From: Josef Bacik The verdict of an sk_msg prog is valid for one message, or for the bytes that bpf_msg_apply_bytes() requests. These bytes can come from many sendmsg() calls. Thus tcp_bpf_send_verdict() keeps the verdict in psock->eval and runs the prog only when psock->eval is __SK_NONE. The code that resets psock->eval is after the switch statement, but the __SK_DROP branch returns before that code. Then sendmsg() drops all subsequent messages with -EACCES and does not run the prog. Reset psock->eval when apply_bytes is 0, as the __SK_REDIRECT branch does. Fixes: 4f738adba30a ("bpf: create tcp_bpf_ulp allowing BPF to monitor socket TX/RX data") Signed-off-by: Josef Bacik Signed-off-by: Alexei Starovoitov --- 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 8cf63a9e7fed..d90bcc911b36 100644 --- a/net/ipv4/tcp_bpf.c +++ b/net/ipv4/tcp_bpf.c @@ -509,6 +509,9 @@ static int tcp_bpf_send_verdict(struct sock *sk, struct sk_psock *psock, default: sk_msg_free(sk, msg); sk_msg_apply_bytes(psock, tosend); + /* The verdict holds for apply_bytes, not for ever */ + if (!psock->apply_bytes) + psock->eval = __SK_NONE; *copied -= (tosend + delta); return -EACCES; } -- 2.55.0