acrn-kernel/net
Mohamed Khalfella 04c3eee4e1 skbuff: skb_segment, Call zero copy functions before using skbuff frags
commit 2ea35288c8 upstream.

Commit bf5c25d608 ("skbuff: in skb_segment, call zerocopy functions
once per nskb") added the call to zero copy functions in skb_segment().
The change introduced a bug in skb_segment() because skb_orphan_frags()
may possibly change the number of fragments or allocate new fragments
altogether leaving nrfrags and frag to point to the old values. This can
cause a panic with stacktrace like the one below.

[  193.894380] BUG: kernel NULL pointer dereference, address: 00000000000000bc
[  193.895273] CPU: 13 PID: 18164 Comm: vh-net-17428 Kdump: loaded Tainted: G           O      5.15.123+ #26
[  193.903919] RIP: 0010:skb_segment+0xb0e/0x12f0
[  194.021892] Call Trace:
[  194.027422]  <TASK>
[  194.072861]  tcp_gso_segment+0x107/0x540
[  194.082031]  inet_gso_segment+0x15c/0x3d0
[  194.090783]  skb_mac_gso_segment+0x9f/0x110
[  194.095016]  __skb_gso_segment+0xc1/0x190
[  194.103131]  netem_enqueue+0x290/0xb10 [sch_netem]
[  194.107071]  dev_qdisc_enqueue+0x16/0x70
[  194.110884]  __dev_queue_xmit+0x63b/0xb30
[  194.121670]  bond_start_xmit+0x159/0x380 [bonding]
[  194.128506]  dev_hard_start_xmit+0xc3/0x1e0
[  194.131787]  __dev_queue_xmit+0x8a0/0xb30
[  194.138225]  macvlan_start_xmit+0x4f/0x100 [macvlan]
[  194.141477]  dev_hard_start_xmit+0xc3/0x1e0
[  194.144622]  sch_direct_xmit+0xe3/0x280
[  194.147748]  __dev_queue_xmit+0x54a/0xb30
[  194.154131]  tap_get_user+0x2a8/0x9c0 [tap]
[  194.157358]  tap_sendmsg+0x52/0x8e0 [tap]
[  194.167049]  handle_tx_zerocopy+0x14e/0x4c0 [vhost_net]
[  194.173631]  handle_tx+0xcd/0xe0 [vhost_net]
[  194.176959]  vhost_worker+0x76/0xb0 [vhost]
[  194.183667]  kthread+0x118/0x140
[  194.190358]  ret_from_fork+0x1f/0x30
[  194.193670]  </TASK>

In this case calling skb_orphan_frags() updated nr_frags leaving nrfrags
local variable in skb_segment() stale. This resulted in the code hitting
i >= nrfrags prematurely and trying to move to next frag_skb using
list_skb pointer, which was NULL, and caused kernel panic. Move the call
to zero copy functions before using frags and nr_frags.

Fixes: bf5c25d608 ("skbuff: in skb_segment, call zerocopy functions once per nskb")
Signed-off-by: Mohamed Khalfella <mkhalfella@purestorage.com>
Reported-by: Amit Goyal <agoyal@purestorage.com>
Cc: stable@vger.kernel.org
Reviewed-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2023-09-13 09:42:59 +02:00
..
6lowpan
9p 9p: virtio: make sure 'offs' is initialized in zc_request 2023-09-13 09:42:21 +02:00
802
8021q
appletalk
atm
ax25
batman-adv batman-adv: Hold rtnl lock during MTU update via netlink 2023-08-30 16:11:08 +02:00
bluetooth net: annotate data-races around sk->sk_lingertime 2023-09-13 09:42:33 +02:00
bpf
bpfilter
bridge Revert "bridge: Add extack warning when enabling STP in netns." 2023-09-13 09:42:20 +02:00
caif
can can: raw: add missing refcount for memory leak fix 2023-08-30 16:11:11 +02:00
ceph
core skbuff: skb_segment, Call zero copy functions before using skbuff frags 2023-09-13 09:42:59 +02:00
dcb
dccp ipv4: fix data-races around inet->inet_id 2023-08-30 16:11:02 +02:00
devlink devlink: add missing unregister linecard notification 2023-08-30 16:11:00 +02:00
dns_resolver
dsa
ethernet
ethtool
hsr
ieee802154
ife
ipv4 igmp: limit igmpv3_newpack() packet size to IP_MAX_MTU 2023-09-13 09:42:59 +02:00
ipv6 lwt: Check LWTUNNEL_XMIT_CONTINUE strictly 2023-09-13 09:42:33 +02:00
iucv
kcm
key net: af_key: fix sadb_x_filter validation 2023-08-23 17:52:32 +02:00
l2tp
l3mdev
lapb
llc
mac80211 wifi: mac80211: Use active_links instead of valid_links in Tx 2023-09-13 09:42:24 +02:00
mac802154
mctp
mpls
mptcp mptcp: fix the incorrect judgment for msk->cb_flags 2023-08-16 18:27:26 +02:00
ncsi
netfilter netfilter: xt_sctp: validate the flag_info count 2023-09-13 09:42:59 +02:00
netlabel netlabel: fix shift wrapping bug in netlbl_catmap_setlong() 2023-09-13 09:42:24 +02:00
netlink
netrom netrom: Deny concurrent connect(). 2023-09-13 09:42:35 +02:00
nfc
nsh
openvswitch net: openvswitch: reject negative ifindex 2023-08-23 17:52:35 +02:00
packet net/packet: annotate data-races around tp->status 2023-08-16 18:27:26 +02:00
phonet
psample
qrtr
rds
rfkill
rose
rxrpc
sched net/sched: sch_hfsc: Ensure inner classes have fsc curve 2023-09-13 09:42:35 +02:00
sctp sctp: handle invalid error codes without calling BUG() 2023-09-13 09:42:25 +02:00
smc net: annotate data-races around sk->sk_lingertime 2023-09-13 09:42:33 +02:00
strparser
sunrpc xprtrdma: Remap Receive buffers after a reconnect 2023-08-30 16:10:57 +02:00
switchdev
tipc
tls net: tls: avoid discarding data on record close 2023-08-16 18:27:27 +02:00
unix af_unix: Fix null-ptr-deref in unix_stream_sendpage(). 2023-08-23 17:52:42 +02:00
vmw_vsock
wireless wifi: nl80211/cfg80211: add forgotten nla_policy for BSS color attribute 2023-09-13 09:42:34 +02:00
x25
xdp xsk: fix refcount underflow in error path 2023-08-16 18:27:27 +02:00
xfrm xfrm: add forgotten nla_policy for XFRMA_MTIMER_THRESH 2023-08-23 17:52:32 +02:00
Kconfig
Kconfig.debug
Makefile devlink: move code to a dedicated directory 2023-08-30 16:11:00 +02:00
compat.c
devres.c
socket.c net: Avoid address overwrite in kernel_connect 2023-09-13 09:42:26 +02:00
sysctl_net.c