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: <Zfhs5LD-1RQt3aw4@kernel.org>
Date: Mon, 18 Mar 2024 18:33:40 +0200
From: Mike Rapoport <rppt@...nel.org>
To: thunder.leizhen@...weicloud.com
Cc: Andrew Morton <akpm@...ux-foundation.org>, linux-mm@...ck.org,
	linux-kernel@...r.kernel.org
Subject: Re: [PATCH 1/1] mm/mm_init.c: eliminate a local variable in
 mem_debugging_and_hardening_init()

On Mon, Mar 18, 2024 at 09:57:14PM +0800, thunder.leizhen@...weicloud.com wrote:
> From: Zhen Lei <thunder.leizhen@...wei.com>
> 
> The local variable 'page_poisoning_requested' is assigned true at only
> one point. It can be eliminated by moving the code that depends on it
> to the location where it is assigned true. This also make the moved
> code to be compiled only if CONFIG_PAGE_POISONING is set.

I don't see it as much of an improvement and code readability becomes worse
IMO.
 
> Signed-off-by: Zhen Lei <thunder.leizhen@...wei.com>
> ---
>  mm/mm_init.c | 17 +++++++----------
>  1 file changed, 7 insertions(+), 10 deletions(-)
> 
> diff --git a/mm/mm_init.c b/mm/mm_init.c
> index 549e76af8f82a8e..3eb217130bcb2b5 100644
> --- a/mm/mm_init.c
> +++ b/mm/mm_init.c
> @@ -2614,7 +2614,6 @@ DEFINE_STATIC_KEY_MAYBE(CONFIG_DEBUG_VM, check_pages_enabled);
>   */
>  static void __init mem_debugging_and_hardening_init(void)
>  {
> -	bool page_poisoning_requested = false;
>  	bool want_check_pages = false;
>  
>  #ifdef CONFIG_PAGE_POISONING
> @@ -2626,18 +2625,16 @@ static void __init mem_debugging_and_hardening_init(void)
>  	     (!IS_ENABLED(CONFIG_ARCH_SUPPORTS_DEBUG_PAGEALLOC) &&
>  	      debug_pagealloc_enabled())) {
>  		static_branch_enable(&_page_poisoning_enabled);
> -		page_poisoning_requested = true;
>  		want_check_pages = true;
> -	}
> -#endif
>  
> -	if ((_init_on_alloc_enabled_early || _init_on_free_enabled_early) &&
> -	    page_poisoning_requested) {
> -		pr_info("mem auto-init: CONFIG_PAGE_POISONING is on, "
> -			"will take precedence over init_on_alloc and init_on_free\n");
> -		_init_on_alloc_enabled_early = false;
> -		_init_on_free_enabled_early = false;
> +		if (_init_on_alloc_enabled_early || _init_on_free_enabled_early) {
> +			pr_info("mem auto-init: CONFIG_PAGE_POISONING is on, "
> +				"will take precedence over init_on_alloc and init_on_free\n");
> +			_init_on_alloc_enabled_early = false;
> +			_init_on_free_enabled_early = false;
> +		}
>  	}
> +#endif
>  
>  	if (_init_on_alloc_enabled_early) {
>  		want_check_pages = true;
> -- 
> 2.34.1
> 

-- 
Sincerely yours,
Mike.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ