Skip to content

Commit c219427

Browse files
ForstPaolo Abeni
authored andcommitted
usbnet: ipheth: fix possible overflow in DPE length check
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: a2d274c ("usbnet: ipheth: add CDC NCM support") Cc: stable@vger.kernel.org Signed-off-by: Foster Snowhill <forst@pen.gy> Reviewed-by: Jakub Kicinski <kuba@kernel.org> Signed-off-by: Paolo Abeni <pabeni@redhat.com>
1 parent 19ae40f commit c219427

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

drivers/net/usb/ipheth.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -243,8 +243,8 @@ static int ipheth_rcvbulk_callback_ncm(struct urb *urb)
243243
while (le16_to_cpu(dpe->wDatagramIndex) != 0 &&
244244
le16_to_cpu(dpe->wDatagramLength) != 0) {
245245
if (le16_to_cpu(dpe->wDatagramIndex) >= urb->actual_length ||
246-
le16_to_cpu(dpe->wDatagramIndex) +
247-
le16_to_cpu(dpe->wDatagramLength) > urb->actual_length) {
246+
le16_to_cpu(dpe->wDatagramLength) > urb->actual_length -
247+
le16_to_cpu(dpe->wDatagramIndex)) {
248248
dev->net->stats.rx_length_errors++;
249249
return retval;
250250
}

0 commit comments

Comments
 (0)