From: Xi Wang <xi.wang@gmail.com> Date: 2012-08-25 06:06:16
This patch complements 518de9b3 ("fs: allow for more than 2^31 files").
get_max_files() returns files_stat.max_files, which can be set to any
value from user space via /proc/sys/fs/file-max. A large file-max will
cause an integer overflow in the following check:
if (atomic_long_read(&unix_nr_socks) > 2 * get_max_files())
goto out;
The kernel will then fail to create a unix domain socket.
Rewrite the check using "/ 2" on the left-hand side.
Signed-off-by: Xi Wang <xi.wang@gmail.com>
Cc: Eric Dumazet <edumazet@google.com>
---
net/unix/af_unix.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
From: Eric Dumazet <hidden> Date: 2012-08-25 06:43:15
On Sat, 2012-08-25 at 02:05 -0400, Xi Wang wrote:
quoted hunk
This patch complements 518de9b3 ("fs: allow for more than 2^31 files").
get_max_files() returns files_stat.max_files, which can be set to any
value from user space via /proc/sys/fs/file-max. A large file-max will
cause an integer overflow in the following check:
if (atomic_long_read(&unix_nr_socks) > 2 * get_max_files())
goto out;
The kernel will then fail to create a unix domain socket.
Rewrite the check using "/ 2" on the left-hand side.
Signed-off-by: Xi Wang <xi.wang@gmail.com>
Cc: Eric Dumazet <edumazet@google.com>
---
net/unix/af_unix.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
I dont think this patch is right.
atomic_long_inc_return() is expensive, more than atomic_long_inc()
And setting a 2^63 limit for max number of files is plain wrong,
as there is no way a kernel can allocate 2^63 files structures.
(same apply on 32bit arches, but for 2^31)
If you feel you must warn a sysadmin of stupid settings, add sane
boundaries in kernel/sysctl.c, and send your patch to lkml instead.
From: Xi Wang <xi.wang@gmail.com> Date: 2012-08-25 16:17:45
On Aug 25, 2012, at 2:43 AM, Eric Dumazet [off-list ref] wrote:
I dont think this patch is right.
atomic_long_inc_return() is expensive, more than atomic_long_inc()
And setting a 2^63 limit for max number of files is plain wrong,
as there is no way a kernel can allocate 2^63 files structures.
(same apply on 32bit arches, but for 2^31)
If you feel you must warn a sysadmin of stupid settings, add sane
boundaries in kernel/sysctl.c, and send your patch to lkml instead.
Yeah, I agree it's better to limit max_files in sysctl. I will send
another patch instead. Thanks.
- xi