|
Kmods SIG |
5c37b1 |
From 294c149a209c6196c2de85f512b52ef50f519949 Mon Sep 17 00:00:00 2001
|
|
Kmods SIG |
5c37b1 |
From: Dan Carpenter <dan.carpenter@oracle.com>
|
|
Kmods SIG |
5c37b1 |
Date: Fri, 1 Feb 2019 11:28:16 +0300
|
|
Kmods SIG |
5c37b1 |
Subject: [Backport 294c149a209c] skge: potential memory corruption in
|
|
Kmods SIG |
5c37b1 |
skge_get_regs()
|
|
Kmods SIG |
5c37b1 |
|
|
Kmods SIG |
5c37b1 |
The "p" buffer is 0x4000 bytes long. B3_RI_WTO_R1 is 0x190. The value
|
|
Kmods SIG |
5c37b1 |
of "regs->len" is in the 1-0x4000 range. The bug here is that
|
|
Kmods SIG |
5c37b1 |
"regs->len - B3_RI_WTO_R1" can be a negative value which would lead to
|
|
Kmods SIG |
5c37b1 |
memory corruption and an abrupt crash.
|
|
Kmods SIG |
5c37b1 |
|
|
Kmods SIG |
5c37b1 |
Fixes: c3f8be961808 ("[PATCH] skge: expand ethtool debug register dump")
|
|
Kmods SIG |
5c37b1 |
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
|
|
Kmods SIG |
5c37b1 |
Signed-off-by: David S. Miller <davem@davemloft.net>
|
|
Kmods SIG |
5c37b1 |
---
|
|
Kmods SIG |
5c37b1 |
src/skge.c | 6 ++++--
|
|
Kmods SIG |
5c37b1 |
1 file changed, 4 insertions(+), 2 deletions(-)
|
|
Kmods SIG |
5c37b1 |
|
|
Kmods SIG |
5c37b1 |
diff --git a/src/skge.c b/src/skge.c
|
|
Kmods SIG |
5c37b1 |
index 04fd1f135011f1a068bbc79991af0d05a7c56583..654ac534b10e3e8e04911b618d5fd1cb6fb5c8c8 100644
|
|
Kmods SIG |
5c37b1 |
--- a/src/skge.c
|
|
Kmods SIG |
5c37b1 |
+++ b/src/skge.c
|
|
Kmods SIG |
5c37b1 |
@@ -152,8 +152,10 @@ static void skge_get_regs(struct net_device *dev, struct ethtool_regs *regs,
|
|
Kmods SIG |
5c37b1 |
memset(p, 0, regs->len);
|
|
Kmods SIG |
5c37b1 |
memcpy_fromio(p, io, B3_RAM_ADDR);
|
|
Kmods SIG |
5c37b1 |
|
|
Kmods SIG |
5c37b1 |
- memcpy_fromio(p + B3_RI_WTO_R1, io + B3_RI_WTO_R1,
|
|
Kmods SIG |
5c37b1 |
- regs->len - B3_RI_WTO_R1);
|
|
Kmods SIG |
5c37b1 |
+ if (regs->len > B3_RI_WTO_R1) {
|
|
Kmods SIG |
5c37b1 |
+ memcpy_fromio(p + B3_RI_WTO_R1, io + B3_RI_WTO_R1,
|
|
Kmods SIG |
5c37b1 |
+ regs->len - B3_RI_WTO_R1);
|
|
Kmods SIG |
5c37b1 |
+ }
|
|
Kmods SIG |
5c37b1 |
}
|
|
Kmods SIG |
5c37b1 |
|
|
Kmods SIG |
5c37b1 |
/* Wake on Lan only supported on Yukon chips with rev 1 or above */
|
|
Kmods SIG |
5c37b1 |
--
|
|
Kmods SIG |
5c37b1 |
2.31.1
|
|
Kmods SIG |
5c37b1 |
|