Netdev List
 help / color / mirror / Atom feed
From: Sechang Lim <rhkrqnwk98@gmail.com>
To: bpf@vger.kernel.org
Cc: netdev@vger.kernel.org, john.fastabend@gmail.com,
	jakub@cloudflare.com, jiayuan.chen@linux.dev,
	edumazet@kernel.org, ncardwell@google.com, kuniyu@google.com,
	davem@davemloft.net, kuba@kernel.org, pabeni@redhat.com,
	willemb@google.com, horms@kernel.org, daniel@iogearbox.net
Subject: [PATCH bpf] bpf, sockmap: Stop the sk_msg verdict loop on a fatal signal
Date: Mon, 30 Nov 2026 11:34:46 +0000	[thread overview]
Message-ID: <20261130113448.1325369-1-rhkrqnwk98@gmail.com> (raw)

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 <rhkrqnwk98@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


                 reply	other threads:[~2026-11-30 11:34 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261130113448.1325369-1-rhkrqnwk98@gmail.com \
    --to=rhkrqnwk98@gmail.com \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=davem@davemloft.net \
    --cc=edumazet@kernel.org \
    --cc=horms@kernel.org \
    --cc=jakub@cloudflare.com \
    --cc=jiayuan.chen@linux.dev \
    --cc=john.fastabend@gmail.com \
    --cc=kuba@kernel.org \
    --cc=kuniyu@google.com \
    --cc=ncardwell@google.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=willemb@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox