Skip to content

Commit

Permalink
usbnet: ipheth: fix DPE OoB read
Browse files Browse the repository at this point in the history
Fix an out-of-bounds DPE read, limit the number of processed DPEs to
the amount that fits into the fixed-size NDP16 header.

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>
  • Loading branch information
Foster Snowhill authored and Paolo Abeni committed Jan 28, 2025
1 parent efcbc67 commit ee591f2
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions drivers/net/usb/ipheth.c
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ static int ipheth_rcvbulk_callback_ncm(struct urb *urb)
goto rx_error;

dpe = ncm0->dpe16;
while (true) {
for (int dpe_i = 0; dpe_i < IPHETH_NDP16_MAX_DPE; ++dpe_i, ++dpe) {
dg_idx = le16_to_cpu(dpe->wDatagramIndex);
dg_len = le16_to_cpu(dpe->wDatagramLength);

Expand All @@ -268,8 +268,6 @@ static int ipheth_rcvbulk_callback_ncm(struct urb *urb)
retval = ipheth_consume_skb(buf, dg_len, dev);
if (retval != 0)
return retval;

dpe++;
}

rx_error:
Expand Down

0 comments on commit ee591f2

Please sign in to comment.