An SK_MSG program can pop the whole message with bpf_msg_pop_data() and then redirect it with BPF_F_INGRESS. tcp_bpf_send_verdict() does not check for that and calls bpf_tcp_ingress() with nothing to send. Its do-while loop still walks the empty ring, charges zero bytes and queues a zero sized sk_msg on the peer's ingress_msg. __sk_msg_recvmsg() hits the zero length element first, returns -EFAULT and never dequeues it, so every later message on that socket sits behind it and recvmsg() keeps failing. Only tearing down the psock gets rid of it. Return early from bpf_tcp_ingress() when the message is empty. SK_PASS and egress redirect already send nothing in that case. Fixes: 5d609ba26247 ("bpf, sockmap: Several fixes to bpf_msg_pop_data") Signed-off-by: Jiayuan Chen --- net/ipv4/tcp_bpf.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/net/ipv4/tcp_bpf.c b/net/ipv4/tcp_bpf.c index e59103e77aa5..7191b95c7b1c 100644 --- a/net/ipv4/tcp_bpf.c +++ b/net/ipv4/tcp_bpf.c @@ -39,6 +39,9 @@ static int bpf_tcp_ingress(struct sock *sk, struct sk_psock *psock, struct sk_msg *tmp; int i, ret = 0; + if (!msg->sg.size) + return 0; + tmp = kzalloc_obj(*tmp, __GFP_NOWARN | GFP_KERNEL); if (unlikely(!tmp)) return -ENOMEM; -- 2.43.0