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, ...@@ -1096,17 +1096,17 @@ static struct module *load_module(void *umod,
mod = (void *)sechdrs[modindex].sh_addr; mod = (void *)sechdrs[modindex].sh_addr;
/* Now copy in args */ /* Now copy in args */
err = strlen_user(uargs); arglen = strlen_user(uargs);
if (err < 0) if (!arglen) {
err = -EFAULT;
goto free_hdr; goto free_hdr;
arglen = err; }
args = kmalloc(arglen, GFP_KERNEL);
args = kmalloc(arglen+1, GFP_KERNEL);
if (!args) { if (!args) {
err = -ENOMEM; err = -ENOMEM;
goto free_hdr; goto free_hdr;
} }
if (copy_from_user(args, uargs, arglen+1) != 0) { if (copy_from_user(args, uargs, arglen) != 0) {
err = -EFAULT; err = -EFAULT;
goto free_mod; 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