mirror of
https://github.com/adulau/aha.git
synced 2024-12-28 03:36:19 +00:00
[PATCH] strndup_user: convert module
Change hand-coded userspace string copying to strndup_user. Signed-off-by: Davi Arnaut <davi.arnaut@gmail.com> Cc: David Howells <dhowells@redhat.com> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
This commit is contained in:
parent
96840aa00a
commit
24277dda3a
1 changed files with 3 additions and 16 deletions
|
@ -1572,7 +1572,6 @@ static struct module *load_module(void __user *umod,
|
||||||
exportindex, modindex, obsparmindex, infoindex, gplindex,
|
exportindex, modindex, obsparmindex, infoindex, gplindex,
|
||||||
crcindex, gplcrcindex, versindex, pcpuindex, gplfutureindex,
|
crcindex, gplcrcindex, versindex, pcpuindex, gplfutureindex,
|
||||||
gplfuturecrcindex;
|
gplfuturecrcindex;
|
||||||
long arglen;
|
|
||||||
struct module *mod;
|
struct module *mod;
|
||||||
long err = 0;
|
long err = 0;
|
||||||
void *percpu = NULL, *ptr = NULL; /* Stops spurious gcc warning */
|
void *percpu = NULL, *ptr = NULL; /* Stops spurious gcc warning */
|
||||||
|
@ -1691,23 +1690,11 @@ static struct module *load_module(void __user *umod,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Now copy in args */
|
/* Now copy in args */
|
||||||
arglen = strlen_user(uargs);
|
args = strndup_user(uargs, ~0UL >> 1);
|
||||||
if (!arglen) {
|
if (IS_ERR(args)) {
|
||||||
err = -EFAULT;
|
err = PTR_ERR(args);
|
||||||
goto free_hdr;
|
goto free_hdr;
|
||||||
}
|
}
|
||||||
args = kmalloc(arglen, GFP_KERNEL);
|
|
||||||
if (!args) {
|
|
||||||
err = -ENOMEM;
|
|
||||||
goto free_hdr;
|
|
||||||
}
|
|
||||||
if (copy_from_user(args, uargs, arglen) != 0) {
|
|
||||||
err = -EFAULT;
|
|
||||||
goto free_mod;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Userspace could have altered the string after the strlen_user() */
|
|
||||||
args[arglen - 1] = '\0';
|
|
||||||
|
|
||||||
if (find_module(mod->name)) {
|
if (find_module(mod->name)) {
|
||||||
err = -EEXIST;
|
err = -EEXIST;
|
||||||
|
|
Loading…
Reference in a new issue