From: Greg KH <gregkh@suse.de>
To: linux-kernel@vger.kernel.org, stable@kernel.org
Cc: stable-review@kernel.org, torvalds@linux-foundation.org,
akpm@linux-foundation.org, alan@lxorguk.ukuu.org.uk,
Michael Buesch <mb@bu3sch.de>,
"John W. Linville" <linville@tuxdriver.com>
Subject: [07/18] ssb: Fix range check in sprom write
Date: Wed, 16 Dec 2009 16:45:58 -0800 [thread overview]
Message-ID: <20091217004707.899625984@mini.kroah.org> (raw)
In-Reply-To: <20091217005306.GA6230@kroah.com>
2.6.27-stable review patch. If anyone has any objections, please let us know.
------------------
From: Michael Buesch <mb@bu3sch.de>
commit e33761e6f23881de9f3ee77cc2204ab2e26f3d9a upstream.
The range check in the sprom image parser hex2sprom() is broken.
One sprom word is 4 hex characters.
This fixes the check and also adds much better sanity checks to the code.
We better make sure the image is OK by doing some sanity checks to avoid
bricking the device by accident.
Signed-off-by: Michael Buesch <mb@bu3sch.de>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
---
drivers/ssb/sprom.c | 20 ++++++++++++++++----
1 file changed, 16 insertions(+), 4 deletions(-)
--- a/drivers/ssb/sprom.c
+++ b/drivers/ssb/sprom.c
@@ -13,6 +13,8 @@
#include "ssb_private.h"
+#include <linux/ctype.h>
+
static int sprom2hex(const u16 *sprom, char *buf, size_t buf_len,
size_t sprom_size_words)
@@ -30,17 +32,27 @@ static int sprom2hex(const u16 *sprom, c
static int hex2sprom(u16 *sprom, const char *dump, size_t len,
size_t sprom_size_words)
{
- char tmp[5] = { 0 };
- int cnt = 0;
+ char c, tmp[5] = { 0 };
+ int err, cnt = 0;
unsigned long parsed;
- if (len < sprom_size_words * 2)
+ /* Strip whitespace at the end. */
+ while (len) {
+ c = dump[len - 1];
+ if (!isspace(c) && c != '\0')
+ break;
+ len--;
+ }
+ /* Length must match exactly. */
+ if (len != sprom_size_words * 4)
return -EINVAL;
while (cnt < sprom_size_words) {
memcpy(tmp, dump, 4);
dump += 4;
- parsed = simple_strtoul(tmp, NULL, 16);
+ err = strict_strtoul(tmp, 16, &parsed);
+ if (err)
+ return err;
sprom[cnt++] = swab16((u16)parsed);
}
next prev parent reply other threads:[~2009-12-17 0:57 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-12-17 0:53 [00/18] 2.6.27.42-stable review Greg KH
2009-12-17 0:45 ` [01/18] signal: Fix alternate signal stack check Greg KH
2009-12-17 0:45 ` [02/18] debugfs: fix create mutex racy fops and private data Greg KH
2009-12-17 0:45 ` [03/18] firewire: ohci: handle receive packets with a data length of zero Greg KH
2009-12-17 0:45 ` [04/18] fuse: reject O_DIRECT flag also in fuse_create Greg KH
2009-12-17 1:36 ` David Daney
2009-12-17 4:15 ` Greg KH
2009-12-17 0:45 ` [05/18] hfs: fix a potential buffer overflow Greg KH
2009-12-17 0:45 ` [06/18] pata_hpt{37x|3x2n}: fix timing register masks (take 2) Greg KH
2009-12-17 0:45 ` Greg KH [this message]
2009-12-17 0:45 ` [08/18] V4L/DVB: Fix test in copy_reg_bits() Greg KH
2009-12-17 0:46 ` [09/18] x86, apic: Enable lapic nmi watchdog on AMD Family 11h Greg KH
2009-12-17 0:46 ` [10/18] x86: ASUS P4S800 reboot=bios quirk Greg KH
2009-12-17 0:46 ` [11/18] x86, Calgary IOMMU quirk: Find nearest matching Calgary while walking up the PCI tree Greg KH
2009-12-17 0:46 ` [12/18] x86: Fix iommu=nodac parameter handling Greg KH
2009-12-17 0:46 ` [13/18] x86: GART: pci-gart_64.c: Use correct length in strncmp Greg KH
2009-12-17 0:46 ` [14/18] [IA64] fix csum_ipv6_magic() Greg KH
2009-12-17 0:46 ` [15/18] USB: fix mos7840 problem with minor numbers Greg KH
2009-12-17 0:46 ` [16/18] backlight: lcd - Fix wrong sizeof Greg KH
2009-12-17 0:46 ` [17/18] jffs2: Fix long-standing bug with symlink garbage collection Greg KH
2009-12-17 0:46 ` [18/18] matroxfb: fix problems with display stability Greg KH
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=20091217004707.899625984@mini.kroah.org \
--to=gregkh@suse.de \
--cc=akpm@linux-foundation.org \
--cc=alan@lxorguk.ukuu.org.uk \
--cc=linux-kernel@vger.kernel.org \
--cc=linville@tuxdriver.com \
--cc=mb@bu3sch.de \
--cc=stable-review@kernel.org \
--cc=stable@kernel.org \
--cc=torvalds@linux-foundation.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
all inboxes | Powered by JetHome®