[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20200813145941.GJ17456@casper.infradead.org>
Date: Thu, 13 Aug 2020 15:59:41 +0100
From: Matthew Wilcox <willy@...radead.org>
To: Josef Bacik <josef@...icpanda.com>
Cc: hch@....de, viro@...iv.linux.org.uk, linux-fsdevel@...r.kernel.org,
linux-kernel@...r.kernel.org, kernel-team@...com
Subject: Re: [PATCH] proc: use vmalloc for our kernel buffer
On Thu, Aug 13, 2020 at 10:53:05AM -0400, Josef Bacik wrote:
> +/**
> + * vmemdup_user - duplicate memory region from user space and NUL-terminate
vmemdup_user_nul()
> +void *vmemdup_user_nul(const void __user *src, size_t len)
> +{
> + void *p;
> +
> + p = kvmalloc(len, GFP_USER);
len+1, shirley?
> + if (!p)
> + return ERR_PTR(-ENOMEM);
> +
> + if (copy_from_user(p, src, len)) {
> + kvfree(p);
> + return ERR_PTR(-EFAULT);
> + }
I think you forgot
p[len] = '\0';
> + return p;
> +}
> +EXPORT_SYMBOL(vmemdup_user_nul);
> +
> /**
> * strndup_user - duplicate an existing string from user space
> * @s: The string to duplicate
> --
> 2.24.1
>
Powered by blists - more mailing lists