From: Steve Glendinning <steve.glendinning@shawell.net>
To: netdev@vger.kernel.org
Cc: Steve Glendinning <steve.glendinning@shawell.net>,
Bjorn Mork <bjorn@mork.no>, Joe Perches <joe@perches.com>
Subject: [PATCH 1/3] smsc95xx: fix suspend buffer overflow
Date: Wed, 28 Nov 2012 17:46:57 +0000 [thread overview]
Message-ID: <1354124819-29531-2-git-send-email-steve.glendinning@shawell.net> (raw)
In-Reply-To: <1354124819-29531-1-git-send-email-steve.glendinning@shawell.net>
This patch fixes a buffer overflow introduced by bbd9f9e, where
the filter_mask array is accessed beyond its bounds.
Updated to also add a check for kzalloc failure, as reported by
Bjorn Mork and Joe Perches.
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Steve Glendinning <steve.glendinning@shawell.net>
Cc: Bjorn Mork <bjorn@mork.no>
Cc: Joe Perches <joe@perches.com>
---
drivers/net/usb/smsc95xx.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/drivers/net/usb/smsc95xx.c b/drivers/net/usb/smsc95xx.c
index 79d495d..c397b3a 100644
--- a/drivers/net/usb/smsc95xx.c
+++ b/drivers/net/usb/smsc95xx.c
@@ -1281,7 +1281,7 @@ static int smsc95xx_suspend(struct usb_interface *intf, pm_message_t message)
}
if (pdata->wolopts & (WAKE_BCAST | WAKE_MCAST | WAKE_ARP | WAKE_UCAST)) {
- u32 *filter_mask = kzalloc(32, GFP_KERNEL);
+ u32 *filter_mask = kzalloc(sizeof(u32) * 32, GFP_KERNEL);
u32 command[2];
u32 offset[2];
u32 crc[4];
@@ -1290,6 +1290,11 @@ static int smsc95xx_suspend(struct usb_interface *intf, pm_message_t message)
LAN9500A_WUFF_NUM : LAN9500_WUFF_NUM;
int i, filter = 0;
+ if (!filter_mask) {
+ netdev_warn(dev->net, "Unable to allocate filter_mask\n");
+ return -ENOMEM;
+ }
+
memset(command, 0, sizeof(command));
memset(offset, 0, sizeof(offset));
memset(crc, 0, sizeof(crc));
--
1.7.10.4
next prev parent reply other threads:[~2012-11-28 17:47 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-11-28 17:46 [PATCH 0/3] smsc95xx enhancements Steve Glendinning
2012-11-28 17:46 ` Steve Glendinning [this message]
2012-11-28 17:46 ` [PATCH 2/3] smsc95xx: fix error handling in suspend failure case Steve Glendinning
2012-11-29 2:04 ` David Miller
2012-11-28 17:46 ` [PATCH 3/3] smsc95xx: don't enable remote wakeup directly Steve Glendinning
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=1354124819-29531-2-git-send-email-steve.glendinning@shawell.net \
--to=steve.glendinning@shawell.net \
--cc=bjorn@mork.no \
--cc=joe@perches.com \
--cc=netdev@vger.kernel.org \
/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).