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: <ef1d602b-23cb-4a95-b83e-c506958dc90c@lucifer.local>
Date: Thu, 2 Jan 2025 14:08:04 +0000
From: Lorenzo Stoakes <lorenzo.stoakes@...cle.com>
To: Kaixiong Yu <yukaixiong@...wei.com>
Cc: akpm@...ux-foundation.org, mcgrof@...nel.org, ysato@...rs.sourceforge.jp,
        dalias@...c.org, glaubitz@...sik.fu-berlin.de, luto@...nel.org,
        tglx@...utronix.de, mingo@...hat.com, bp@...en8.de,
        dave.hansen@...ux.intel.com, hpa@...or.com, viro@...iv.linux.org.uk,
        brauner@...nel.org, jack@...e.cz, kees@...nel.org,
        j.granados@...sung.com, willy@...radead.org, Liam.Howlett@...cle.com,
        vbabka@...e.cz, trondmy@...nel.org, anna@...nel.org,
        chuck.lever@...cle.com, jlayton@...nel.org, neilb@...e.de,
        okorniev@...hat.com, Dai.Ngo@...cle.com, tom@...pey.com,
        davem@...emloft.net, edumazet@...gle.com, kuba@...nel.org,
        pabeni@...hat.com, paul@...l-moore.com, jmorris@...ei.org,
        linux-sh@...r.kernel.org, linux-kernel@...r.kernel.org,
        linux-fsdevel@...r.kernel.org, linux-mm@...ck.org,
        linux-nfs@...r.kernel.org, netdev@...r.kernel.org,
        linux-security-module@...r.kernel.org, dhowells@...hat.com,
        haifeng.xu@...pee.com, baolin.wang@...ux.alibaba.com,
        shikemeng@...weicloud.com, dchinner@...hat.com, bfoster@...hat.com,
        souravpanda@...gle.com, hannes@...xchg.org, rientjes@...gle.com,
        pasha.tatashin@...een.com, david@...hat.com, ryan.roberts@....com,
        ying.huang@...el.com, yang@...amperecomputing.com,
        zev@...ilderbeest.net, serge@...lyn.com, vegard.nossum@...cle.com,
        wangkefeng.wang@...wei.com
Subject: Re: [PATCH v4 -next 06/15] mm: mmap: move sysctl to mm/mmap.c

On Mon, Dec 23, 2024 at 10:15:25PM +0800, Kaixiong Yu wrote:
> This moves all mmap related sysctls to mm/mmap.c, as part of the
> kernel/sysctl.c cleaning, also move the variable declaration from
> kernel/sysctl.c into mm/mmap.c.
>
> Signed-off-by: Kaixiong Yu <yukaixiong@...wei.com>
> Reviewed-by: Kees Cook <kees@...nel.org>

Looks good to me, thanks!

Reviewed-by: Lorenzo Stoakes <lorenzo.stoakes@...cle.com>

> ---
> v4:
>  - const qualify struct ctl_table mmap_table
> v3:
>  - change the title
> v2:
>  - fix sysctl_max_map_count undeclared issue in mm/nommu.c
> ---
> ---
>  kernel/sysctl.c | 50 +--------------------------------------------
>  mm/mmap.c       | 54 +++++++++++++++++++++++++++++++++++++++++++++++++
>  2 files changed, 55 insertions(+), 49 deletions(-)
>
> diff --git a/kernel/sysctl.c b/kernel/sysctl.c
> index aea3482106e0..9c245898f535 100644
> --- a/kernel/sysctl.c
> +++ b/kernel/sysctl.c
> @@ -127,12 +127,6 @@ enum sysctl_writes_mode {
>
>  static enum sysctl_writes_mode sysctl_writes_strict = SYSCTL_WRITES_STRICT;
>  #endif /* CONFIG_PROC_SYSCTL */
> -
> -#if defined(HAVE_ARCH_PICK_MMAP_LAYOUT) || \
> -    defined(CONFIG_ARCH_WANT_DEFAULT_TOPDOWN_MMAP_LAYOUT)
> -int sysctl_legacy_va_layout;
> -#endif
> -
>  #endif /* CONFIG_SYSCTL */
>
>  /*
> @@ -2037,16 +2031,7 @@ static struct ctl_table vm_table[] = {
>  		.extra1		= SYSCTL_ONE,
>  		.extra2		= SYSCTL_FOUR,
>  	},
> -#ifdef CONFIG_MMU
> -	{
> -		.procname	= "max_map_count",
> -		.data		= &sysctl_max_map_count,
> -		.maxlen		= sizeof(sysctl_max_map_count),
> -		.mode		= 0644,
> -		.proc_handler	= proc_dointvec_minmax,
> -		.extra1		= SYSCTL_ZERO,
> -	},
> -#else
> +#ifndef CONFIG_MMU
>  	{
>  		.procname	= "nr_trim_pages",
>  		.data		= &sysctl_nr_trim_pages,
> @@ -2064,17 +2049,6 @@ static struct ctl_table vm_table[] = {
>  		.proc_handler	= proc_dointvec_minmax,
>  		.extra1		= SYSCTL_ZERO,
>  	},

Nitty, but  this bit belongs in mm/nommu.c?

> -#if defined(HAVE_ARCH_PICK_MMAP_LAYOUT) || \
> -    defined(CONFIG_ARCH_WANT_DEFAULT_TOPDOWN_MMAP_LAYOUT)
> -	{
> -		.procname	= "legacy_va_layout",
> -		.data		= &sysctl_legacy_va_layout,
> -		.maxlen		= sizeof(sysctl_legacy_va_layout),
> -		.mode		= 0644,
> -		.proc_handler	= proc_dointvec_minmax,
> -		.extra1		= SYSCTL_ZERO,
> -	},
> -#endif
>  #ifdef CONFIG_MMU
>  	{
>  		.procname	= "mmap_min_addr",
> @@ -2100,28 +2074,6 @@ static struct ctl_table vm_table[] = {
>  		.extra1		= SYSCTL_ZERO,
>  	},
>  #endif
> -#ifdef CONFIG_HAVE_ARCH_MMAP_RND_BITS
> -	{
> -		.procname	= "mmap_rnd_bits",
> -		.data		= &mmap_rnd_bits,
> -		.maxlen		= sizeof(mmap_rnd_bits),
> -		.mode		= 0600,
> -		.proc_handler	= proc_dointvec_minmax,
> -		.extra1		= (void *)&mmap_rnd_bits_min,
> -		.extra2		= (void *)&mmap_rnd_bits_max,
> -	},
> -#endif
> -#ifdef CONFIG_HAVE_ARCH_MMAP_RND_COMPAT_BITS
> -	{
> -		.procname	= "mmap_rnd_compat_bits",
> -		.data		= &mmap_rnd_compat_bits,
> -		.maxlen		= sizeof(mmap_rnd_compat_bits),
> -		.mode		= 0600,
> -		.proc_handler	= proc_dointvec_minmax,
> -		.extra1		= (void *)&mmap_rnd_compat_bits_min,
> -		.extra2		= (void *)&mmap_rnd_compat_bits_max,
> -	},
> -#endif
>  };
>
>  int __init sysctl_init_bases(void)
> diff --git a/mm/mmap.c b/mm/mmap.c
> index aef835984b1c..cc579aafd7ba 100644
> --- a/mm/mmap.c
> +++ b/mm/mmap.c
> @@ -1603,6 +1603,57 @@ struct vm_area_struct *_install_special_mapping(
>  					&special_mapping_vmops);
>  }
>
> +#ifdef CONFIG_SYSCTL
> +#if defined(HAVE_ARCH_PICK_MMAP_LAYOUT) || \
> +		defined(CONFIG_ARCH_WANT_DEFAULT_TOPDOWN_MMAP_LAYOUT)
> +int sysctl_legacy_va_layout;
> +#endif
> +
> +static const struct ctl_table mmap_table[] = {
> +		{
> +				.procname       = "max_map_count",
> +				.data           = &sysctl_max_map_count,
> +				.maxlen         = sizeof(sysctl_max_map_count),
> +				.mode           = 0644,
> +				.proc_handler   = proc_dointvec_minmax,
> +				.extra1         = SYSCTL_ZERO,
> +		},
> +#if defined(HAVE_ARCH_PICK_MMAP_LAYOUT) || \
> +		defined(CONFIG_ARCH_WANT_DEFAULT_TOPDOWN_MMAP_LAYOUT)
> +		{
> +				.procname       = "legacy_va_layout",
> +				.data           = &sysctl_legacy_va_layout,
> +				.maxlen         = sizeof(sysctl_legacy_va_layout),
> +				.mode           = 0644,
> +				.proc_handler   = proc_dointvec_minmax,
> +				.extra1         = SYSCTL_ZERO,
> +		},
> +#endif
> +#ifdef CONFIG_HAVE_ARCH_MMAP_RND_BITS
> +		{
> +				.procname       = "mmap_rnd_bits",
> +				.data           = &mmap_rnd_bits,
> +				.maxlen         = sizeof(mmap_rnd_bits),
> +				.mode           = 0600,
> +				.proc_handler   = proc_dointvec_minmax,
> +				.extra1         = (void *)&mmap_rnd_bits_min,
> +				.extra2         = (void *)&mmap_rnd_bits_max,
> +		},
> +#endif
> +#ifdef CONFIG_HAVE_ARCH_MMAP_RND_COMPAT_BITS
> +		{
> +				.procname       = "mmap_rnd_compat_bits",
> +				.data           = &mmap_rnd_compat_bits,
> +				.maxlen         = sizeof(mmap_rnd_compat_bits),
> +				.mode           = 0600,
> +				.proc_handler   = proc_dointvec_minmax,
> +				.extra1         = (void *)&mmap_rnd_compat_bits_min,
> +				.extra2         = (void *)&mmap_rnd_compat_bits_max,
> +		},
> +#endif
> +};
> +#endif /* CONFIG_SYSCTL */
> +
>  /*
>   * initialise the percpu counter for VM
>   */
> @@ -1612,6 +1663,9 @@ void __init mmap_init(void)
>
>  	ret = percpu_counter_init(&vm_committed_as, 0, GFP_KERNEL);
>  	VM_BUG_ON(ret);
> +#ifdef CONFIG_SYSCTL
> +	register_sysctl_init("vm", mmap_table);
> +#endif
>  }
>
>  /*
> --
> 2.34.1
>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ