Commit d6ad9cca authored by Rusty Russell's avatar Rusty Russell Committed by Kai Germaschewski

[PATCH] Fix strlen_user usage in module.c

strlen_user returns 0 on error, not an error number, and otherwise
returns the length including the NUL byte.  Found by Andi Kleen.
parent f7434ef4
......@@ -1096,17 +1096,17 @@ static struct module *load_module(void *umod,
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;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment