aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/module.c
diff options
context:
space:
mode:
authorDavi Arnaut <davi.arnaut@gmail.com>2006-03-24 06:18:43 -0500
committerLinus Torvalds <torvalds@g5.osdl.org>2006-03-24 10:33:31 -0500
commit24277dda3a54aa5e6265487e1a3091e27f3c0c45 (patch)
tree8fdfcb8c522fff6ce6f82d0b06346b89a825d639 /kernel/module.c
parent96840aa00a031069a136ec4c55d0bdd09ac6d3a7 (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/module.c')
-rw-r--r--kernel/module.c19
1 files changed, 3 insertions, 16 deletions
diff --git a/kernel/module.c b/kernel/module.c
index fb404299082e..54623c714bba 100644
--- a/kernel/module.c
+++ b/kernel/module.c
@@ -1572,7 +1572,6 @@ static struct module *load_module(void __user *umod,
1572 exportindex, modindex, obsparmindex, infoindex, gplindex, 1572 exportindex, modindex, obsparmindex, infoindex, gplindex,
1573 crcindex, gplcrcindex, versindex, pcpuindex, gplfutureindex, 1573 crcindex, gplcrcindex, versindex, pcpuindex, gplfutureindex,
1574 gplfuturecrcindex; 1574 gplfuturecrcindex;
1575 long arglen;
1576 struct module *mod; 1575 struct module *mod;
1577 long err = 0; 1576 long err = 0;
1578 void *percpu = NULL, *ptr = NULL; /* Stops spurious gcc warning */ 1577 void *percpu = NULL, *ptr = NULL; /* Stops spurious gcc warning */
@@ -1691,23 +1690,11 @@ static struct module *load_module(void __user *umod,
1691 } 1690 }
1692 1691
1693 /* Now copy in args */ 1692 /* Now copy in args */
1694 arglen = strlen_user(uargs); 1693 args = strndup_user(uargs, ~0UL >> 1);
1695 if (!arglen) { 1694 if (IS_ERR(args)) {
1696 err = -EFAULT; 1695 err = PTR_ERR(args);
1697 goto free_hdr;
1698 }
1699 args = kmalloc(arglen, GFP_KERNEL);
1700 if (!args) {
1701 err = -ENOMEM;
1702 goto free_hdr; 1696 goto free_hdr;
1703 } 1697 }
1704 if (copy_from_user(args, uargs, arglen) != 0) {
1705 err = -EFAULT;
1706 goto free_mod;
1707 }
1708
1709 /* Userspace could have altered the string after the strlen_user() */
1710 args[arglen - 1] = '\0';
1711 1698
1712 if (find_module(mod->name)) { 1699 if (find_module(mod->name)) {
1713 err = -EEXIST; 1700 err = -EEXIST;