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: <CAGsJ_4yAp=VF4c12soA0U5dzX-ksb3FV4UnC5e7Jtp+D6BO4iw@mail.gmail.com>
Date: Fri, 6 Sep 2024 21:25:50 +1200
From: Barry Song <21cnbao@...il.com>
To: Hailong Liu <hailong.liu@...o.com>
Cc: viro@...iv.linux.org.uk, brauner@...nel.org, jack@...e.cz, 
	linux-fsdevel@...r.kernel.org, linux-kernel@...r.kernel.org, 
	linux-mm@...ck.org
Subject: Re: [PATCH] seq_file: replace kzalloc() with kvzalloc()

On Fri, Sep 6, 2024 at 8:06 PM Hailong Liu <hailong.liu@...o.com> wrote:
>
> __seq_open_private() uses kzalloc() to allocate a private buffer. However,
> the size of the buffer might be greater than order-3, which may cause
> allocation failure. To address this issue, use kvzalloc instead.

In general, this patch seems sensible, but do we have a specific example
of a driver that uses such a large amount of private data?
Providing a real-world example of a driver with substantial private data could
make this patch more convincing:-)

>
> Signed-off-by: Hailong Liu <hailong.liu@...o.com>
> ---
>  fs/seq_file.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/fs/seq_file.c b/fs/seq_file.c
> index e676c8b0cf5d..cf23143bbb65 100644
> --- a/fs/seq_file.c
> +++ b/fs/seq_file.c
> @@ -621,7 +621,7 @@ int seq_release_private(struct inode *inode, struct file *file)
>  {
>         struct seq_file *seq = file->private_data;
>
> -       kfree(seq->private);
> +       kvfree(seq->private);
>         seq->private = NULL;
>         return seq_release(inode, file);
>  }
> @@ -634,7 +634,7 @@ void *__seq_open_private(struct file *f, const struct seq_operations *ops,
>         void *private;
>         struct seq_file *seq;
>
> -       private = kzalloc(psize, GFP_KERNEL_ACCOUNT);
> +       private = kvzalloc(psize, GFP_KERNEL_ACCOUNT);
>         if (private == NULL)
>                 goto out;
>
> @@ -647,7 +647,7 @@ void *__seq_open_private(struct file *f, const struct seq_operations *ops,
>         return private;
>
>  out_free:
> -       kfree(private);
> +       kvfree(private);
>  out:
>         return NULL;
>  }
> --
> 2.30.0
>
>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ