From: Dan Carpenter <dan.carpenter@oracle.com>
To: Rusty Russell <rusty@rustcorp.com.au>
Cc: linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org
Subject: [patch] module: static checker complains about negative values
Date: Mon, 19 May 2014 23:36:26 +0300 [thread overview]
Message-ID: <20140519203626.GC5671@mwanda> (raw)
We cap "stat.size" at INT_MAX but we don't check for negative values so
my static checker complains. At this point, you already have control of
the kernel and if you start passing negative values here then you
deserve what happens next.
On 64 bit systems the vmalloc() will definitely fail. On 32 bit systems
we truncate the upper 32 bits away so that could succeed. I haven't
followed it further than that.
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
diff --git a/kernel/module.c b/kernel/module.c
index 626d164..26e0d15 100644
--- a/kernel/module.c
+++ b/kernel/module.c
@@ -2536,7 +2536,7 @@ static int copy_module_from_fd(int fd, struct load_info *info)
}
/* Don't hand 0 to vmalloc, it whines. */
- if (stat.size == 0) {
+ if (stat.size <= 0) {
err = -EINVAL;
goto out;
}
next reply other threads:[~2014-05-19 20:36 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-05-19 20:36 Dan Carpenter [this message]
2014-05-20 1:46 ` [patch] module: static checker complains about negative values Rusty Russell
2014-05-20 8:19 ` Dan Carpenter
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=20140519203626.GC5671@mwanda \
--to=dan.carpenter@oracle.com \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=rusty@rustcorp.com.au \
/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