|
|
93c8d4 |
From ad4757373f2ade3e1b238c8967d1b5bf80654820 Mon Sep 17 00:00:00 2001
|
|
|
93c8d4 |
From: Yannick Cote <ycote@redhat.com>
|
|
|
93c8d4 |
Date: Wed, 7 Dec 2022 14:07:55 -0500
|
|
|
93c8d4 |
Subject: [KPATCH CVE-2022-2964] kpatch fixes for CVE-2022-2964
|
|
|
93c8d4 |
|
|
|
93c8d4 |
Kernels:
|
|
|
93c8d4 |
3.10.0-1160.66.1.el7
|
|
|
93c8d4 |
3.10.0-1160.71.1.el7
|
|
|
93c8d4 |
3.10.0-1160.76.1.el7
|
|
|
93c8d4 |
3.10.0-1160.80.1.el7
|
|
|
93c8d4 |
|
|
|
93c8d4 |
|
|
|
93c8d4 |
Kpatch-MR: https://gitlab.com/redhat/prdsc/rhel/src/kpatch/rhel-7/-/merge_requests/47
|
|
|
93c8d4 |
Approved-by: Joe Lawrence (@joe.lawrence)
|
|
|
93c8d4 |
Changes since last build:
|
|
|
93c8d4 |
arches: x86_64 ppc64le
|
|
|
93c8d4 |
ax88179_178a.o: changed function: ax88179_rx_fixup
|
|
|
93c8d4 |
ax88179_178a.o: changed function: ax88179_tx_fixup
|
|
|
93c8d4 |
---------------------------
|
|
|
93c8d4 |
|
|
|
93c8d4 |
Modifications: none
|
|
|
93c8d4 |
|
|
|
93c8d4 |
commit 6887c693d5b263d458cdae235b5ca4cb36d79466
|
|
|
93c8d4 |
Author: Jose Ignacio Tornos Martinez <jtornosm@redhat.com>
|
|
|
93c8d4 |
Date: Thu Oct 6 18:32:21 2022 +0200
|
|
|
93c8d4 |
|
|
|
93c8d4 |
net: usb: ax88179_178a: fix packet alignment padding
|
|
|
93c8d4 |
|
|
|
93c8d4 |
Bugzilla: https://bugzilla.redhat.com/2120504
|
|
|
93c8d4 |
CVE: CVE-2022-2964
|
|
|
93c8d4 |
|
|
|
93c8d4 |
commit e869e7a17798d85829fa7d4f9bbe1eebd4b2d3f6
|
|
|
93c8d4 |
Author: Jeremy Kerr <jk@ozlabs.org>
|
|
|
93c8d4 |
Date: Mon Jun 15 10:54:56 2020 +0800
|
|
|
93c8d4 |
|
|
|
93c8d4 |
net: usb: ax88179_178a: fix packet alignment padding
|
|
|
93c8d4 |
|
|
|
93c8d4 |
Using a AX88179 device (0b95:1790), I see two bytes of appended data on
|
|
|
93c8d4 |
every RX packet. For example, this 48-byte ping, using 0xff as a
|
|
|
93c8d4 |
payload byte:
|
|
|
93c8d4 |
|
|
|
93c8d4 |
04:20:22.528472 IP 192.168.1.1 > 192.168.1.2: ICMP echo request, id 2447, seq 1, length 64
|
|
|
93c8d4 |
0x0000: 000a cd35 ea50 000a cd35 ea4f 0800 4500
|
|
|
93c8d4 |
0x0010: 0054 c116 4000 4001 f63e c0a8 0101 c0a8
|
|
|
93c8d4 |
0x0020: 0102 0800 b633 098f 0001 87ea cd5e 0000
|
|
|
93c8d4 |
0x0030: 0000 dcf2 0600 0000 0000 ffff ffff ffff
|
|
|
93c8d4 |
0x0040: ffff ffff ffff ffff ffff ffff ffff ffff
|
|
|
93c8d4 |
0x0050: ffff ffff ffff ffff ffff ffff ffff ffff
|
|
|
93c8d4 |
0x0060: ffff 961f
|
|
|
93c8d4 |
|
|
|
93c8d4 |
Those last two bytes - 96 1f - aren't part of the original packet.
|
|
|
93c8d4 |
|
|
|
93c8d4 |
In the ax88179 RX path, the usbnet rx_fixup function trims a 2-byte
|
|
|
93c8d4 |
'alignment pseudo header' from the start of the packet, and sets the
|
|
|
93c8d4 |
length from a per-packet field populated by hardware. It looks like that
|
|
|
93c8d4 |
length field *includes* the 2-byte header; the current driver assumes
|
|
|
93c8d4 |
that it's excluded.
|
|
|
93c8d4 |
|
|
|
93c8d4 |
This change trims the 2-byte alignment header after we've set the packet
|
|
|
93c8d4 |
length, so the resulting packet length is correct. While we're moving
|
|
|
93c8d4 |
the comment around, this also fixes the spelling of 'pseudo'.
|
|
|
93c8d4 |
|
|
|
93c8d4 |
Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
|
|
|
93c8d4 |
Signed-off-by: David S. Miller <davem@davemloft.net>
|
|
|
93c8d4 |
|
|
|
93c8d4 |
Signed-off-by: Jose Ignacio Tornos Martinez <jtornosm@redhat.com>
|
|
|
93c8d4 |
|
|
|
93c8d4 |
commit cb4cf1dd8820ba776a91ebf5b88ad1c3d83a0dfb
|
|
|
93c8d4 |
Author: Jose Ignacio Tornos Martinez <jtornosm@redhat.com>
|
|
|
93c8d4 |
Date: Thu Oct 6 18:32:21 2022 +0200
|
|
|
93c8d4 |
|
|
|
93c8d4 |
ax88179_178a: Merge memcpy + le32_to_cpus to get_unaligned_le32
|
|
|
93c8d4 |
|
|
|
93c8d4 |
Bugzilla: https://bugzilla.redhat.com/2120504
|
|
|
93c8d4 |
CVE: CVE-2022-2964
|
|
|
93c8d4 |
|
|
|
93c8d4 |
commit d1854d509d61d36af44f2130423bff8836e1592e
|
|
|
93c8d4 |
Author: Chuhong Yuan <hslester96@gmail.com>
|
|
|
93c8d4 |
Date: Fri Jul 19 17:07:15 2019 +0800
|
|
|
93c8d4 |
|
|
|
93c8d4 |
ax88179_178a: Merge memcpy + le32_to_cpus to get_unaligned_le32
|
|
|
93c8d4 |
|
|
|
93c8d4 |
Merge the combo use of memcpy and le32_to_cpus.
|
|
|
93c8d4 |
Use get_unaligned_le32 instead.
|
|
|
93c8d4 |
This simplifies the code.
|
|
|
93c8d4 |
|
|
|
93c8d4 |
Signed-off-by: Chuhong Yuan <hslester96@gmail.com>
|
|
|
93c8d4 |
Signed-off-by: David S. Miller <davem@davemloft.net>
|
|
|
93c8d4 |
|
|
|
93c8d4 |
Signed-off-by: Jose Ignacio Tornos Martinez <jtornosm@redhat.com>
|
|
|
93c8d4 |
|
|
|
93c8d4 |
commit 4e6ea26989123e731329323492d30f826aa28010
|
|
|
93c8d4 |
Author: Jose Ignacio Tornos Martinez <jtornosm@redhat.com>
|
|
|
93c8d4 |
Date: Thu Oct 6 18:32:21 2022 +0200
|
|
|
93c8d4 |
|
|
|
93c8d4 |
net: usb: Merge cpu_to_le32s + memcpy to put_unaligned_le32
|
|
|
93c8d4 |
|
|
|
93c8d4 |
Bugzilla: https://bugzilla.redhat.com/2120504
|
|
|
93c8d4 |
CVE: CVE-2022-2964
|
|
|
93c8d4 |
|
|
|
93c8d4 |
Conflicts:
|
|
|
93c8d4 |
Only ax88179 files
|
|
|
93c8d4 |
|
|
|
93c8d4 |
commit 7e24b4ed5ac4321e41415b0c6f0f8a8ac14852b2
|
|
|
93c8d4 |
Author: Chuhong Yuan <hslester96@gmail.com>
|
|
|
93c8d4 |
Date: Mon Jul 22 15:41:34 2019 +0800
|
|
|
93c8d4 |
|
|
|
93c8d4 |
net: usb: Merge cpu_to_le32s + memcpy to put_unaligned_le32
|
|
|
93c8d4 |
|
|
|
93c8d4 |
Merge the combo uses of cpu_to_le32s and memcpy.
|
|
|
93c8d4 |
Use put_unaligned_le32 instead.
|
|
|
93c8d4 |
This simplifies the code.
|
|
|
93c8d4 |
|
|
|
93c8d4 |
Signed-off-by: Chuhong Yuan <hslester96@gmail.com>
|
|
|
93c8d4 |
Signed-off-by: David S. Miller <davem@davemloft.net>
|
|
|
93c8d4 |
|
|
|
93c8d4 |
Signed-off-by: Jose Ignacio Tornos Martinez <jtornosm@redhat.com>
|
|
|
93c8d4 |
|
|
|
93c8d4 |
commit 7faaf2665dcbc3a4fdb31331de699045040ed213
|
|
|
93c8d4 |
Author: Jose Ignacio Tornos Martinez <jtornosm@redhat.com>
|
|
|
93c8d4 |
Date: Thu Oct 6 18:32:22 2022 +0200
|
|
|
93c8d4 |
|
|
|
93c8d4 |
net: usb: ax88179_178a: Fix out-of-bounds accesses in RX fixup
|
|
|
93c8d4 |
|
|
|
93c8d4 |
Bugzilla: https://bugzilla.redhat.com/2120504
|
|
|
93c8d4 |
CVE: CVE-2022-2964
|
|
|
93c8d4 |
|
|
|
93c8d4 |
commit 57bc3d3ae8c14df3ceb4e17d26ddf9eeab304581
|
|
|
93c8d4 |
Author: Jann Horn <jannh@google.com>
|
|
|
93c8d4 |
Date: Wed Jan 26 14:14:52 2022 +0100
|
|
|
93c8d4 |
|
|
|
93c8d4 |
net: usb: ax88179_178a: Fix out-of-bounds accesses in RX fixup
|
|
|
93c8d4 |
|
|
|
93c8d4 |
ax88179_rx_fixup() contains several out-of-bounds accesses that can be
|
|
|
93c8d4 |
triggered by a malicious (or defective) USB device, in particular:
|
|
|
93c8d4 |
|
|
|
93c8d4 |
- The metadata array (hdr_off..hdr_off+2*pkt_cnt) can be out of bounds,
|
|
|
93c8d4 |
causing OOB reads and (on big-endian systems) OOB endianness flips.
|
|
|
93c8d4 |
- A packet can overlap the metadata array, causing a later OOB
|
|
|
93c8d4 |
endianness flip to corrupt data used by a cloned SKB that has already
|
|
|
93c8d4 |
been handed off into the network stack.
|
|
|
93c8d4 |
- A packet SKB can be constructed whose tail is far beyond its end,
|
|
|
93c8d4 |
causing out-of-bounds heap data to be considered part of the SKB's
|
|
|
93c8d4 |
data.
|
|
|
93c8d4 |
|
|
|
93c8d4 |
I have tested that this can be used by a malicious USB device to send a
|
|
|
93c8d4 |
bogus ICMPv6 Echo Request and receive an ICMPv6 Echo Reply in response
|
|
|
93c8d4 |
that contains random kernel heap data.
|
|
|
93c8d4 |
It's probably also possible to get OOB writes from this on a
|
|
|
93c8d4 |
little-endian system somehow - maybe by triggering skb_cow() via IP
|
|
|
93c8d4 |
options processing -, but I haven't tested that.
|
|
|
93c8d4 |
|
|
|
93c8d4 |
Fixes: e2ca90c276e1 ("ax88179_178a: ASIX AX88179_178A USB 3.0/2.0 to gigabit ethernet adapter driver")
|
|
|
93c8d4 |
Cc: stable@kernel.org
|
|
|
93c8d4 |
Signed-off-by: Jann Horn <jannh@google.com>
|
|
|
93c8d4 |
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
|
|
|
93c8d4 |
|
|
|
93c8d4 |
Signed-off-by: Jose Ignacio Tornos Martinez <jtornosm@redhat.com>
|
|
|
93c8d4 |
|
|
|
93c8d4 |
commit 4e8b1e4091c6dce2911ffe8b9a8a7c58f8b028bc
|
|
|
93c8d4 |
Author: Jose Ignacio Tornos Martinez <jtornosm@redhat.com>
|
|
|
93c8d4 |
Date: Thu Nov 17 08:53:37 2022 +0100
|
|
|
93c8d4 |
|
|
|
93c8d4 |
net: usb: ax88179_178a: Fix packet receiving
|
|
|
93c8d4 |
|
|
|
93c8d4 |
Bugzilla: https://bugzilla.redhat.com/2120504
|
|
|
93c8d4 |
CVE: CVE-2022-2964
|
|
|
93c8d4 |
|
|
|
93c8d4 |
commit f8ebb3ac881b17712e1d5967c97ab1806b16d3d6
|
|
|
93c8d4 |
Author: Jose Alonso <joalonsof@gmail.com>
|
|
|
93c8d4 |
Date: Tue Jun 28 12:13:02 2022 -0300
|
|
|
93c8d4 |
|
|
|
93c8d4 |
net: usb: ax88179_178a: Fix packet receiving
|
|
|
93c8d4 |
|
|
|
93c8d4 |
This patch corrects packet receiving in ax88179_rx_fixup.
|
|
|
93c8d4 |
|
|
|
93c8d4 |
- problem observed:
|
|
|
93c8d4 |
ifconfig shows allways a lot of 'RX Errors' while packets
|
|
|
93c8d4 |
are received normally.
|
|
|
93c8d4 |
|
|
|
93c8d4 |
This occurs because ax88179_rx_fixup does not recognise properly
|
|
|
93c8d4 |
the usb urb received.
|
|
|
93c8d4 |
The packets are normally processed and at the end, the code exits
|
|
|
93c8d4 |
with 'return 0', generating RX Errors.
|
|
|
93c8d4 |
(pkt_cnt==-2 and ptk_hdr over field rx_hdr trying to identify
|
|
|
93c8d4 |
another packet there)
|
|
|
93c8d4 |
|
|
|
93c8d4 |
This is a usb urb received by "tcpdump -i usbmon2 -X" on a
|
|
|
93c8d4 |
little-endian CPU:
|
|
|
93c8d4 |
0x0000: eeee f8e3 3b19 87a0 94de 80e3 daac 0800
|
|
|
93c8d4 |
^ packet 1 start (pkt_len = 0x05ec)
|
|
|
93c8d4 |
^^^^ IP alignment pseudo header
|
|
|
93c8d4 |
^ ethernet packet start
|
|
|
93c8d4 |
last byte ethernet packet v
|
|
|
93c8d4 |
padding (8-bytes aligned) vvvv vvvv
|
|
|
93c8d4 |
0x05e0: c92d d444 1420 8a69 83dd 272f e82b 9811
|
|
|
93c8d4 |
0x05f0: eeee f8e3 3b19 87a0 94de 80e3 daac 0800
|
|
|
93c8d4 |
... ^ packet 2
|
|
|
93c8d4 |
0x0be0: eeee f8e3 3b19 87a0 94de 80e3 daac 0800
|
|
|
93c8d4 |
...
|
|
|
93c8d4 |
0x1130: 9d41 9171 8a38 0ec5 eeee f8e3 3b19 87a0
|
|
|
93c8d4 |
...
|
|
|
93c8d4 |
0x1720: 8cfc 15ff 5e4c e85c eeee f8e3 3b19 87a0
|
|
|
93c8d4 |
...
|
|
|
93c8d4 |
0x1d10: ecfa 2a3a 19ab c78c eeee f8e3 3b19 87a0
|
|
|
93c8d4 |
...
|
|
|
93c8d4 |
0x2070: eeee f8e3 3b19 87a0 94de 80e3 daac 0800
|
|
|
93c8d4 |
... ^ packet 7
|
|
|
93c8d4 |
0x2120: 7c88 4ca5 5c57 7dcc 0d34 7577 f778 7e0a
|
|
|
93c8d4 |
0x2130: f032 e093 7489 0740 3008 ec05 0000 0080
|
|
|
93c8d4 |
====1==== ====2====
|
|
|
93c8d4 |
hdr_off ^
|
|
|
93c8d4 |
pkt_len = 0x05ec ^^^^
|
|
|
93c8d4 |
AX_RXHDR_*=0x00830 ^^^^ ^
|
|
|
93c8d4 |
pkt_len = 0 ^^^^
|
|
|
93c8d4 |
AX_RXHDR_DROP_ERR=0x80000000 ^^^^ ^
|
|
|
93c8d4 |
0x2140: 3008 ec05 0000 0080 3008 5805 0000 0080
|
|
|
93c8d4 |
0x2150: 3008 ec05 0000 0080 3008 ec05 0000 0080
|
|
|
93c8d4 |
0x2160: 3008 5803 0000 0080 3008 c800 0000 0080
|
|
|
93c8d4 |
===11==== ===12==== ===13==== ===14====
|
|
|
93c8d4 |
0x2170: 0000 0000 0e00 3821
|
|
|
93c8d4 |
^^^^ ^^^^ rx_hdr
|
|
|
93c8d4 |
^^^^ pkt_cnt=14
|
|
|
93c8d4 |
^^^^ hdr_off=0x2138
|
|
|
93c8d4 |
^^^^ ^^^^ padding
|
|
|
93c8d4 |
|
|
|
93c8d4 |
The dump shows that pkt_cnt is the number of entrys in the
|
|
|
93c8d4 |
per-packet metadata. It is "2 * packet count".
|
|
|
93c8d4 |
Each packet have two entrys. The first have a valid
|
|
|
93c8d4 |
value (pkt_len and AX_RXHDR_*) and the second have a
|
|
|
93c8d4 |
dummy-header 0x80000000 (pkt_len=0 with AX_RXHDR_DROP_ERR).
|
|
|
93c8d4 |
Why exists dummy-header for each packet?!?
|
|
|
93c8d4 |
My guess is that this was done probably to align the
|
|
|
93c8d4 |
entry for each packet to 64-bits and maintain compatibility
|
|
|
93c8d4 |
with old firmware.
|
|
|
93c8d4 |
There is also a padding (0x00000000) before the rx_hdr to
|
|
|
93c8d4 |
align the end of rx_hdr to 64-bit.
|
|
|
93c8d4 |
Note that packets have a alignment of 64-bits (8-bytes).
|
|
|
93c8d4 |
|
|
|
93c8d4 |
This patch assumes that the dummy-header and the last
|
|
|
93c8d4 |
padding are optional. So it preserves semantics and
|
|
|
93c8d4 |
recognises the same valid packets as the current code.
|
|
|
93c8d4 |
|
|
|
93c8d4 |
This patch was made using only the dumpfile information and
|
|
|
93c8d4 |
tested with only one device:
|
|
|
93c8d4 |
0b95:1790 ASIX Electronics Corp. AX88179 Gigabit Ethernet
|
|
|
93c8d4 |
|
|
|
93c8d4 |
Fixes: 57bc3d3ae8c1 ("net: usb: ax88179_178a: Fix out-of-bounds accesses in RX fixup")
|
|
|
93c8d4 |
Fixes: e2ca90c276e1 ("ax88179_178a: ASIX AX88179_178A USB 3.0/2.0 to gigabit ethernet adapter driver")
|
|
|
93c8d4 |
Signed-off-by: Jose Alonso <joalonsof@gmail.com>
|
|
|
93c8d4 |
Acked-by: Paolo Abeni <pabeni@redhat.com>
|
|
|
93c8d4 |
Link: https://lore.kernel.org/r/d6970bb04bf67598af4d316eaeb1792040b18cfd.camel@gmail.com
|
|
|
93c8d4 |
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
|
|
|
93c8d4 |
|
|
|
93c8d4 |
Signed-off-by: Jose Ignacio Tornos Martinez <jtornosm@redhat.com>
|
|
|
93c8d4 |
|
|
|
93c8d4 |
Signed-off-by: Yannick Cote <ycote@redhat.com>
|
|
|
93c8d4 |
---
|
|
|
93c8d4 |
drivers/net/usb/ax88179_178a.c | 128 ++++++++++++++++++++++++---------
|
|
|
93c8d4 |
1 file changed, 93 insertions(+), 35 deletions(-)
|
|
|
93c8d4 |
|
|
|
93c8d4 |
diff --git a/drivers/net/usb/ax88179_178a.c b/drivers/net/usb/ax88179_178a.c
|
|
|
93c8d4 |
index 7f496ccdd272..1940f31facf0 100644
|
|
|
93c8d4 |
--- a/drivers/net/usb/ax88179_178a.c
|
|
|
93c8d4 |
+++ b/drivers/net/usb/ax88179_178a.c
|
|
|
93c8d4 |
@@ -1375,58 +1375,119 @@ static int ax88179_rx_fixup(struct usbnet *dev, struct sk_buff *skb)
|
|
|
93c8d4 |
u16 hdr_off;
|
|
|
93c8d4 |
u32 *pkt_hdr;
|
|
|
93c8d4 |
|
|
|
93c8d4 |
- /* This check is no longer done by usbnet */
|
|
|
93c8d4 |
- if (skb->len < dev->net->hard_header_len)
|
|
|
93c8d4 |
+ /* At the end of the SKB, there's a header telling us how many packets
|
|
|
93c8d4 |
+ * are bundled into this buffer and where we can find an array of
|
|
|
93c8d4 |
+ * per-packet metadata (which contains elements encoded into u16).
|
|
|
93c8d4 |
+ */
|
|
|
93c8d4 |
+
|
|
|
93c8d4 |
+ /* SKB contents for current firmware:
|
|
|
93c8d4 |
+ * <packet 1> <padding>
|
|
|
93c8d4 |
+ * ...
|
|
|
93c8d4 |
+ * <packet N> <padding>
|
|
|
93c8d4 |
+ * <per-packet metadata entry 1> <dummy header>
|
|
|
93c8d4 |
+ * ...
|
|
|
93c8d4 |
+ * <per-packet metadata entry N> <dummy header>
|
|
|
93c8d4 |
+ * <padding2> <rx_hdr>
|
|
|
93c8d4 |
+ *
|
|
|
93c8d4 |
+ * where:
|
|
|
93c8d4 |
+ * <packet N> contains pkt_len bytes:
|
|
|
93c8d4 |
+ * 2 bytes of IP alignment pseudo header
|
|
|
93c8d4 |
+ * packet received
|
|
|
93c8d4 |
+ * <per-packet metadata entry N> contains 4 bytes:
|
|
|
93c8d4 |
+ * pkt_len and fields AX_RXHDR_*
|
|
|
93c8d4 |
+ * <padding> 0-7 bytes to terminate at
|
|
|
93c8d4 |
+ * 8 bytes boundary (64-bit).
|
|
|
93c8d4 |
+ * <padding2> 4 bytes to make rx_hdr terminate at
|
|
|
93c8d4 |
+ * 8 bytes boundary (64-bit)
|
|
|
93c8d4 |
+ * <dummy-header> contains 4 bytes:
|
|
|
93c8d4 |
+ * pkt_len=0 and AX_RXHDR_DROP_ERR
|
|
|
93c8d4 |
+ * <rx-hdr> contains 4 bytes:
|
|
|
93c8d4 |
+ * pkt_cnt and hdr_off (offset of
|
|
|
93c8d4 |
+ * <per-packet metadata entry 1>)
|
|
|
93c8d4 |
+ *
|
|
|
93c8d4 |
+ * pkt_cnt is number of entrys in the per-packet metadata.
|
|
|
93c8d4 |
+ * In current firmware there is 2 entrys per packet.
|
|
|
93c8d4 |
+ * The first points to the packet and the
|
|
|
93c8d4 |
+ * second is a dummy header.
|
|
|
93c8d4 |
+ * This was done probably to align fields in 64-bit and
|
|
|
93c8d4 |
+ * maintain compatibility with old firmware.
|
|
|
93c8d4 |
+ * This code assumes that <dummy header> and <padding2> are
|
|
|
93c8d4 |
+ * optional.
|
|
|
93c8d4 |
+ */
|
|
|
93c8d4 |
+
|
|
|
93c8d4 |
+ if (skb->len < 4)
|
|
|
93c8d4 |
return 0;
|
|
|
93c8d4 |
-
|
|
|
93c8d4 |
skb_trim(skb, skb->len - 4);
|
|
|
93c8d4 |
- memcpy(&rx_hdr, skb_tail_pointer(skb), 4);
|
|
|
93c8d4 |
- le32_to_cpus(&rx_hdr);
|
|
|
93c8d4 |
-
|
|
|
93c8d4 |
+ rx_hdr = get_unaligned_le32(skb_tail_pointer(skb));
|
|
|
93c8d4 |
pkt_cnt = (u16)rx_hdr;
|
|
|
93c8d4 |
hdr_off = (u16)(rx_hdr >> 16);
|
|
|
93c8d4 |
+
|
|
|
93c8d4 |
+ if (pkt_cnt == 0)
|
|
|
93c8d4 |
+ return 0;
|
|
|
93c8d4 |
+
|
|
|
93c8d4 |
+ /* Make sure that the bounds of the metadata array are inside the SKB
|
|
|
93c8d4 |
+ * (and in front of the counter at the end).
|
|
|
93c8d4 |
+ */
|
|
|
93c8d4 |
+ if (pkt_cnt * 4 + hdr_off > skb->len)
|
|
|
93c8d4 |
+ return 0;
|
|
|
93c8d4 |
pkt_hdr = (u32 *)(skb->data + hdr_off);
|
|
|
93c8d4 |
|
|
|
93c8d4 |
- while (pkt_cnt--) {
|
|
|
93c8d4 |
+ /* Packets must not overlap the metadata array */
|
|
|
93c8d4 |
+ skb_trim(skb, hdr_off);
|
|
|
93c8d4 |
+
|
|
|
93c8d4 |
+ for (; pkt_cnt > 0; pkt_cnt--, pkt_hdr++) {
|
|
|
93c8d4 |
+ u16 pkt_len_plus_padd;
|
|
|
93c8d4 |
u16 pkt_len;
|
|
|
93c8d4 |
|
|
|
93c8d4 |
le32_to_cpus(pkt_hdr);
|
|
|
93c8d4 |
pkt_len = (*pkt_hdr >> 16) & 0x1fff;
|
|
|
93c8d4 |
+ pkt_len_plus_padd = (pkt_len + 7) & 0xfff8;
|
|
|
93c8d4 |
+
|
|
|
93c8d4 |
+ /* Skip dummy header used for alignment
|
|
|
93c8d4 |
+ */
|
|
|
93c8d4 |
+ if (pkt_len == 0)
|
|
|
93c8d4 |
+ continue;
|
|
|
93c8d4 |
+
|
|
|
93c8d4 |
+ if (pkt_len_plus_padd > skb->len)
|
|
|
93c8d4 |
+ return 0;
|
|
|
93c8d4 |
|
|
|
93c8d4 |
/* Check CRC or runt packet */
|
|
|
93c8d4 |
- if ((*pkt_hdr & AX_RXHDR_CRC_ERR) ||
|
|
|
93c8d4 |
- (*pkt_hdr & AX_RXHDR_DROP_ERR)) {
|
|
|
93c8d4 |
- skb_pull(skb, (pkt_len + 7) & 0xFFF8);
|
|
|
93c8d4 |
- pkt_hdr++;
|
|
|
93c8d4 |
+ if ((*pkt_hdr & (AX_RXHDR_CRC_ERR | AX_RXHDR_DROP_ERR)) ||
|
|
|
93c8d4 |
+ pkt_len < 2 + ETH_HLEN) {
|
|
|
93c8d4 |
+ dev->net->stats.rx_errors++;
|
|
|
93c8d4 |
+ skb_pull(skb, pkt_len_plus_padd);
|
|
|
93c8d4 |
continue;
|
|
|
93c8d4 |
}
|
|
|
93c8d4 |
|
|
|
93c8d4 |
- if (pkt_cnt == 0) {
|
|
|
93c8d4 |
- /* Skip IP alignment psudo header */
|
|
|
93c8d4 |
+ /* last packet */
|
|
|
93c8d4 |
+ if (pkt_len_plus_padd == skb->len) {
|
|
|
93c8d4 |
+ skb_trim(skb, pkt_len);
|
|
|
93c8d4 |
+
|
|
|
93c8d4 |
+ /* Skip IP alignment pseudo header */
|
|
|
93c8d4 |
skb_pull(skb, 2);
|
|
|
93c8d4 |
- skb->len = pkt_len;
|
|
|
93c8d4 |
- skb_set_tail_pointer(skb, pkt_len);
|
|
|
93c8d4 |
- skb->truesize = pkt_len + sizeof(struct sk_buff);
|
|
|
93c8d4 |
+
|
|
|
93c8d4 |
+ skb->truesize = SKB_TRUESIZE(pkt_len_plus_padd);
|
|
|
93c8d4 |
ax88179_rx_checksum(skb, pkt_hdr);
|
|
|
93c8d4 |
return 1;
|
|
|
93c8d4 |
}
|
|
|
93c8d4 |
|
|
|
93c8d4 |
ax_skb = skb_clone(skb, GFP_ATOMIC);
|
|
|
93c8d4 |
- if (ax_skb) {
|
|
|
93c8d4 |
- ax_skb->len = pkt_len;
|
|
|
93c8d4 |
- ax_skb->data = skb->data + 2;
|
|
|
93c8d4 |
- skb_set_tail_pointer(ax_skb, pkt_len);
|
|
|
93c8d4 |
- ax_skb->truesize = pkt_len + sizeof(struct sk_buff);
|
|
|
93c8d4 |
- ax88179_rx_checksum(ax_skb, pkt_hdr);
|
|
|
93c8d4 |
- usbnet_skb_return(dev, ax_skb);
|
|
|
93c8d4 |
- } else {
|
|
|
93c8d4 |
+ if (!ax_skb)
|
|
|
93c8d4 |
return 0;
|
|
|
93c8d4 |
- }
|
|
|
93c8d4 |
+ skb_trim(ax_skb, pkt_len);
|
|
|
93c8d4 |
|
|
|
93c8d4 |
- skb_pull(skb, (pkt_len + 7) & 0xFFF8);
|
|
|
93c8d4 |
- pkt_hdr++;
|
|
|
93c8d4 |
+ /* Skip IP alignment pseudo header */
|
|
|
93c8d4 |
+ skb_pull(ax_skb, 2);
|
|
|
93c8d4 |
+
|
|
|
93c8d4 |
+ skb->truesize = pkt_len_plus_padd +
|
|
|
93c8d4 |
+ SKB_DATA_ALIGN(sizeof(struct sk_buff));
|
|
|
93c8d4 |
+ ax88179_rx_checksum(ax_skb, pkt_hdr);
|
|
|
93c8d4 |
+ usbnet_skb_return(dev, ax_skb);
|
|
|
93c8d4 |
+
|
|
|
93c8d4 |
+ skb_pull(skb, pkt_len_plus_padd);
|
|
|
93c8d4 |
}
|
|
|
93c8d4 |
- return 1;
|
|
|
93c8d4 |
+
|
|
|
93c8d4 |
+ return 0;
|
|
|
93c8d4 |
}
|
|
|
93c8d4 |
|
|
|
93c8d4 |
static struct sk_buff *
|
|
|
93c8d4 |
@@ -1436,6 +1497,7 @@ ax88179_tx_fixup(struct usbnet *dev, struct sk_buff *skb, gfp_t flags)
|
|
|
93c8d4 |
int frame_size = dev->maxpacket;
|
|
|
93c8d4 |
int mss = skb_shinfo(skb)->gso_size;
|
|
|
93c8d4 |
int headroom;
|
|
|
93c8d4 |
+ void *ptr;
|
|
|
93c8d4 |
|
|
|
93c8d4 |
tx_hdr1 = skb->len;
|
|
|
93c8d4 |
tx_hdr2 = mss;
|
|
|
93c8d4 |
@@ -1450,13 +1512,9 @@ ax88179_tx_fixup(struct usbnet *dev, struct sk_buff *skb, gfp_t flags)
|
|
|
93c8d4 |
return NULL;
|
|
|
93c8d4 |
}
|
|
|
93c8d4 |
|
|
|
93c8d4 |
- skb_push(skb, 4);
|
|
|
93c8d4 |
- cpu_to_le32s(&tx_hdr2);
|
|
|
93c8d4 |
- skb_copy_to_linear_data(skb, &tx_hdr2, 4);
|
|
|
93c8d4 |
-
|
|
|
93c8d4 |
- skb_push(skb, 4);
|
|
|
93c8d4 |
- cpu_to_le32s(&tx_hdr1);
|
|
|
93c8d4 |
- skb_copy_to_linear_data(skb, &tx_hdr1, 4);
|
|
|
93c8d4 |
+ ptr = skb_push(skb, 8);
|
|
|
93c8d4 |
+ put_unaligned_le32(tx_hdr1, ptr);
|
|
|
93c8d4 |
+ put_unaligned_le32(tx_hdr2, ptr + 4);
|
|
|
93c8d4 |
|
|
|
93c8d4 |
return skb;
|
|
|
93c8d4 |
}
|
|
|
93c8d4 |
--
|
|
|
93c8d4 |
2.39.0
|
|
|
93c8d4 |
|
|
|
93c8d4 |
|