Bug 2066976

Summary: AF_PACKET SOCK_RAW drops GSO tagged packets.
Product: Red Hat Enterprise Linux 8 Reporter: Flavio Leitner <fleitner>
Component: kernelAssignee: Hangbin Liu <haliu>
kernel sub component: Networking QA Contact: Jianwen Ji <jiji>
Status: CLOSED ERRATA Docs Contact:
Severity: medium    
Priority: unspecified CC: jarod, jiji, kzhang, mpattric
Version: 8.8Keywords: Triaged
Target Milestone: rc   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: kernel-4.18.0-404.el8 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2022-11-08 10:26:02 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
Reproducer
none
Reproducer none

Description Flavio Leitner 2022-03-22 23:33:20 UTC
Created attachment 1867603 [details]
Reproducer

Description of problem:


The kernel drops GSO tagged packets while untagged packets are forwarded.

The reproducer only requires a veth pair, one side in the host and another in a another netns.

ip netns add test
ip link add veth1 type veth peer name veth2
ip link set veth2 netns test 
ip netns exec test ip link add veth2.10 link veth2 type vlan id 10 
ip netns exec test ip link set veth2 up 
ip netns exec test ip link set veth2.10 up 
ip netns exec test ip address add 192.168.200.31/24 dev veth2.10
ip link set veth1 up 


On one terminal run tcpdump:
ip netns exec test tcpdump -n -nn -e -v -i veth2 

On another terminal run the reproducer:
# gcc -o repro sock-gso.c 
#./repro veth1 untag gso

The above should show the packet being forwarded ok:
20:21:48.533856 52:54:00:40:f8:92 > 56:16:b4:8a:ca:12, ethertype IPv4 (0x0800), length 2048: (tos 0x0, ttl 64, id 0, offset 0, flags [none], proto TCP (6), length 2024)
    192.168.200.11.3320 > 192.168.200.31.8080: Flags [P], cksum 0xe6a8 (incorrect -> 0x5d97), seq 666:2650, win 1536, length 1984: HTTP


Now running with VLAN tag:
# ./repro veth1 tag gso 

This doesn't show any packet. Not even in veth1 interface.


Disabling GSO without VLAN tag:
# ./repro veth1 untag n


The above shows the packet below being forwarded ok:
20:23:55.307572 52:54:00:40:f8:92 > 56:16:b4:8a:ca:12, ethertype IPv4 (0x0800), length 400: (tos 0x0, ttl 64, id 0, offset 0, flags [none], proto TCP (6), length 376)
    192.168.200.11.3320 > 192.168.200.31.8080: Flags [P], cksum 0xed18 (incorrect -> 0x6407), seq 666:1002, win 1536, length 336: HTTP


Disabling GSO with tagged VLAN:
# ./repro veth1 tag n
20:25:04.375593 52:54:00:40:f8:92 > 56:16:b4:8a:ca:12, ethertype 802.1Q (0x8100), length 400: vlan 10, p 0, ethertype IPv4 (0x0800), (tos 0x0, ttl 64, id 0, offset 0, flags [none], proto TCP (6), length 376)
    192.168.200.11.3320 > 192.168.200.31.8080: Flags [P], cksum 0xed18 (incorrect -> 0x6407), seq 666:1002, win 1536, length 336: HTTP

That works too, so forwarding fails only with the GSO + VLAN tag.

The TX drop increases in veth1 interface in that case.

A quick look at the kernel sources indicates the issue might be in inet_gso_segment().


Version-Release number of selected component (if applicable):

The issue happens with 5.17.0-rc7+ as well.

How reproducible:
Always


Actual results:
The GSO tagged packet is dropped.


Expected results:
The GSO tagged packet should be forwarded.

Comment 1 Flavio Leitner 2022-03-22 23:53:45 UTC
Created attachment 1867615 [details]
Reproducer

Comment 2 Hangbin Liu 2022-03-28 09:53:53 UTC
> A quick look at the kernel sources indicates the issue might be in inet_gso_segment().

        skb_reset_network_header(skb);
        nhoff = skb_network_header(skb) - skb_mac_header(skb);
        if (unlikely(!pskb_may_pull(skb, sizeof(*iph))))
                goto out;

        iph = ip_hdr(skb);
        ihl = iph->ihl * 4;
        if (ihl < sizeof(*iph))
                goto out;

Looks it doesn't check if there is a VLAN header. Need to see how to fix it, as there may also has QinQ header.

Comment 3 Hangbin Liu 2022-04-14 06:27:05 UTC
OK, since we don't support VLAN in inet_gso_segment, we should return error to userspace.
But the packet_snd() didn't do it as it only checks if error > 0, while it sometime may return error < 0.

```
static int packet_snd()
        [...]
        err = po->xmit(skb);
        if (err > 0 && (err = net_xmit_errno(err)) != 0)
                goto out_unlock;

        [...]
}
```

So a simple fix is to also check if error < 0. But in a long time, we'd better try to implement VLAN GSO.

Comment 4 Flavio Leitner 2022-04-14 11:23:07 UTC
We are actually implementing TSO/GSO support in OVS user space and that is how I found out about this problem.
If the kernel doesn't support that, it means user space needs to segment the packet and lose performance.
fbl

Comment 5 Hangbin Liu 2022-04-15 01:31:42 UTC
(In reply to Flavio Leitner from comment #4)
> We are actually implementing TSO/GSO support in OVS user space and that is
> how I found out about this problem.
> If the kernel doesn't support that, it means user space needs to segment the
> packet and lose performance.

I'm still investing the reason. There may have a bug as in skb_mac_gso_segment() it should deal with the VLANs, but actually not.

Comment 13 Hangbin Liu 2022-06-01 01:59:42 UTC
Move back to Assigned as there is a followup fix need to backport.

Comment 17 Hangbin Liu 2022-06-15 04:24:26 UTC
FYI, reproducer https://syzkaller.appspot.com/bug?extid=7160965e6a93d826048a for the second patch

Comment 23 errata-xmlrpc 2022-11-08 10:26:02 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (Moderate: kernel security, bug fix, and enhancement update), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHSA-2022:7683