mirror of
https://github.com/torvalds/linux.git
synced 2026-06-06 21:45:45 +02:00
CDC-NCM: avoid overflow in sanity checking
commit 8d2b1a1ec9 upstream.
A broken device may give an extreme offset like 0xFFF0
and a reasonable length for a fragment. In the sanity
check as formulated now, this will create an integer
overflow, defeating the sanity check. Both offset
and offset + len need to be checked in such a manner
that no overflow can occur.
And those quantities should be unsigned.
Signed-off-by: Oliver Neukum <oneukum@suse.com>
Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
2aeba1ea7c
commit
69560efa00
|
|
@ -1702,10 +1702,10 @@ int cdc_ncm_rx_fixup(struct usbnet *dev, struct sk_buff *skb_in)
|
||||||
{
|
{
|
||||||
struct sk_buff *skb;
|
struct sk_buff *skb;
|
||||||
struct cdc_ncm_ctx *ctx = (struct cdc_ncm_ctx *)dev->data[0];
|
struct cdc_ncm_ctx *ctx = (struct cdc_ncm_ctx *)dev->data[0];
|
||||||
int len;
|
unsigned int len;
|
||||||
int nframes;
|
int nframes;
|
||||||
int x;
|
int x;
|
||||||
int offset;
|
unsigned int offset;
|
||||||
union {
|
union {
|
||||||
struct usb_cdc_ncm_ndp16 *ndp16;
|
struct usb_cdc_ncm_ndp16 *ndp16;
|
||||||
struct usb_cdc_ncm_ndp32 *ndp32;
|
struct usb_cdc_ncm_ndp32 *ndp32;
|
||||||
|
|
@ -1777,8 +1777,8 @@ int cdc_ncm_rx_fixup(struct usbnet *dev, struct sk_buff *skb_in)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* sanity checking */
|
/* sanity checking - watch out for integer wrap*/
|
||||||
if (((offset + len) > skb_in->len) ||
|
if ((offset > skb_in->len) || (len > skb_in->len - offset) ||
|
||||||
(len > ctx->rx_max) || (len < ETH_HLEN)) {
|
(len > ctx->rx_max) || (len < ETH_HLEN)) {
|
||||||
netif_dbg(dev, rx_err, dev->net,
|
netif_dbg(dev, rx_err, dev->net,
|
||||||
"invalid frame detected (ignored) offset[%u]=%u, length=%u, skb=%p\n",
|
"invalid frame detected (ignored) offset[%u]=%u, length=%u, skb=%p\n",
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user