From: Hannes Frederic Sowa <hannes@stressinduktion.org>
To: Willy Tarreau <w@1wt.eu>
Cc: "David S. Miller" <davem@davemloft.net>,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
Linus Torvalds <torvalds@linux-foundation.org>,
Eric Dumazet <edumazet@google.com>,
socketpair@gmail.com
Subject: Re: [PATCH] unix: properly account for FDs passed over unix sockets
Date: Wed, 30 Dec 2015 09:58:42 +0100 [thread overview]
Message-ID: <56839CC2.9080000@stressinduktion.org> (raw)
In-Reply-To: <20151229203527.GA13826@1wt.eu>
On 29.12.2015 21:35, Willy Tarreau wrote:
> On Tue, Dec 29, 2015 at 03:48:45PM +0100, Hannes Frederic Sowa wrote:
>> On 28.12.2015 15:14, Willy Tarreau wrote:
>>> It is possible for a process to allocate and accumulate far more FDs than
>>> the process' limit by sending them over a unix socket then closing them
>>> to keep the process' fd count low.
>>>
>>> This change addresses this problem by keeping track of the number of FDs
>>> in flight per user and preventing non-privileged processes from having
>>> more FDs in flight than their configured FD limit.
>>>
>>> Reported-by: socketpair@gmail.com
>>> Suggested-by: Linus Torvalds <torvalds@linux-foundation.org>
>>> Signed-off-by: Willy Tarreau <w@1wt.eu>
>>
>> Thanks for the patch!
>>
>> I think this does not close the DoS attack completely as we duplicate
>> fds if the reader uses MSG_PEEK on the unix domain socket and thus
>> clones the fd. Have I overlooked something?
>
> I didn't know this behaviour. However, then the fd remains in flight, right ?
> So as long as it's not removed from the queue, the sender cannot add more
> than its FD limit. I may be missing something obvious though :-/
Yes, it remains in flight.
The MSG_PEEK code should not be harmful and the patch is good as is. I
first understood from the published private thread, that it is possible
for a program to exceed the rlimit of fds. But the DoS is only by
keeping the fds in flight and not attaching them to any program.
__alloc_fd, called on the receiver side, does check for the rlimit
maximum anyway, so I don't see a loophole anymore:
Acked-by: Hannes Frederic Sowa <hannes@stressinduktion.org>
Another idea would be to add the amount of memory used to manage the fds
to sock_rmem/wmem but I don't see any advantages or disadvantages.
Thanks!
next prev parent reply other threads:[~2015-12-30 8:58 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-12-28 14:14 [PATCH] unix: properly account for FDs passed over unix sockets Willy Tarreau
2015-12-29 14:37 ` Hannes Frederic Sowa
2015-12-29 14:48 ` Hannes Frederic Sowa
2015-12-29 20:35 ` Willy Tarreau
2015-12-30 8:58 ` Hannes Frederic Sowa [this message]
2015-12-30 11:23 ` Willy Tarreau
2015-12-30 13:14 ` One Thousand Gnomes
2015-12-31 6:08 ` Tetsuo Handa
2015-12-31 7:12 ` Willy Tarreau
2015-12-31 10:27 ` One Thousand Gnomes
2016-01-04 21:44 ` David Miller
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=56839CC2.9080000@stressinduktion.org \
--to=hannes@stressinduktion.org \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=socketpair@gmail.com \
--cc=torvalds@linux-foundation.org \
--cc=w@1wt.eu \
/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