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