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.?