linux-stable/net/core
Jiri Benc bd5362e587 net: gso: fix panic on frag_list with mixed head alloc types
[ Upstream commit 9e4b7a99a0 ]

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-25 17:40:16 +01:00
..
datagram.c net: add READ_ONCE() annotation in __skb_wait_for_more_packets() 2019-11-10 11:27:49 +01:00
dev.c net: Fix a data-race around netdev_budget_usecs. 2022-09-05 10:26:31 +02:00
dev_addr_lists.c
dev_ioctl.c
devlink.c devlink: Add missing genlmsg_cancel() in devlink_nl_sb_port_pool_fill() 2020-11-24 13:27:16 +01:00
drop_monitor.c drop_monitor: fix data-race in dropmon_net_event / trace_napi_poll_hit 2022-02-23 11:58:39 +01:00
dst.c
dst_cache.c
ethtool.c net: ethtool: clear heap allocations for ethtool function 2021-06-30 08:48:30 -04:00
failover.c failover: allow name change on IFF_UP slave interfaces 2019-04-27 09:36:30 +02:00
fib_notifier.c
fib_rules.c fib: Return the correct errno code 2021-06-30 08:48:13 -04:00
filter.c seg6: bpf: fix skb checksum in bpf_push_seg6_encap() 2022-07-21 21:09:29 +02:00
flow_dissector.c net/sched: flower: fix parsing of ethertype following VLAN header 2022-04-20 09:12:48 +02:00
gen_estimator.c net_sched: gen_estimator: support large ewma log 2021-02-07 14:48:37 +01:00
gen_stats.c net: sched: put back q.qlen into a single location 2019-03-10 07:17:16 +01:00
gro_cells.c gro_cells: make sure device is up in gro_cells_receive() 2019-03-19 13:12:38 +01:00
hwbm.c
link_watch.c
lwt_bpf.c lwt: Disable BH too in run_lwt_bpf() 2020-12-30 11:26:06 +01:00
lwtunnel.c
Makefile
neighbour.c net, neigh: Fix null-ptr-deref in neigh_table_clear() 2022-11-10 17:46:53 +01:00
net-procfs.c net-procfs: show net devices bound packet types 2022-02-08 18:23:09 +01:00
net-sysfs.c net-sysfs: add check for netdevice being present to speed_show 2022-03-16 13:20:27 +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:52:31 +09:00
netclassid_cgroup.c cgroup, netclassid: remove double cond_resched 2020-05-10 10:30:12 +02:00
netevent.c
netpoll.c net: Have netpoll bring-up DSA management interface 2020-11-24 13:27:17 +01:00
netprio_cgroup.c netprio_cgroup: Fix unlimited memory leak of v2 cgroups 2020-05-20 08:18:38 +02:00
page_pool.c
pktgen.c pktgen: fix misuse of BUG_ON() in pktgen_thread_worker() 2021-03-07 12:18:57 +01:00
ptp_classifier.c
request_sock.c
rtnetlink.c rtnetlink: make sure to refresh master_dev/m_ops in __rtnl_newlink() 2022-02-08 18:23:12 +01:00
scm.c
secure_seq.c secure_seq: use the 64 bits of the siphash for port offset calculation 2022-06-06 08:24:20 +02:00
skbuff.c net: gso: fix panic on frag_list with mixed head alloc types 2022-11-25 17:40:16 +01:00
sock.c net: Fix a data-race around sysctl_net_busy_read. 2022-09-05 10:26:31 +02:00
sock_diag.c
sock_reuseport.c udp: Prevent reuseport_select_sock from reading uninitialized socks 2021-01-23 15:49:55 +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:19:38 +02:00
sysctl_net_core.c net: Fix data-races around weight_p and dev_weight_[rt]x_bias. 2022-09-05 10:26:30 +02:00
timestamping.c
tso.c
utils.c net: Fix skb->csum update in inet_proto_csum_replace16(). 2020-02-05 14:43:53 +00:00
xdp.c