mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Wen Yang <wenyang@linux.alibaba.com>
To: Eric Dumazet <eric.dumazet@gmail.com>,
	davem@davemloft.net, David Ahern <dsahern@kernel.org>,
	Jakub Kicinski <kuba@kernel.org>,
	Hideaki YOSHIFUJI <yoshfuji@linux-ipv6.org>,
	Baoyou Xie <baoyou.xie@alibaba-inc.com>
Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 2/2] net: return early for possible invalid uaddr
Date: Fri, 13 Aug 2021 01:35:57 +0800	[thread overview]
Message-ID: <6c11b9e7-6aac-65c9-4755-99d41fbdcb4e@linux.alibaba.com> (raw)
In-Reply-To: <247c8272-0e26-87ab-d492-140047d4abc4@gmail.com>



在 2021/8/12 上午12:11, Eric Dumazet 写道:
> 
> 
> On 8/11/21 5:24 PM, Wen Yang wrote:
>> The inet_dgram_connect() first calls inet_autobind() to select an
>> ephemeral port, then checks uaddr in udp_pre_connect() or
>> __ip4_datagram_connect(), but the port is not released until the socket
>> is closed. This could cause performance issues or even exhaust ephemeral
>> ports if a malicious user makes a large number of UDP connections with
>> invalid uaddr and/or addr_len.
>>
>>   
> 
> This is a big patch.
> 
> Can the malicious user still use a large number of UDP sockets,
> with valid uaddr/add_len and consequently exhaust ephemeral ports ?
> 
> If yes, it does not seem your patch is helping.
> 

Thank you for your comments.
However, we could make these optimizations:

1, If the user passed in some invalid parameters, we should return as
soon as possible. We shouldn't assume that these parameters are valid
first, then do some real work (such as select an ephemeral port), and
then finally check that they are indeed valid or not.

2. Unify the code for checking parameters in udp_pre_connect() and
__ip4_datagram_connect() to make the code clearer.

> If no, have you tried instead to undo the autobind, if the connect fails ?
> 

Thanks. Undo the autobind is useful if the connect fails.
We will add this logic and submit the v3 patch later.

-- 
Best wishes,
Wen


  reply	other threads:[~2021-08-12 17:36 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-11 15:24 [PATCH 1/2] ipv4: fix up inetsw_array coding style Wen Yang
2021-08-11 15:24 ` [PATCH v2 2/2] net: return early for possible invalid uaddr Wen Yang
2021-08-11 16:11   ` Eric Dumazet
2021-08-12 17:35     ` Wen Yang [this message]
2021-08-17  4:08       ` Wen Yang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=6c11b9e7-6aac-65c9-4755-99d41fbdcb4e@linux.alibaba.com \
    --to=wenyang@linux.alibaba.com \
    --cc=baoyou.xie@alibaba-inc.com \
    --cc=davem@davemloft.net \
    --cc=dsahern@kernel.org \
    --cc=eric.dumazet@gmail.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=yoshfuji@linux-ipv6.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®