linux/net
Liu Jian 9974d37ea7 skmsg: Fix invalid last sg check in sk_msg_recvmsg()
In sk_psock_skb_ingress_enqueue function, if the linear area + nr_frags +
frag_list of the SKB has NR_MSG_FRAG_IDS blocks in total, skb_to_sgvec
will return NR_MSG_FRAG_IDS, then msg->sg.end will be set to
NR_MSG_FRAG_IDS, and in addition, (NR_MSG_FRAG_IDS - 1) is set to the last
SG of msg. Recv the msg in sk_msg_recvmsg, when i is (NR_MSG_FRAG_IDS - 1),
the sk_msg_iter_var_next(i) will change i to 0 (not NR_MSG_FRAG_IDS), the
judgment condition "msg_rx->sg.start==msg_rx->sg.end" and
"i != msg_rx->sg.end" can not work.

As a result, the processed msg cannot be deleted from ingress_msg list.
But the length of all the sge of the msg has changed to 0. Then the next
recvmsg syscall will process the msg repeatedly, because the length of sge
is 0, the -EFAULT error is always returned.

Fixes: 604326b41a ("bpf, sockmap: convert to generic sk_msg interface")
Signed-off-by: Liu Jian <liujian56@huawei.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: John Fastabend <john.fastabend@gmail.com>
Link: https://lore.kernel.org/bpf/20220628123616.186950-1-liujian56@huawei.com
2022-07-11 18:22:07 +02:00
..
6lowpan
9p
802
8021q
appletalk
atm
ax25 ax25: use GFP_KERNEL in ax25_dev_device_up() 2022-06-17 20:34:13 -07:00
batman-adv
bluetooth Bluetooth: core: Fix deadlock on hci_power_on_sync. 2022-07-05 13:20:03 -07:00
bpf
bpfilter
bridge Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net 2022-06-30 16:31:00 -07:00
caif
can Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net 2022-07-07 12:07:37 -07:00
ceph
core skmsg: Fix invalid last sg check in sk_msg_recvmsg() 2022-07-11 18:22:07 +02:00
dcb
dccp Revert "net: Add a second bind table hashed by port and address" 2022-06-16 11:07:59 -07:00
decnet net, neigh: introduce interval_probe_time_ms for periodic probe 2022-06-30 13:14:35 +02:00
dns_resolver
dsa net: dsa: tag_ksz: add tag handling for Microchip LAN937x 2022-07-02 16:34:05 +01:00
ethernet
ethtool Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net 2022-06-23 12:33:24 -07:00
hsr
ieee802154
ife
ipv4 net: Find dst with sk's xfrm policy not ctl_sk 2022-07-11 13:39:56 +01:00
ipv6 net: Find dst with sk's xfrm policy not ctl_sk 2022-07-11 13:39:56 +01:00
iucv net: keep sk->sk_forward_alloc as small as possible 2022-06-10 16:21:27 -07:00
kcm
key
l2tp l2tp: l2tp_debugfs: fix Clang -Wformat warnings 2022-07-08 12:14:36 +01:00
l3mdev
lapb
llc
mac80211 wireless-next patches for v5.20 2022-06-10 08:57:35 -07:00
mac802154
mctp
mpls
mptcp mptcp: move MPTCPOPT_HMAC_LEN to net/mptcp.h 2022-07-09 12:19:23 +01:00
ncsi net/ncsi: use proper "mellanox" DT vendor prefix 2022-06-23 20:51:06 -07:00
netfilter netfilter: nft_set_pipapo: release elements in clone from abort path 2022-07-02 21:04:19 +02:00
netlabel
netlink
netrom
nfc
nsh
openvswitch Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net 2022-06-23 12:33:24 -07:00
packet
phonet
psample
qrtr
rds
rfkill
rose net: rose: fix UAF bug caused by rose_t0timer_expiry 2022-07-06 19:49:11 -07:00
rxrpc net: rxrpc: fix clang -Wformat warning 2022-07-08 20:15:11 -07:00
sched Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net 2022-07-07 12:07:37 -07:00
sctp net: keep sk->sk_forward_alloc as small as possible 2022-06-10 16:21:27 -07:00
smc
strparser strparser: pad sk_skb_cb to avoid straddling cachelines 2022-07-08 18:38:44 -07:00
sunrpc Notable regression fixes: 2022-07-02 11:20:56 -07:00
switchdev
tipc Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net 2022-06-30 16:31:00 -07:00
tls tls: rx: make tls_wait_data() return an recvmsg retcode 2022-07-08 18:38:45 -07:00
unix Merge https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next 2022-07-09 12:24:16 -07:00
vmw_vsock
wireless
x25
xdp Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net 2022-07-07 12:07:37 -07:00
xfrm
compat.c
devres.c
Kconfig
Kconfig.debug
Makefile
socket.c Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net 2022-06-30 16:31:00 -07:00
sysctl_net.c