lkml.org 
[lkml]   [2003]   [Jan]   [12]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH] Fix strlen_user usage in module.c
Date
Spotted by Andi Kleen.  strlen_user *is* documented, I just made
assumptions.

Name: Fix strlen_user usage
Author: Rusty Russell
Status: Trivial

D: strlen_user returns 0 on error, not an error number, and otherwise
D: returns the length including the NUL byte. Found by Andi Kleen.

diff -urpN --exclude TAGS -X /home/rusty/devel/kernel/kernel-patches/current-dontdiff --minimal .22129-linux-2.5.55/kernel/module.c .22129-linux-2.5.55.updated/kernel/module.c
--- .22129-linux-2.5.55/kernel/module.c 2003-01-10 10:55:43.000000000 +1100
+++ .22129-linux-2.5.55.updated/kernel/module.c 2003-01-10 20:55:55.000000000 +1100
@@ -1096,17 +1096,17 @@ static struct module *load_module(void *
mod = (void *)sechdrs[modindex].sh_addr;

/* Now copy in args */
- err = strlen_user(uargs);
- if (err < 0)
+ arglen = strlen_user(uargs);
+ if (!arglen) {
+ err = -EFAULT;
goto free_hdr;
- arglen = err;
-
- args = kmalloc(arglen+1, GFP_KERNEL);
+ }
+ args = kmalloc(arglen, GFP_KERNEL);
if (!args) {
err = -ENOMEM;
goto free_hdr;
}
- if (copy_from_user(args, uargs, arglen+1) != 0) {
+ if (copy_from_user(args, uargs, arglen) != 0) {
err = -EFAULT;
goto free_mod;
}
--
Anyone who quotes me in their sig is an idiot. -- Rusty Russell.
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
\
 
 \ /
  Last update: 2005-03-22 13:32    [W:0.017 / U:0.540 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site