OrangePi_CM5/net/core
Jiri Benc 50868de7dc net: gso: fix panic on frag_list with mixed head alloc types
[ Upstream commit 9e4b7a99a03aefd37ba7bb1f022c8efab5019165 ]

Since commit 3dcbdb134f ("net: gso: Fix skb_segment splat when
splitting gso_size mangled skb having linear-headed frag_list"), it is
allowed to change gso_size of a GRO packet. However, that commit assumes
that "checking the first list_skb member suffices; i.e if either of the
list_skb members have non head_frag head, then the first one has too".

It turns out this assumption does not hold. We've seen BUG_ON being hit
in skb_segment when skbs on the frag_list had differing head_frag with
the vmxnet3 driver. This happens because __netdev_alloc_skb and
__napi_alloc_skb can return a skb that is page backed or kmalloced
depending on the requested size. As the result, the last small skb in
the GRO packet can be kmalloced.

There are three different locations where this can be fixed:

(1) We could check head_frag in GRO and not allow GROing skbs with
    different head_frag. However, that would lead to performance
    regression on normal forward paths with unmodified gso_size, where
    !head_frag in the last packet is not a problem.

(2) Set a flag in bpf_skb_net_grow and bpf_skb_net_shrink indicating
    that NETIF_F_SG is undesirable. That would need to eat a bit in
    sk_buff. Furthermore, that flag can be unset when all skbs on the
    frag_list are page backed. To retain good performance,
    bpf_skb_net_grow/shrink would have to walk the frag_list.

(3) Walk the frag_list in skb_segment when determining whether
    NETIF_F_SG should be cleared. This of course slows things down.

This patch implements (3). To limit the performance impact in
skb_segment, the list is walked only for skbs with SKB_GSO_DODGY set
that have gso_size changed. Normal paths thus will not hit it.

We could check only the last skb but since we need to walk the whole
list anyway, let's stay on the safe side.

Fixes: 3dcbdb134f ("net: gso: Fix skb_segment splat when splitting gso_size mangled skb having linear-headed frag_list")
Signed-off-by: Jiri Benc <jbenc@redhat.com>
Reviewed-by: Willem de Bruijn <willemb@google.com>
Link: https://lore.kernel.org/r/e04426a6a91baf4d1081e1b478c82b5de25fdf21.1667407944.git.jbenc@redhat.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2022-11-16 09:57:09 +01:00
..
Makefile
…
bpf_sk_storage.c net: Fix data-races around sysctl_optmem_max. 2022-08-31 17:15:20 +02:00
datagram.c
…
datagram.h
…
dev.c bpf: Don't redirect packets with invalid pkt_len 2022-09-05 10:28:56 +02:00
dev_addr_lists.c
…
dev_ioctl.c net: socket: remove register_gifconf 2022-09-28 11:10:35 +02:00
devlink.c devlink: Fix use-after-free after a failed reload 2022-08-25 11:37:57 +02:00
drop_monitor.c drop_monitor: fix data-race in dropmon_net_event / trace_napi_poll_hit 2022-02-23 12:01:02 +01:00
dst.c
…
dst_cache.c wireguard: device: reset peer src endpoint when netns exits 2021-12-08 09:03:22 +01:00
failover.c
…
fib_notifier.c
…
fib_rules.c ipv6: fix memory leak in fib6_rule_suppress 2021-12-08 09:03:21 +01:00
filter.c net: Fix data-races around sysctl_optmem_max. 2022-08-31 17:15:20 +02:00
flow_dissector.c net: core: fix flow symmetric hash 2022-09-28 11:10:30 +02:00
flow_offload.c netfilter: nf_tables: bail out early if hardware offload is not supported 2022-06-14 18:32:40 +02:00
gen_estimator.c
…
gen_stats.c
…
gro_cells.c net: Fix data-races around netdev_max_backlog. 2022-08-31 17:15:19 +02:00
hwbm.c
…
link_watch.c net: linkwatch: fix failure to restore device state across suspend/resume 2021-08-18 08:59:13 +02:00
lwt_bpf.c bpf, lwt: Fix crash when using bpf_skb_set_tunnel_key() from bpf_xmit lwt hook 2022-05-09 09:05:02 +02:00
lwtunnel.c lwtunnel: Validate RTA_ENCAP_TYPE attribute length 2022-01-11 15:25:00 +01:00
neighbour.c net, neigh: Fix null-ptr-deref in neigh_table_clear() 2022-11-10 18:14:20 +01:00
net-procfs.c net-procfs: show net devices bound packet types 2022-02-01 17:25:44 +01:00
net-sysfs.c net-sysfs: add check for netdevice being present to speed_show 2022-03-16 14:16:00 +01:00
net-sysfs.h
…
net-traces.c
…
net_namespace.c net: fix UAF issue in nfqnl_nf_hook_drop() when ops_init() failed 2022-11-03 23:57:52 +09:00
netclassid_cgroup.c
…
netevent.c
…
netpoll.c
…
netprio_cgroup.c
…
page_pool.c
…
pktgen.c
…
ptp_classifier.c
…
request_sock.c
…
rtnetlink.c net: make free_netdev() more lenient with unregistering devices 2022-07-29 17:19:07 +02:00
scm.c
…
secure_seq.c tcp: Fix data-races around sysctl knobs related to SYN option. 2022-07-29 17:19:21 +02:00
skbuff.c net: gso: fix panic on frag_list with mixed head alloc types 2022-11-16 09:57:09 +01:00
skmsg.c net: fix refcount bug in sk_psock_get (2) 2022-09-05 10:28:56 +02:00
sock.c net: Fix a data-race around sysctl_net_busy_read. 2022-08-31 17:15:20 +02:00
sock_diag.c
…
sock_map.c bpf: Acquire map uref in .init_seq_private for sock{map,hash} iterator 2022-08-25 11:37:55 +02:00
sock_reuseport.c udp: Update reuse->has_conns under reuseport_lock. 2022-10-30 09:41:19 +01:00
stream.c net: If sock is dead don't access sock's sk_wq in sk_stream_wait_memory 2022-10-26 13:25:47 +02:00
sysctl_net_core.c net: Fix data-races around weight_p and dev_weight_[rt]x_bias. 2022-08-31 17:15:19 +02:00
timestamping.c
…
tso.c
…
utils.c
…
xdp.c
…