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: <YeU8PhtvvXIWtTk/@dhcp22.suse.cz>
Date:   Mon, 17 Jan 2022 10:51:58 +0100
From:   Michal Hocko <mhocko@...e.com>
To:     Christophe JAILLET <christophe.jaillet@...adoo.fr>
Cc:     Andy Shevchenko <andy@...nel.org>,
        Stephen Rothwell <sfr@...b.auug.org.au>,
        Andrew Morton <akpm@...ux-foundation.org>,
        Mel Gorman <mgorman@...e.de>, Vlastimil Babka <vbabka@...e.cz>,
        linux-kernel@...r.kernel.org, kernel-janitors@...r.kernel.org
Subject: Re: [PATCH] lib/string_helpers: Use the given gfp flag when
 allocating memory

On Sun 16-01-22 13:49:22, Christophe JAILLET wrote:
> kstrdup_quotable_cmdline() is given a gfp flag that is passed and used for
> memory allocation in kstrdup_quotable() just a few lines below.
> 
> It looks reasonable to use this gfp value for the buffer allocated and
> freed in kstrdup_quotable_cmdline() as well.
> 
> Fixes: 0ee931c4e31a ("mm: treewide: remove GFP_TEMPORARY allocation flag")

I do not think this commit is changing much here. It just replaces
GFP_TEMPORARY with GFP_KERNEL so the code has ignored the gfp mask even
before that change.

All existing callers of kstrdup_quotable_cmdline use GFP_KERNEL so would
it make more sense to simply drop the gfp argument altogether and use
GFP_KERNEL internally?

Normally it is better to have a full control of the allocation mask but
if we have any non-GFP_KERNEL caller then I would rather have the
argument added and the function checked whether all internal paths are
gfp mask aware.

> Signed-off-by: Christophe JAILLET <christophe.jaillet@...adoo.fr>
> ---
> According to what I've found in 5.16, all callers use GFP_KERNEL, so this
> patch should be a no-op.
> But who knows how it will be used in the future. Better safe than sorry.
> ---
>  lib/string_helpers.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/lib/string_helpers.c b/lib/string_helpers.c
> index 90f9f1b7afec..7aceeb40dfd7 100644
> --- a/lib/string_helpers.c
> +++ b/lib/string_helpers.c
> @@ -624,7 +624,7 @@ char *kstrdup_quotable_cmdline(struct task_struct *task, gfp_t gfp)
>  	char *buffer, *quoted;
>  	int i, res;
>  
> -	buffer = kmalloc(PAGE_SIZE, GFP_KERNEL);
> +	buffer = kmalloc(PAGE_SIZE, gfp);
>  	if (!buffer)
>  		return NULL;
>  
> -- 
> 2.32.0

-- 
Michal Hocko
SUSE Labs

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ