Article View: linux.kernel.netdev
Article #9336Re: [PATCH bpf 02/15] bpf, sockmap: Don't let an SK_DROP verdict stick
From: bot+bpf-ci
Date: Sun, 01 Nov 2026 19:39
Date: Sun, 01 Nov 2026 19:39
71 lines
10915 bytes
10915 bytes
--===============0240678656479494321==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
> bpf, sockmap: Don't let an SK_DROP verdict stick
TL;DR: Resetting eval after an SK_DROP verdict may make sendmsg() return a
positive byte count instead of -EACCES for every dropped message; the fix is a
later patch, so should they be applied together?
> 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;
> }
Now that an exhausted SK_DROP verdict resets psock->eval, the prog runs again
for each later message. Does that make an older accounting problem in this
branch happen on every message instead of once per socket?
sk_msg_free(sk, msg) frees the whole message, but only tosend is subtracted
from *copied, and tosend is capped to psock->apply_bytes:
tosend = msg->sg.size;
if (psock->apply_bytes && psock->apply_bytes < tosend)
tosend = psock->apply_bytes;
Take a prog that calls bpf_msg_apply_bytes(msg, A) and returns SK_DROP, and a
sender whose sendmsg() calls each carry S > A bytes in one sk_msg.
Before this patch:
- call 1 ran the prog (apply_bytes = A), set tosend = A and returned S - A;
- eval then stayed __SK_DROP with apply_bytes = 0, so calls 2..N used
tosend = S, *copied went to 0, and tcp_bpf_sendmsg() returned -EACCES.
After this patch, eval is reset once apply_bytes reaches 0. Every later call
runs sk_psock_msg_verdict() again, which sets psock->apply_bytes =
msg->apply_bytes = A, so tosend = A again. Every sendmsg() then returns
S - A > 0 even though all S bytes were freed and none were sent. Userspace
sees partial success on each message instead of -EACCES.
The subtraction itself predates this patch. The sticky verdict hid it after
the first message, and this change exposes it on every message. A backport
of this commit alone would change sendmsg() return values from -EACCES to
positive byte counts for such progs.
A later patch in this series, f54ec6a22738 ("bpf, sockmap: Subtract all
dropped bytes from the return value"), fixes this by subtracting the return
value of sk_msg_free() plus delta instead of tosend + delta.
Should the two patches be applied (and backported) together?
---
AI reviewed your patch. Please fix the bug or email reply why it's not a bug.
See: https://github.com/kernel-patches/vmtest/blob/master/ci/claude/README.md
CI run summary: https://github.com/kernel-patches/bpf/actions/runs/41341848185
--===============0240678656479494321==--
Technical Details
Message-ID:
<0dd29e75d62b7190a9808444743fc5dcebd3fd42ebff15602c7eef5a9313784f@mail.kernel.org>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-354317-linux-kernel-netdev=dewy.ruReferences:
<20261101192057.2296489-3-alexei.starovoitov@gmail.com>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-354317-linux-kernel-netdev=dewy.ru From: bot+bpf-ci@kernel.org Newsgroups: linux.kernel.netdev Subject: Re: [PATCH bpf 02/15] bpf, sockmap: Don't let an SK_DROP verdict stick Date: Sun, 1 Nov 2026 19:39:09 +0000 (UTC) Organization: Usenet Network Message-ID: <0dd29e75d62b7190a9808444743fc5dcebd3fd42ebff15602c7eef5a9313784f@mail.kernel.org> References: <20261101192057.2296489-3-alexei.starovoitov@gmail.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="===============0240678656479494321==" Injection-Info: usenet.network; logging-data="2752622"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:9NjUW6tQWnzKBeRqC0LQ0FzI0p0= sha256:OYr8ltP84qtcqOPkin9wcdhp2U8gR6XPwaQoIACVJEU= sha1:wo2KOJvbYAsdY8wW3GFkj2gc1wo= sha256:ATMgR21RzFjc2W2xKN6MRp/phNplbJun4j1pxwm/qU8= List-ID: <netdev.vger.kernel.org> X-Mailpost-Empty-Hdrs: X-Spam-Level X-Received: from localhost (localhost [127.0.0.1]) by mail.dewy.ru (Postfix) with ESMTP id 0111911237E; Sun, 1 Nov 2026 22:39:32 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.401 X-Spam-Status: No, score=-3.401 tagged_above=-9999 required=6.31 tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001] autolearn=ham autolearn_force=no X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key) header.d=kernel.org X-Received: from mail.dewy.ru ([127.0.0.1]) by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id q7Q2ujDs9PYj; Sun, 1 Nov 2026 22:39:28 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-354317-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org X-Received: from tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114]) by mail.dewy.ru (Postfix) with ESMTPS id 96702112378; Sun, 1 Nov 2026 22:39:19 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by tor.lore.kernel.org (Postfix) with ESMTP id EE5EB25F76; Sun, 1 Nov 2026 19:39:16 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1793561956; b=JWMWi+YdGULV+irB8IQHDp6nUdhjzIuZWldSdY9F1h1WWpvgb/q/xdRUFyMz25OPucKF UIUa2LS66kOOlW/939gByLUl6t/YMRFMz5+fI7TVERMzwm8QCRgq9dAPdUrhT7mRwWZTl QVBrUvOHJuExjabHC1M3e5dDQDGO2QvM6IqtbQUOPVWk6OC5p6gzBlkLwv4CR01v4zSAe E4Ph5T5nSAaEt1xnQYbQfnvUK/1BhrWZzD1jCQmLu36thcZTFGE6Zd0DybYa5owKdPfH5 /PNKcLgfg4t3nqSajgJbLHl5eLRETUEleepd6txWBK74uc3Iyy51ox88vOYypyzcXlg== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1793561956; h=X-Original-To:Received:Received:DKIM-Signature:Content-Type: X-Mailing-List:List-Id:List-Post:List-Help:List-Subscribe: List-Unsubscribe:List-Owner:Precedence:MIME-Version:Message-Id: In-Reply-To:References:Subject:From:To:Cc:Date; bh=eFd6KOabnWiebFmLCAzscPfD6b0ZJ8Xt/eedBcDRnj0=; b=Jeamt8/faAylXI//uHaU3Qj2In21I9d80KBFEVPrx/0/GOWNlouMe6MnevvS5paUtzBy yLP1LDVMp04eiIL3aH8N/QiFJOGNdEIKDaZx62OeTyb81YUd38SEEgxDbkCGuGskMUbHv OqxsIV3NzusdELhGVpTQWQFXnaAXXvHBKS5+MRQTQ5cOOTK3ECmLTEnoDqHK9T5017MWf N0JEGPuEn87N26iaeMHfdm1nBlB5h2f4x39EOT/1ZDkC1d+r0s/5Q4ckQqaK/tjDg4mlS jnL6VdILM+eZUuvTTWM0va5XfkIdm4OfSizl484KOEDiBEBaVhxvwbJOESLD1WUVHeQ== X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=n1h8NX4d; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B2319606A331; Sun, 1 Nov 2026 19:39:16 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=n1h8NX4d X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1793561950; b=WFAV/K+y8I3BurFnpka3eFON9RMGWsmDlzRDDvRBjaSAf64ibnZO4T5/hcot9nmYxN3E wJdxogS0r5eaibaqqye1mjGUvxEVizMp0G+2y6OGeHm6uYe7tlYNPTOXzLpiBqU21PRFV tQqBJYo5vKUm//Lg8RzC9QmGRxQ9g2Vq8ghikSD4814wsZW+6X7I6uD8TM+7dtVxIAe4c DLRqDIhJInp9TFc9nUumW5u2+hn6DpXwdyMXg2ylRoFOycGyfD9Klt109/DffFe0a//u2 shsUxam34IxvazmPS5rpS5KDHPyDHYj/tM6RQAhJ6RbzPsVTC6OQTlb5j9Yi2hCRVZw== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1793561950; h=Received:DKIM-Signature:Content-Type:MIME-Version:Message-Id: In-Reply-To:References:Subject:From:To:Cc:Date; bh=eFd6KOabnWiebFmLCAzscPfD6b0ZJ8Xt/eedBcDRnj0=; b=gYWK8qcJcOUWctdNE7zNS9j+8YN25hPP576xYBQ/uiJV5hQENNaUFi77RsNMfXVSWRSc ogxISmvnDeV4o3Zw4tZUQvx1j0QWYk3yUCS6d3QxU0pTCD0QC3i6ILmnfJU8jP0+KSrwp DVuE8hPwk9CRUEuPFtRKnrrs5rPdwAv4Ek3hQMBlEUA3IKtU6ad88VC2TpWP3AlmoVm9b rpWzSeykNlUJ/wVcE9y82kU9EUymvupudmMzzKiB5hFShNEFA373q9d0Pl/qRxqdDs2pa +5eqCLsWFmbw6UXFc9E7VOLe2e3nzY8iKM2+2a+M73uybuEP1u0xu5ef736uLNWRVHg== X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=n1h8NX4d; arc=none smtp.remote-ip=100.103.45.18 X-Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8F7D3606A329; Sun, 1 Nov 2026 19:39:10 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id AF5601F00A02; Sun, 1 Nov 2026 19:39:09 +0000 (UTC) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1793561950; bh=eFd6KOabnWiebFmLCAzscPfD6b0ZJ8Xt/eedBcDRnj0=; h=In-Reply-To:References:Subject:From:To:Cc:Date; b=n1h8NX4dijMw7k2N+JR33AFofCYVC62ewcoFeKBQJKIZRJkJ6JzhEC//C3fhD6PMS XRxmBDH/UZzZs4FrEz3a2pDWa7ChswGMeZgplXJnBd+/x1YpN6xIfZxTRGYwtLidD2 jJNq1AuijIwgJ/1YvXrbOsTePXHm1muj9Bu0MAHy1R9Z6gCr2bpPkrDIqBApASH0cB OF+631UAex3bUZ2wurH/Kga5hmMXLC7LaM8DKaS/gG82kyzO6/vqiB4zkgiZEVXy7k sXOlh5z3wrb6xvMCOVDLOSGDHpwy++YHUS8aJQYe+QobDMRSkhrAb9lMVc0qk2w6PC cB/M8C1mxqTag== X-Mailing-List: netdev@vger.kernel.org X-List-Post: <mailto:netdev@vger.kernel.org> X-List-Help: <mailto:netdev+help@vger.kernel.org> X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org> X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org> X-List-Owner: <mailto:netdev+owner@vger.kernel.org> X-Precedence: list X-In-Reply-To: <20261101192057.2296489-3-alexei.starovoitov@gmail.com> X-Cc: daniel@iogearbox.net,andrii@kernel.org,eddyz87@gmail.com,memxor@gmail.com,john.fastabend@gmail.com,jakub@cloudflare.com,jiayuan.chen@linux.dev,davem@davemloft.net,edumazet@kernel.org,kuba@kernel.org,pabeni@redhat.com,horms@kernel.org,kuniyu@google.com,willemb@google.com,matttbe@kernel.org,mptcp@lists.linux.dev,mason@kernel.org,josef@toxicpanda.com,ast@kernel.org,andrii@kernel.org,daniel@iogearbox.net,martin.lau@kernel.org,eddyz87@gmail.com,yonghong.song@linux.dev,mason@kernel.org,ihor.solodrai@linux.dev