[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CAOQ4uxjFombc5SQDRxGFn3we-rJ8nbd4KrTfECG3AzSNwcQHuQ@mail.gmail.com>
Date: Wed, 5 Nov 2025 16:37:36 +0100
From: Amir Goldstein <amir73il@...il.com>
To: Ally Heev <allyheev@...il.com>, Christian Brauner <brauner@...nel.org>
Cc: Miklos Szeredi <miklos@...redi.hu>, linux-unionfs@...r.kernel.org,
linux-kernel@...r.kernel.org, Dan Carpenter <dan.carpenter@...aro.org>
Subject: Re: [PATCH] overlayfs: fix uninitialized pointers with free attr
On Wed, Nov 5, 2025 at 3:33 PM Ally Heev <allyheev@...il.com> wrote:
>
> Uninitialized pointers with `__free` attribute can cause undefined
> behaviour as the memory assigned(randomly) to the pointer is freed
> automatically when the pointer goes out of scope
>
> overlayfs doesn't have any bugs related to this as of now, but
> it is better to initialize and assign pointers with `__free` attr
> in one statement to ensure proper scope-based cleanup
>
> Reported-by: Dan Carpenter <dan.carpenter@...aro.org>
> Closes: https://lore.kernel.org/all/aPiG_F5EBQUjZqsl@stanley.mountain/
> Signed-off-by: Ally Heev <allyheev@...il.com>
> ---
Christian,
Would you mind picking this patch?
Feel free to add:
Acked-by: Amir Goldstein <amir73il@...il.com>
Thanks,
Amir.
> fs/overlayfs/params.c | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/fs/overlayfs/params.c b/fs/overlayfs/params.c
> index 63b7346c5ee1c127a9c33b12c3704aa035ff88cf..56d5906e1e41ae6581911cbd269d0fb085db4516 100644
> --- a/fs/overlayfs/params.c
> +++ b/fs/overlayfs/params.c
> @@ -448,10 +448,9 @@ static int ovl_parse_layer(struct fs_context *fc, struct fs_parameter *param,
> err = ovl_do_parse_layer(fc, param->string, &layer_path, layer);
> break;
> case fs_value_is_file: {
> - char *buf __free(kfree);
> char *layer_name;
> + char *buf __free(kfree) = kmalloc(PATH_MAX, GFP_KERNEL_ACCOUNT);
>
> - buf = kmalloc(PATH_MAX, GFP_KERNEL_ACCOUNT);
> if (!buf)
> return -ENOMEM;
>
>
> ---
> base-commit: c9cfc122f03711a5124b4aafab3211cf4d35a2ac
> change-id: 20251105-aheev-uninitialized-free-attr-overlayfs-6873964429e0
>
> Best regards,
> --
> Ally Heev <allyheev@...il.com>
>
Powered by blists - more mailing lists