public inbox for kernel-janitors@vger.kernel.org
 help / color / mirror / Atom feed
* [RESEND PATCH v2] staging/wlan-ng: Fix potential buffer overflow in firmware handling
@ 2015-10-10 19:56 Tillmann Heidsieck
  2015-10-12 11:14 ` Sudip Mukherjee
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Tillmann Heidsieck @ 2015-10-10 19:56 UTC (permalink / raw)
  To: kernel-janitors

This patch fixes a potential buffer overflow detected by smatch.

pda16 has length 512, while processing an element with index < 512 we
are checking for an end marker in the next element. This poses a
potential buffer overflow if no end marker is present.

Signed-off-by: Tillmann Heidsieck <theidsieck@leenox.de>
---
v2: add missing Signed-off-by line


 drivers/staging/wlan-ng/prism2fw.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/wlan-ng/prism2fw.c b/drivers/staging/wlan-ng/prism2fw.c
index fe36613..d357b7e 100644
--- a/drivers/staging/wlan-ng/prism2fw.c
+++ b/drivers/staging/wlan-ng/prism2fw.c
@@ -590,7 +590,7 @@ static int mkpdrlist(struct pda *pda)
 
 	pda->nrec = 0;
 	curroff = 0;
-	while (curroff < (HFA384x_PDA_LEN_MAX / 2) &&
+	while (curroff < (HFA384x_PDA_LEN_MAX / 2 - 1) &&
 	       le16_to_cpu(pda16[curroff + 1]) != HFA384x_PDR_END_OF_PDA) {
 		pda->rec[pda->nrec] = (hfa384x_pdrec_t *) &(pda16[curroff]);
 
@@ -626,7 +626,7 @@ static int mkpdrlist(struct pda *pda)
 		curroff += le16_to_cpu(pda16[curroff]) + 1;
 
 	}
-	if (curroff >= (HFA384x_PDA_LEN_MAX / 2)) {
+	if (curroff >= (HFA384x_PDA_LEN_MAX / 2 - 1)) {
 		pr_err("no end record found or invalid lengths in PDR data, exiting. %x %d\n",
 		       curroff, pda->nrec);
 		return 1;
-- 
2.6.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2015-10-13 12:58 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-10-10 19:56 [RESEND PATCH v2] staging/wlan-ng: Fix potential buffer overflow in firmware handling Tillmann Heidsieck
2015-10-12 11:14 ` Sudip Mukherjee
2015-10-12 11:35 ` Tillmann Heidsieck
2015-10-12 11:53 ` Sudip Mukherjee
2015-10-13 12:58 ` Tillmann Heidsieck

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox