]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commit
bpf, sockmap: Handle fin correctly
authorJohn Fastabend <john.fastabend@gmail.com>
Tue, 23 May 2023 02:56:09 +0000 (19:56 -0700)
committerStefan Bader <stefan.bader@canonical.com>
Wed, 9 Aug 2023 09:38:16 +0000 (11:38 +0200)
commitb13b1c37d1bf2c9e2586d1e0c9432ac10d76698a
treebb0be3e08a9c78035d73907dd0901287f03cfde7
parent09a55f16fb6f1b0e5602216a0e1db281684c7904
bpf, sockmap: Handle fin correctly

BugLink: https://bugs.launchpad.net/bugs/2028979
[ Upstream commit 901546fd8f9ca4b5c481ce00928ab425ce9aacc0 ]

The sockmap code is returning EAGAIN after a FIN packet is received and no
more data is on the receive queue. Correct behavior is to return 0 to the
user and the user can then close the socket. The EAGAIN causes many apps
to retry which masks the problem. Eventually the socket is evicted from
the sockmap because its released from sockmap sock free handling. The
issue creates a delay and can cause some errors on application side.

To fix this check on sk_msg_recvmsg side if length is zero and FIN flag
is set then set return to zero. A selftest will be added to check this
condition.

Fixes: 04919bed948dc ("tcp: Introduce tcp_read_skb()")
Signed-off-by: John Fastabend <john.fastabend@gmail.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Tested-by: William Findlay <will@isovalent.com>
Reviewed-by: Jakub Sitnicki <jakub@cloudflare.com>
Link: https://lore.kernel.org/bpf/20230523025618.113937-6-john.fastabend@gmail.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
net/ipv4/tcp_bpf.c