From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=91.218.175.87 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796222149; b=UcLOVhDCVrr26Np4NR6JXvSsP4TDkv0tKZZsc/CalNf8TGw/kuLDLMJQ7dVq1WZKDXE4 /pUflMUPZxZdhEYfmAz3QYSz4cwdkiUHHshxQypcRr6EfPwHYHwfcmwyevCWi68nyQfwJ Dxndc0Jp59EpkFZkc1/jCtSj3F/wrz2NtToyknf7IP40o4ClritkhChhH6Yjq4WenK67W X3Jf6EGhK8eIdYXOWfLp01rQNAgny76xMHFtyUfJG05gNm06vILUZDZhbNOcwBnkPON5I JRqNKTkj2E5g+6UH9zT4mVLWocVqZoZZKTYmx3w1EaZCxD1TB0Yi7sUwRJHaMgNEeTg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796222149; h=DMARC-Filter:X-Envelope-To:DKIM-Signature:X-Envelope-To:Received: X-Mizu-Trace-ID:X-Migadu-Flow:From:To:Cc:Subject:Date:Message-ID: X-Mailer:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding; bh=rv6riqI2QAkYKdfPpPaYBQDQtKSrQqICv+GTHYchjvw=; b=e1z+xwcCTT4Jle8bdWT93jOPiMlX6QMpSaoFQ/0c364MX/fmHW8xu/tx2deiDIVttOMe vEc+TcjvHEhCkYQv16vvybsDlXRXc8kHO95eSj0fw7LWOcc6yfbGMVq1lSHKlETH5BOLi mB8ma1CYMFVp6k03e+X9vau9P56rfyM2mts6NBqtnCbv5jJmTSbwsXDKspPH87klG2GAQ 8oNSgnlr95Yv+an7j/YLhtqLztF9qVt06QxISIoklmJI8jaPZi7v6O+0i+fO5W66sxN6m tLAraxYsX77oIqFg5CijsZVUwbo5CfSl1RSaRDaNSjBejCGI7uU/SWJmNZkouPPibxg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=u4bv3s1A; arc=none smtp.remote-ip=91.218.175.87 Received: from mta0.migadu.com (out-87.mta0.migadu.com [91.218.175.87]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4D8EE606A32F for ; Wed, 2 Dec 2026 14:35:48 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 4D8EE606A32F Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key, unprotected) header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=u4bv3s1A X-Envelope-To: netdev@vger.kernel.org DKIM-Signature: a=rsa-sha256; bh=GMi6MRJ88lQLP5bxD62+eQNCcHcehiIxU+cZd4/Z5rY=; c=simple/simple; d=linux.dev; h=from:to:subject:date:message-id:mime-version:content-type; s=key1; t=1796222147; v=1; x=1796826947; b=u4bv3s1AVhgzfBbY/Vpb3BXeufmvyXwiylOX1npv0ilQF7GJ/FqMubhBty4t6fEkC5WZWpn3 KJ3qSQZ4didtH4xDxcA+4osP02asad/guqykYDJuIrQbh5+q2YDvPqJQ+uH5PhbcEoG+4eWyIq0 q7mUHhhaZxdH1Odr4CuF9Qlk= X-Envelope-To: netdev@vger.kernel.org Received: by smtp.migadu.com with ESMTPS id bf407c7e1faee7fb; Wed, 02 Dec 2026 14:35:26 +0000 X-Mizu-Trace-ID: bf407c7e1faee7fb X-Migadu-Flow: FLOW_OUT From: Jiayuan Chen To: bpf@vger.kernel.org Cc: Jiayuan Chen , John Fastabend , Jakub Sitnicki , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Willem de Bruijn , Simon Horman , Kuniyuki Iwashima , Neal Cardwell , Andrii Nakryiko , Eduard Zingerman , Ihor Solodrai , Alexei Starovoitov , Daniel Borkmann , Kumar Kartikeya Dwivedi , Martin KaFai Lau , Song Liu , Yonghong Song , Jiri Olsa , Emil Tsalapatis , Shuah Khan , Sechang Lim , Michal Luczaj , Mattia Meleleo , Zijian Zhang , linux-kernel@vger.kernel.org, netdev@vger.kernel.org, linux-kselftest@vger.kernel.org Subject: [PATCH bpf v3 3/9] bpf, sockmap: Fix empty sk_msg queued by ingress redirect Date: Wed, 2 Dec 2026 22:30:42 +0800 Message-ID: <20261202143337.400831-4-jiayuan.chen@linux.dev> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20261202143337.400831-1-jiayuan.chen@linux.dev> References: <20261202143337.400831-1-jiayuan.chen@linux.dev> X-Mailing-List: netdev@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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