From: Foster Snowhill <forst@xxxxxx> commit c219427ed296f94bb4b91d08626776dc7719ee27 upstream. Originally, it was possible for the DPE length check to overflow if wDatagramIndex + wDatagramLength > U16_MAX. This could lead to an OoB read. Move the wDatagramIndex term to the other side of the inequality. An existing condition ensures that wDatagramIndex < urb->actual_length. Fixes: a2d274c62e44 ("usbnet: ipheth: add CDC NCM support") Cc: stable@xxxxxxxxxxxxxxx Signed-off-by: Foster Snowhill <forst@xxxxxx> Reviewed-by: Jakub Kicinski <kuba@xxxxxxxxxx> Signed-off-by: Paolo Abeni <pabeni@xxxxxxxxxx> Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> --- drivers/net/usb/ipheth.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/usb/ipheth.c b/drivers/net/usb/ipheth.c index 46afb95ffabe..45daae234cb8 100644 --- a/drivers/net/usb/ipheth.c +++ b/drivers/net/usb/ipheth.c @@ -243,8 +243,8 @@ static int ipheth_rcvbulk_callback_ncm(struct urb *urb) while (le16_to_cpu(dpe->wDatagramIndex) != 0 && le16_to_cpu(dpe->wDatagramLength) != 0) { if (le16_to_cpu(dpe->wDatagramIndex) >= urb->actual_length || - le16_to_cpu(dpe->wDatagramIndex) + - le16_to_cpu(dpe->wDatagramLength) > urb->actual_length) { + le16_to_cpu(dpe->wDatagramLength) > urb->actual_length - + le16_to_cpu(dpe->wDatagramIndex)) { dev->net->stats.rx_length_errors++; return retval; } -- 2.48.1 Patches currently in stable-queue which might be from forst@xxxxxx are queue-6.6/usbnet-ipheth-use-static-ndp16-location-in-urb.patch queue-6.6/usbnet-ipheth-check-that-dpe-points-past-ncm-header.patch queue-6.6/usbnet-ipheth-fix-dpe-oob-read.patch queue-6.6/usbnet-ipheth-document-scope-of-ncm-implementation.patch queue-6.6/usbnet-ipheth-fix-possible-overflow-in-dpe-length-check.patch queue-6.6/usbnet-ipheth-refactor-ncm-datagram-loop.patch queue-6.6/usbnet-ipheth-break-up-ncm-header-size-computation.patch