tcp_bpf_send_verdict() loops as long as msg has data left, sending at
most apply_bytes per round and running the SK_MSG program again when
apply_bytes is used up. A program that pushes at least as many bytes
as it applies, e.g. an 8-byte header with apply_bytes 8, keeps msg from
ever draining. With a redirect to a socket that keeps reading, send()
never returns and the task ignores SIGKILL.
Free the rest of msg and return -EINTR when a fatal signal is pending,
as the push error path does.
Fixes: 6fff607e2f14 ("bpf: sk_msg program helper bpf_msg_push_data")
Signed-off-by: Sechang Lim <rhkr…@gmail.com>
---
net/ipv4/tcp_bpf.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/net/ipv4/tcp_bpf.c b/net/ipv4/tcp_bpf.c
index 788ce08eef4d..f62c3238c300 100644
--- a/net/ipv4/tcp_bpf.c
+++ b/net/ipv4/tcp_bpf.c
@@ -580,8 +580,13 @@ static int tcp_bpf_send_verdict(struct sock *sk, struct sk_psock *psock,
}
if (msg &&
msg->sg.data[msg->sg.start].page_link &&
- msg->sg.data[msg->sg.start].length)
+ msg->sg.data[msg->sg.start].length) {
+ if (fatal_signal_pending(current)) {
+ *copied -= sk_msg_free(sk, msg);
+ return -EINTR;
+ }
goto more_data;
+ }
}
return ret;
}
--
2.56.1