Linux-Fsdevel Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Vlastimil Babka <vbabka@suse.cz>
To: Josef Bacik <josef@toxicpanda.com>,
	viro@ZenIV.linux.org.uk, akpm@linux-foundation.org,
	linux-fsdevel@vger.kernel.org, willy@infradead.org
Cc: Christoph Hellwig <hch@lst.de>, Steven Noonan <steven@uplinklabs.net>
Subject: Re: [PATCH] proc: use vmalloc for our kernel buffer
Date: Wed, 10 Feb 2021 18:16:08 +0100	[thread overview]
Message-ID: <4d4257c0-37ff-4602-a540-1607a8b42525@suse.cz> (raw)
In-Reply-To: <6345270a2c1160b89dd5e6715461f388176899d1.1612972413.git.josef@toxicpanda.com>

On 2/10/21 4:54 PM, Josef Bacik wrote:
> Since
> 
>   sysctl: pass kernel pointers to ->proc_handler
> 
> we have been pre-allocating a buffer to copy the data from the proc
> handlers into, and then copying that to userspace.  The problem is this
> just blind kmalloc()'s the buffer size passed in from the read, which in
> the case of our 'cat' binary was 64kib.  Order-4 allocations are not
> awesome, and since we can potentially allocate up to our maximum order,
> use vmalloc for these buffers.
> 
> Fixes: 32927393dc1c ("sysctl: pass kernel pointers to ->proc_handler")
> Signed-off-by: Josef Bacik <josef@toxicpanda.com>
> Reviewed-by: Christoph Hellwig <hch@lst.de>

Acked-by: Vlastimil Babka <vbabka@suse.cz>

> ---
>  fs/proc/proc_sysctl.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/fs/proc/proc_sysctl.c b/fs/proc/proc_sysctl.c
> index d2018f70d1fa..070d2df8ab9c 100644
> --- a/fs/proc/proc_sysctl.c
> +++ b/fs/proc/proc_sysctl.c
> @@ -571,7 +571,7 @@ static ssize_t proc_sys_call_handler(struct kiocb *iocb, struct iov_iter *iter,
>  	error = -ENOMEM;
>  	if (count >= KMALLOC_MAX_SIZE)
>  		goto out;
> -	kbuf = kzalloc(count + 1, GFP_KERNEL);
> +	kbuf = kvzalloc(count + 1, GFP_KERNEL);
>  	if (!kbuf)
>  		goto out;
>  
> @@ -600,7 +600,7 @@ static ssize_t proc_sys_call_handler(struct kiocb *iocb, struct iov_iter *iter,
>  
>  	error = count;
>  out_free_buf:
> -	kfree(kbuf);
> +	kvfree(kbuf);
>  out:
>  	sysctl_head_finish(head);
>  
> 


  reply	other threads:[~2021-02-10 17:17 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-10 15:54 Josef Bacik
2021-02-10 17:16 ` Vlastimil Babka [this message]
2021-02-10 18:15 ` Matthew Wilcox
  -- strict thread matches above, loose matches on Subject: below --
2020-08-13 14:53 Josef Bacik
2020-08-13 14:59 ` Matthew Wilcox
2020-08-13 15:08   ` Josef Bacik
2020-08-13 16:19 ` David Laight
2020-08-13 16:21   ` Al Viro
2020-08-13 17:08   ` Josef Bacik

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4d4257c0-37ff-4602-a540-1607a8b42525@suse.cz \
    --to=vbabka@suse.cz \
    --cc=akpm@linux-foundation.org \
    --cc=hch@lst.de \
    --cc=josef@toxicpanda.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=steven@uplinklabs.net \
    --cc=viro@ZenIV.linux.org.uk \
    --cc=willy@infradead.org \
    --subject='Re: [PATCH] proc: use vmalloc for our kernel buffer' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).