From: Dan Carpenter <dan.carpenter@oracle.com>
To: Rasesh Mody <rasesh.mody@cavium.com>,
Krishna Gudipati <kgudipat@brocade.com>
Cc: Sudarsana Kalluru <sudarsana.kalluru@cavium.com>,
Dept-GELinuxNICDev@cavium.com, netdev@vger.kernel.org,
kernel-janitors@vger.kernel.org
Subject: [PATCH] bna: integer overflow bug in debugfs
Date: Fri, 17 Mar 2017 23:52:35 +0300 [thread overview]
Message-ID: <20170317205234.GA2888@mwanda> (raw)
We could allocate less memory than intended because we do:
bnad->regdata = kzalloc(len << 2, GFP_KERNEL);
The shift can overflow leading to a crash. This is debugfs code so the
impact is very small.
Fixes: 7afc5dbde091 ("bna: Add debugfs interface.")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
diff --git a/drivers/net/ethernet/brocade/bna/bnad_debugfs.c b/drivers/net/ethernet/brocade/bna/bnad_debugfs.c
index 05c1c1dd7751..cebfe3bd086e 100644
--- a/drivers/net/ethernet/brocade/bna/bnad_debugfs.c
+++ b/drivers/net/ethernet/brocade/bna/bnad_debugfs.c
@@ -325,7 +325,7 @@ bnad_debugfs_write_regrd(struct file *file, const char __user *buf,
return PTR_ERR(kern_buf);
rc = sscanf(kern_buf, "%x:%x", &addr, &len);
- if (rc < 2) {
+ if (rc < 2 || len > UINT_MAX >> 2) {
netdev_warn(bnad->netdev, "failed to read user buffer\n");
kfree(kern_buf);
return -EINVAL;
next reply other threads:[~2017-03-17 20:52 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-03-17 20:52 Dan Carpenter [this message]
2017-03-21 1:14 ` [PATCH] bna: integer overflow bug in debugfs Mody, Rasesh
2017-03-22 0:43 ` David Miller
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=20170317205234.GA2888@mwanda \
--to=dan.carpenter@oracle.com \
--cc=Dept-GELinuxNICDev@cavium.com \
--cc=kernel-janitors@vger.kernel.org \
--cc=kgudipat@brocade.com \
--cc=netdev@vger.kernel.org \
--cc=rasesh.mody@cavium.com \
--cc=sudarsana.kalluru@cavium.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;
as well as URLs for NNTP newsgroup(s).