mirror of
https://github.com/torvalds/linux.git
synced 2026-10-15 04:13:02 +02:00
net: usb: catc: bound the RX packet length in catc_rx_done()
catc_rx_done() walks a multi-packet URB, reading a two-byte length from
each packet header. Its bound, pkt_len > urb->actual_length, ignores the
header offset and compares against the whole transfer rather than the
bytes left from pkt_start, so a crafted packet header makes
skb_copy_to_linear_data() read past the buffer.
A length below ETH_HLEN is also accepted, including zero, and
eth_type_trans() then reads a MAC header from the uninitialised tailroom
of a shorter skb. The is_f5u011 branch takes its length straight from
the transfer, so a zero-length URB reaches the same path.
Track the bytes remaining from the current packet, and reject a header
that does not fit, a length past what is left, and a length below an
Ethernet header.
A transfer shorter than an Ethernet header, including a zero-length one,
previously became a runt skb passed to netif_rx() and counted as
received; it is now counted in rx_length_errors and ends the walk.
Fixes: 1da177e4c3 ("Linux-2.6.12-rc2")
Signed-off-by: Aamir Ahmed <elb12345@hotmail.co.uk>
Reviewed-by: Simon Horman <horms@kernel.org>
Link: https://patch.msgid.link/AS8P251MB00015FD7716F38C345619B56C8BB2@AS8P251MB0001.EURP251.PROD.OUTLOOK.COM
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
parent
c82b797abe
commit
9d565b6b72
|
|
@ -233,17 +233,26 @@ static void catc_rx_done(struct urb *urb)
|
|||
}
|
||||
|
||||
do {
|
||||
if(!catc->is_f5u011) {
|
||||
pkt_len = le16_to_cpup((__le16*)pkt_start);
|
||||
if (pkt_len > urb->actual_length) {
|
||||
int remaining = urb->actual_length -
|
||||
(pkt_start - (u8 *)urb->transfer_buffer);
|
||||
|
||||
if (!catc->is_f5u011) {
|
||||
if (remaining < pkt_offset) {
|
||||
catc->netdev->stats.rx_length_errors++;
|
||||
catc->netdev->stats.rx_errors++;
|
||||
break;
|
||||
}
|
||||
pkt_len = le16_to_cpup((__le16 *)pkt_start);
|
||||
} else {
|
||||
pkt_len = urb->actual_length;
|
||||
}
|
||||
|
||||
if (pkt_len < ETH_HLEN || pkt_len + pkt_offset > remaining) {
|
||||
catc->netdev->stats.rx_length_errors++;
|
||||
catc->netdev->stats.rx_errors++;
|
||||
break;
|
||||
}
|
||||
|
||||
if (!(skb = dev_alloc_skb(pkt_len)))
|
||||
return;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user