lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <9b23bb6bcabe4f419cb8510e99275085@AcuMS.aculab.com>
Date:   Thu, 12 Oct 2023 13:54:06 +0000
From:   David Laight <David.Laight@...LAB.COM>
To:     'Alexey Dobriyan' <adobriyan@...il.com>,
        "akpm@...ux-foundation.org" <akpm@...ux-foundation.org>
CC:     "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
        Al Viro <viro@...iv.linux.org.uk>
Subject: RE: [PATCH] fs: move and constify sysctl_nr_open_min,
 sysctl_nr_open_max

From: Alexey Dobriyan
> Sent: 11 October 2023 19:24
> 
> sysctl_nr_open_min, sysctl_nr_open_max variables are really hard limits
> on fs.nr_open sysctl, they aren't interesting to the rest of the code
> and are constants (sysctl_nr_open is not constant obviously).
> 
> Signed-off-by: Alexey Dobriyan <adobriyan@...il.com>
> ---
> 
>  fs/file.c            |    5 -----
>  fs/file_table.c      |   10 ++++++++--
>  include/linux/file.h |    2 --
>  3 files changed, 8 insertions(+), 9 deletions(-)
> 
> --- a/fs/file.c
> +++ b/fs/file.c
> @@ -25,11 +25,6 @@
>  #include "internal.h"
> 
>  unsigned int sysctl_nr_open __read_mostly = 1024*1024;
> -unsigned int sysctl_nr_open_min = BITS_PER_LONG;
> -/* our min() is unusable in constant expressions ;-/ */
> -#define __const_min(x, y) ((x) < (y) ? (x) : (y))
> -unsigned int sysctl_nr_open_max =
> -	__const_min(INT_MAX, ~(size_t)0/sizeof(void *)) & -BITS_PER_LONG;
> 
>  static void __free_fdtable(struct fdtable *fdt)
>  {
> --- a/fs/file_table.c
> +++ b/fs/file_table.c
> @@ -111,6 +111,12 @@ static int proc_nr_files(struct ctl_table *table, int write, void *buffer,
>  	return proc_doulongvec_minmax(table, write, buffer, lenp, ppos);
>  }
> 
> +static const unsigned int sysctl_nr_open_min = BITS_PER_LONG;
> +/* our min() is unusable in constant expressions ;-/ */
> +#define __const_min(x, y) ((x) < (y) ? (x) : (y))
> +static const unsigned int sysctl_nr_open_max =
> +	__const_min(INT_MAX, ~(size_t)0/sizeof(void *)) & -BITS_PER_LONG;

I think you'll find that min() is fine.

Although those upper limits look suspect to me.
Looks like ~0.5G on 32bit and ~2G on 64bit based on the size of a bitmap?
But the kernel will run out of address space much earlier - esp on 32bit.

	David

 

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ