]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - releases/4.19.41/net-stmmac-fix-dropping-of-multi-descriptor-rx-frame.patch
5.1-stable patches
[thirdparty/kernel/stable-queue.git] / releases / 4.19.41 / net-stmmac-fix-dropping-of-multi-descriptor-rx-frame.patch
1 From 0b582038c010f4b31b632314d7879350eed6ca4a Mon Sep 17 00:00:00 2001
2 From: Aaro Koskinen <aaro.koskinen@nokia.com>
3 Date: Wed, 27 Mar 2019 22:35:39 +0200
4 Subject: net: stmmac: fix dropping of multi-descriptor RX frames
5
6 [ Upstream commit 8ac0c24fe1c256af6644caf3d311029440ec2fbd ]
7
8 Packets without the last descriptor set should be dropped early. If we
9 receive a frame larger than the DMA buffer, the HW will continue using the
10 next descriptor. Driver mistakes these as individual frames, and sometimes
11 a truncated frame (without the LD set) may look like a valid packet.
12
13 This fixes a strange issue where the system replies to 4098-byte ping
14 although the MTU/DMA buffer size is set to 4096, and yet at the same
15 time it's logging an oversized packet.
16
17 Signed-off-by: Aaro Koskinen <aaro.koskinen@nokia.com>
18 Signed-off-by: David S. Miller <davem@davemloft.net>
19 Signed-off-by: Sasha Levin <sashal@kernel.org>
20 ---
21 drivers/net/ethernet/stmicro/stmmac/enh_desc.c | 5 +++++
22 1 file changed, 5 insertions(+)
23
24 diff --git a/drivers/net/ethernet/stmicro/stmmac/enh_desc.c b/drivers/net/ethernet/stmicro/stmmac/enh_desc.c
25 index c42ef6c729c0..5202d6ad7919 100644
26 --- a/drivers/net/ethernet/stmicro/stmmac/enh_desc.c
27 +++ b/drivers/net/ethernet/stmicro/stmmac/enh_desc.c
28 @@ -201,6 +201,11 @@ static int enh_desc_get_rx_status(void *data, struct stmmac_extra_stats *x,
29 if (unlikely(rdes0 & RDES0_OWN))
30 return dma_own;
31
32 + if (unlikely(!(rdes0 & RDES0_LAST_DESCRIPTOR))) {
33 + stats->rx_length_errors++;
34 + return discard_frame;
35 + }
36 +
37 if (unlikely(rdes0 & RDES0_ERROR_SUMMARY)) {
38 if (unlikely(rdes0 & RDES0_DESCRIPTOR_ERROR)) {
39 x->rx_desc++;
40 --
41 2.20.1
42