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] [day] [month] [year] [list]
Message-ID: <CAOg9mSTEV9A7s_MYK+msgJRzvUS_R6FB+dOvvkDOmeDrUH92Wg@mail.gmail.com>
Date: Wed, 24 Sep 2025 09:55:47 -0400
From: Mike Marshall <hubcap@...ibond.com>
To: Thorsten Blum <thorsten.blum@...ux.dev>
Cc: Martin Brandenburg <martin@...ibond.com>, devel@...ts.orangefs.org, 
	linux-kernel@...r.kernel.org, Mike Marshall <hubcap@...ibond.com>
Subject: Re: [PATCH] fs/orangefs: Replace kzalloc + copy_from_user with memdup_user_nul

Thanks, that looks better in several ways. I ran it through xfstests,
and have added it to my linux-next tree...

-Mike

On Thu, Sep 18, 2025 at 11:08 AM Thorsten Blum <thorsten.blum@...ux.dev> wrote:
>
> Replace kzalloc() followed by copy_from_user() with memdup_user_nul() to
> simplify and improve orangefs_debug_write(). Allocate only 'count' bytes
> instead of the maximum size ORANGEFS_MAX_DEBUG_STRING_LEN, and set 'buf'
> to NULL to ensure kfree(buf) still works.
>
> No functional changes intended.
>
> Signed-off-by: Thorsten Blum <thorsten.blum@...ux.dev>
> ---
>  fs/orangefs/orangefs-debugfs.c | 11 +++++------
>  1 file changed, 5 insertions(+), 6 deletions(-)
>
> diff --git a/fs/orangefs/orangefs-debugfs.c b/fs/orangefs/orangefs-debugfs.c
> index 1c375fb65018..79267b3419f2 100644
> --- a/fs/orangefs/orangefs-debugfs.c
> +++ b/fs/orangefs/orangefs-debugfs.c
> @@ -440,14 +440,13 @@ static ssize_t orangefs_debug_write(struct file *file,
>                 count = ORANGEFS_MAX_DEBUG_STRING_LEN;
>         }
>
> -       buf = kzalloc(ORANGEFS_MAX_DEBUG_STRING_LEN, GFP_KERNEL);
> -       if (!buf)
> -               goto out;
> -
> -       if (copy_from_user(buf, ubuf, count - 1)) {
> +       buf = memdup_user_nul(ubuf, count - 1);
> +       if (IS_ERR(buf)) {
>                 gossip_debug(GOSSIP_DEBUGFS_DEBUG,
> -                            "%s: copy_from_user failed!\n",
> +                            "%s: memdup_user_nul failed!\n",
>                              __func__);
> +               rc = PTR_ERR(buf);
> +               buf = NULL;
>                 goto out;
>         }
>
> --
> 2.51.0
>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ