diff options
author | Davi Arnaut <davi.arnaut@gmail.com> | 2006-03-24 03:18:43 -0800 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2006-03-24 07:33:31 -0800 |
commit | 24277dda3a54aa5e6265487e1a3091e27f3c0c45 (patch) | |
tree | 8fdfcb8c522fff6ce6f82d0b06346b89a825d639 /kernel | |
parent | 96840aa00a031069a136ec4c55d0bdd09ac6d3a7 (diff) |
[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>
Diffstat (limited to 'kernel')
-rw-r--r-- | kernel/module.c | 19 |
1 files changed, 3 insertions, 16 deletions
diff --git a/kernel/module.c b/kernel/module.c index fb404299082..54623c714bb 100644 --- a/kernel/module.c +++ b/kernel/module.c @@ -1572,7 +1572,6 @@ static struct module *load_module(void __user *umod, exportindex, modindex, obsparmindex, infoindex, gplindex, crcindex, gplcrcindex, versindex, pcpuindex, gplfutureindex, gplfuturecrcindex; - long arglen; struct module *mod; long err = 0; 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 */ - arglen = strlen_user(uargs); - if (!arglen) { - err = -EFAULT; - goto free_hdr; - } - args = kmalloc(arglen, GFP_KERNEL); - if (!args) { - err = -ENOMEM; + args = strndup_user(uargs, ~0UL >> 1); + if (IS_ERR(args)) { + err = PTR_ERR(args); 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)) { err = -EEXIST; |