diff options
author | Dan Carpenter <dan.carpenter@oracle.com> | 2019-02-01 11:28:16 +0300 |
---|---|---|
committer | Ben Hutchings <ben@decadent.org.uk> | 2019-05-02 23:41:33 +0300 |
commit | df53da1c7c90d80f05bc85398867b1b518253cb8 (patch) | |
tree | 56bc5c2e4fe3ebbef4d2293a074116e8605d4095 /drivers | |
parent | b6706ab0540c4fbb5424cbaf7c0ce7c87f7a0ba7 (diff) | |
download | linux-df53da1c7c90d80f05bc85398867b1b518253cb8.tar.xz |
skge: potential memory corruption in skge_get_regs()
commit 294c149a209c6196c2de85f512b52ef50f519949 upstream.
The "p" buffer is 0x4000 bytes long. B3_RI_WTO_R1 is 0x190. The value
of "regs->len" is in the 1-0x4000 range. The bug here is that
"regs->len - B3_RI_WTO_R1" can be a negative value which would lead to
memory corruption and an abrupt crash.
Fixes: c3f8be961808 ("[PATCH] skge: expand ethtool debug register dump")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/net/ethernet/marvell/skge.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/drivers/net/ethernet/marvell/skge.c b/drivers/net/ethernet/marvell/skge.c index e912b6887d40..b23c3f684bde 100644 --- a/drivers/net/ethernet/marvell/skge.c +++ b/drivers/net/ethernet/marvell/skge.c @@ -152,8 +152,10 @@ static void skge_get_regs(struct net_device *dev, struct ethtool_regs *regs, memset(p, 0, regs->len); memcpy_fromio(p, io, B3_RAM_ADDR); - memcpy_fromio(p + B3_RI_WTO_R1, io + B3_RI_WTO_R1, - regs->len - B3_RI_WTO_R1); + if (regs->len > B3_RI_WTO_R1) { + memcpy_fromio(p + B3_RI_WTO_R1, io + B3_RI_WTO_R1, + regs->len - B3_RI_WTO_R1); + } } /* Wake on Lan only supported on Yukon chips with rev 1 or above */ |