From: "Michał Mirosław" <mirqus@gmail.com>
To: Eric Dumazet <eric.dumazet@gmail.com>,
Tetsuo Handa <penguin-kernel@i-love.sakura.ne.jp>,
netdev@vger.kernel.org
Subject: Re: [PATCH] UNIX: Do not loop forever at unix_autobind().
Date: Sat, 4 Sep 2010 13:52:13 +0200 [thread overview]
Message-ID: <AANLkTiksRN1DweFkwzhaTe7fUayKEDrjHzn7xSScikV7@mail.gmail.com> (raw)
In-Reply-To: <1283584269.3402.9.camel@edumazet-laptop>
2010/9/4 Eric Dumazet <eric.dumazet@gmail.com>:
> Le samedi 04 septembre 2010 à 15:58 +0900, Tetsuo Handa a écrit :
>> From a67ccbb8033993df29f26bde9944e37bffe4fc1b Mon Sep 17 00:00:00 2001
>> From: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
>> Date: Sat, 4 Sep 2010 15:22:22 +0900
>> Subject: [PATCH] UNIX: Do not loop forever at unix_autobind().
>>
>> We assumed that unix_autobind() never fails if kzalloc() succeeded.
>> But unix_autobind() allows only 1048576 names. If /proc/sys/fs/file-max is
>> larger than 1048576 (e.g. systems with more than 10GB of RAM), a local user can
>> consume all names using fork()/socket()/bind().
>>
>> If all names are in use, those who call bind() with addr_len == sizeof(short)
>> or connect()/sendmsg() with setsockopt(SO_PASSCRED) will continue
>>
>> while (1)
>> yield();
>>
>> loop at unix_autobind() till a name becomes available.
>> This patch changes unix_autobind() to fail if all names are in use.
>>
>> Note that currently a local user can consume 2GB of kernel memory if the user
>> is allowed to create and autobind 1048576 UNIX domain sockets. We should
>> consider adding some restriction for autobind operation.
[cut patch]
> Sorry, this wont work very well if you have many processes using
> autobind(). Some of them will loop many time before hitting
> "stop_ordernum".
>
> unsigned int counter;
>
> ...
>
> if (++maxtries == 1<<20) {
> ...
> }
>
>
> This is a pathological situation. We are not forced to give a successful
> autobind() when so many sockets are in use, even if some slots are
> available.
Is there any specific requirement on generated names for auto-bind?
Wouldn't it be easier and more efficient to use some pseudo-random
name. i.e. derived from current time and/or owning process state?
Best Regards,
Michał Mirosław
next prev parent reply other threads:[~2010-09-04 11:52 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-08-21 12:01 About unix_autobind() Tetsuo Handa
2010-08-21 12:34 ` Changli Gao
2010-08-30 13:27 ` [PATCH] UNIX: Do not loop forever at unix_autobind() Tetsuo Handa
2010-09-01 19:47 ` Eric Dumazet
2010-09-04 6:58 ` Tetsuo Handa
2010-09-04 7:11 ` Eric Dumazet
2010-09-04 7:40 ` Tetsuo Handa
2010-09-04 8:24 ` Eric Dumazet
2010-09-04 9:31 ` Tetsuo Handa
2010-09-04 10:55 ` Eric Dumazet
2010-09-04 11:34 ` Tetsuo Handa
2010-09-07 1:45 ` David Miller
2010-09-04 11:52 ` Michał Mirosław [this message]
2010-09-01 21:33 ` How can OOM killer detect process consuming much kernel memory? Tetsuo Handa
2010-09-01 22:25 ` David Rientjes
2010-09-03 6:32 ` KOSAKI Motohiro
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=AANLkTiksRN1DweFkwzhaTe7fUayKEDrjHzn7xSScikV7@mail.gmail.com \
--to=mirqus@gmail.com \
--cc=eric.dumazet@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=penguin-kernel@i-love.sakura.ne.jp \
/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;
as well as URLs for NNTP newsgroup(s).