Commit 2b79fa8f authored by Kees Cook's avatar Kees Cook Committed by Ben Hutchings

tg3: fix length overflow in VPD firmware parsing

commit 715230a4 upstream.

Commit 184b8904 ("tg3: Use VPD fw version
when present") introduced VPD parsing that contained a potential length
overflow.

Limit the hardware's reported firmware string length (max 255 bytes) to
stay inside the driver's firmware string length (32 bytes). On overflow,
truncate the formatted firmware string instead of potentially overwriting
portions of the tg3 struct.

http://cansecwest.com/slides/2013/PrivateCore%20CSW%202013.pdfSigned-off-by: default avatarKees Cook <keescook@chromium.org>
Reported-by: default avatarOded Horovitz <oded@privatecore.com>
Reported-by: default avatarBrad Spengler <spender@grsecurity.net>
Cc: Matt Carlson <mcarlson@broadcom.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
parent 18698bd2
...@@ -13433,8 +13433,11 @@ static void __devinit tg3_read_vpd(struct tg3 *tp) ...@@ -13433,8 +13433,11 @@ static void __devinit tg3_read_vpd(struct tg3 *tp)
if (j + len > block_end) if (j + len > block_end)
goto partno; goto partno;
memcpy(tp->fw_ver, &vpd_data[j], len); if (len >= sizeof(tp->fw_ver))
strncat(tp->fw_ver, " bc ", vpdlen - len - 1); len = sizeof(tp->fw_ver) - 1;
memset(tp->fw_ver, 0, sizeof(tp->fw_ver));
snprintf(tp->fw_ver, sizeof(tp->fw_ver), "%.*s bc ", len,
&vpd_data[j]);
} }
partno: partno:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment