lkml.org 
[lkml]   [2020]   [Dec]   [15]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v2] proc: Escape more characters in /proc/mounts output
On Tue, Dec 15, 2020 at 06:23:18PM +0530, Siddhesh Poyarekar wrote:

> +static char *copy_mount_devname(const void __user *data)
> +{
> + char *p;
> + long length;
> +
> + if (data == NULL)
> + return NULL;
> +
> + length = strnlen_user(data, PATH_MAX);
> +
> + if (!length)
> + return ERR_PTR(-EFAULT);
> +
> + if (length > PATH_MAX)
> + return ERR_PTR(-EINVAL);
> +
> + /* Ignore blank strings */
> + if (length == 1)
> + return NULL;
> +
> + p = memdup_user(data, length);

Once more, with feeling: why bother? What's wrong
with using the damn strndup_user() and then doing
whatever checks you want with the data already
copied, living in normal kernel memory, with all
string functions applicable, etc.?

\
 
 \ /
  Last update: 2020-12-16 05:34    [W:0.627 / U:0.020 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site