skge: potential memory corruption in skge_get_regs()
authorDan Carpenter <dan.carpenter@oracle.com>
Fri, 1 Feb 2019 08:28:16 +0000 (11:28 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 12 Feb 2019 18:47:22 +0000 (19:47 +0100)
commitc8ba1f7989c639358df5dcb2653b1958a4d30a41
tree1a8d153f74fd655550cef4f74e31760353e3645a
parent7c2361308e1727c3135ebb3b5c6906fb781bb261
skge: potential memory corruption in skge_get_regs()

[ Upstream commit 294c149a209c6196c2de85f512b52ef50f519949 ]

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: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/net/ethernet/marvell/skge.c