From: Rusty Russell <rusty@rustcorp.com.au>
To: torvalds@transmeta.com
Cc: linux-kernel@vger.kernel.org, ak@suse.de
Subject: [PATCH] Fix strlen_user usage in module.c
Date: Mon, 13 Jan 2003 14:42:57 +1100 [thread overview]
Message-ID: <20030113034530.F1ED92C069@lists.samba.org> (raw)
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.
reply other threads:[~2003-01-13 3:36 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20030113034530.F1ED92C069@lists.samba.org \
--to=rusty@rustcorp.com.au \
--cc=ak@suse.de \
--cc=linux-kernel@vger.kernel.org \
--cc=torvalds@transmeta.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox