]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
usbnet: ipheth: fix DPE OoB read
authorFoster Snowhill <forst@pen.gy>
Sat, 25 Jan 2025 23:54:08 +0000 (00:54 +0100)
committerPaolo Abeni <pabeni@redhat.com>
Tue, 28 Jan 2025 11:16:32 +0000 (12:16 +0100)
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: a2d274c62e44 ("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>
drivers/net/usb/ipheth.c

index 03249208612e712e3c67310cb225de3b977487ec..5347cd7e295b3362216ad917a5956db6d9d6ffc6 100644 (file)
@@ -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);
 
@@ -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: