[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20201216043323.GM3579531@ZenIV.linux.org.uk>
Date: Wed, 16 Dec 2020 04:33:23 +0000
From: Al Viro <viro@...iv.linux.org.uk>
To: Siddhesh Poyarekar <siddhesh@...plt.org>
Cc: linux-kernel@...r.kernel.org, linux-fsdevel@...r.kernel.org,
Florian Weimer <fweimer@...hat.com>
Subject: Re: [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.?
Powered by blists - more mailing lists