Article View: linux.kernel.netdev
Article #10011Re: [PATCH bpf v2 10/15] bpf, sockmap: Reset the copy position when corking
From: Jiayuan Chen
Date: Tue, 03 Nov 2026 01:39
Date: Tue, 03 Nov 2026 01:39
27 lines
9687 bytes
9687 bytes
On 11/2/26 3:21 PM, Alexei Starovoitov wrote:
> From: Chris Mason <mason@kernel.org>
>
> sk_msg_memcopy_from_iter() writes to the copy position: byte sg.copybreak
> after the offset of element sg.curr. Both tcp_bpf_push() and sk_msg_xfer()
> remove bytes from the front of an element. They increase its offset, but
> they do not change sg.copybreak when the element is sg.curr.
>
> tcp_bpf_send_verdict() can send a part of a message and keep the rest as
> the cork. tcp_bpf_sendmsg() appends new data to it. If sk_msg_alloc() then
> extends element sg.curr, the peer can get memory that nobody wrote:
>
> old offset offset end of data offset + sg.copybreak
> | removed | rest | not written | new data
>
> Move sk_msg_reset_curr() from filter.c to skmsg.h. Call it when a message
> becomes the cork, as the helpers that change a message do. It sets the copy
> position to the end of the data. Without removed bytes it changes nothing.
>
> Fixes: 91843d540a13 ("bpf: sockmap, add msg_cork_bytes() helper")
> Signed-off-by: Chris Mason <mason@kernel.org>
> Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Reviewed-by: Jiayuan Chen <jiayuan.chen@linux.dev>
Technical Details
Message-ID:
<c5a1ce12-2c0c-489b-840b-1cef8cda999c@linux.dev>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-355145-linux-kernel-netdev=dewy.ruReferences:
<20261102072112.4160195-1-alexei.starovoitov@gmail.com> <20261102072112.4160195-11-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-355145-linux-kernel-netdev=dewy.ru From: jiayuan.chen@linux.dev (Jiayuan Chen) Newsgroups: linux.kernel.netdev Subject: Re: [PATCH bpf v2 10/15] bpf, sockmap: Reset the copy position when corking Date: Tue, 3 Nov 2026 09:39:04 +0800 Organization: Usenet Network Message-ID: <c5a1ce12-2c0c-489b-840b-1cef8cda999c@linux.dev> References: <20261102072112.4160195-1-alexei.starovoitov@gmail.com> <20261102072112.4160195-11-alexei.starovoitov@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Injection-Info: usenet.network; logging-data="3073751"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:UHH6BMXiKLWqYjn/9MOmxCQ11tY= sha256:FOypg3WWd+OFLAluruOu7pW4pCyw9VnkKvTmw3y1O48= sha1:Cqp0DS43zopRfzW73uEFA+dLe9o= sha256:zQvfv0QkT/cInyc79qvVYk6Pz6PETEgtV1TZTppIcsA= 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 C7E171126F5; Tue, 3 Nov 2026 04:39:39 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -2.051 X-Spam-Status: No, score=-2.051 tagged_above=-9999 required=6.31 tests=[DCC_REPUT_70_89=0.1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, HEADER_FROM_DIFFERENT_DOMAINS=0.249, HK_RANDOM_FROM=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 (1024-bit key) header.d=linux.dev 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 N4y-ST3oD3Xq; Tue, 3 Nov 2026 04:39:35 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-355145-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=linux.dev X-Received: from tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114]) by mail.dewy.ru (Postfix) with ESMTPS id E6A2E1126F3; Tue, 3 Nov 2026 04:39:25 +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 4EAFF28E40; Tue, 3 Nov 2026 01:39:19 +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=1793669958; b=rggnFeoAzLJRlZBc22/xrGwwn4n3EBSEYCRcfu8MaQMyBm6H2+2oc3rGqR4xrvYocVsx ssH2qHrkmd/lH9L61iCO/BXG+RerUz9qzEVzOYEP9xJAiP+/SzpwfSTfO2Gg8Gk5s48Y4 W3NScvtaljgHcErGoC3r/i0yOkIC/ng7ciNaZA4LJyJMftPkCciA/oP0RPe/+JFUUmZsS m9EiWUSEQNIxGm++aOIhPTpsda0xORmAYPIlrcbNgf0jAMmolKbRzurmw37CEJqtGhsvP 2ak14G+ogtokVkNeJLXLngruFQERhUakdImWde04hWTM4Jxzncz7Ud9Y/+hlo5wxCWw== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1793669958; h=X-Original-To:Received:DMARC-Filter:X-Envelope-To:DKIM-Signature: X-Envelope-To:Received:X-Mizu-Trace-ID:X-Migadu-Flow:Message-ID:Date: X-Mailing-List:List-Id:List-Post:List-Help:List-Subscribe: List-Unsubscribe:List-Owner:Precedence:MIME-Version:User-Agent: Subject:To:Cc:References:From:In-Reply-To:Content-Type: Content-Transfer-Encoding; bh=HOxjTWq8USRbKf1NHRtOCVdwPDHFFHRlSbuWNNCvU8A=; b=cxwzzwLYYPrzOr8A6sF15hPCOwRFatA/kOX1QBq2PfHJJs51INZB6BdiyEPreq0OCRea TN/bI6ATUkHoS1rLxXFyRF4EcG66wzvlU19YNJlVWP+G3JdVFIPTzOFhu05eZflFeUZG8 I/HdifByzNcKIl7f5MxzXdVu/pMa2P1dM6er5kLFD9ycV3Nw1jk4AN2xpfVQbyx5oRDDZ AvOCZ3mJDGUEc3YDoQgIXYzvCQTzaE9vNM3wLfe3qxCYsrLZSJ8aCFJ9823lXj2aedzUl bjoLhseadft/7T66HgyobMmZx123jtbbdT/+Sh/Q9Ao0FTUdnfvYm3f5j6eJbSfofcw== X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=uDfYp4CI; dmarc=pass header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; 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 3A69D606A332; Tue, 3 Nov 2026 01:39:18 +0000 (UTC) X-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=uDfYp4CI X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=95.215.58.192 X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1793669957; b=FAQdXY5xmSjwhWq7H7Jlg+XqO9nvsVxgMl9abQrtuHrD9S26xI8Kz2dbuZgyJFwclwXR GjV7NpRkXmaLAfMVS86ho/Fe83DK7Jn8B6mAOEw4xS1sHmOLT91fZS5Gt4oKhjE+uuVDJ G4Jk0YIeINWjg80liqqXKoAy0mRVqWfu8RAVftHorB2Mx1T4GpUGFNxns9s0CuJoVGmKd 7gakDoaQ79EJsnX3DdKonAHnHCpUlhktWb+X1XfXj/ISEdIs7g5+mVfMyC5jJz7FJVJc6 rdJVz0/FP4/RPJwdxY948uTHAH0KzWUhta1kK9SBw9suJbCOF2sKWgzkfpdUXEgvItw== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1793669957; h=DMARC-Filter:X-Envelope-To:DKIM-Signature:X-Envelope-To:Received: X-Mizu-Trace-ID:X-Migadu-Flow:Message-ID:Date:MIME-Version:User-Agent: Subject:To:Cc:References:From:In-Reply-To:Content-Type: Content-Transfer-Encoding; bh=HOxjTWq8USRbKf1NHRtOCVdwPDHFFHRlSbuWNNCvU8A=; b=UHhp49MQFwhHXMT7xgkw1F8CpsEMpl8q07IvZQL3RcEoyww/RU8c/fk5F9yujZszqy3L p32X9qZOLLy0WzIqidtO28tqfqQ2N16G8jbdbAYx4mi/+Ux4AXaNe/gT1xHm/VvYSSV2U cn6YaFEyp0W0hxTdSCHN0kz84iBpYvTNgmSr0bCeECADf0QdqlB7Ep+FnCrcxnvo5fMka B7ti7ak87XM5cyNxK88aLP2s+wgQKGfwhVovv0kvdxTuKuNgl40zJ+O4Tz2Yx53QVmrC6 1Hu2XxdxQ9s7lgaeJ9UFVjd1I264PWRJBhhorrXHHbilp5UdMP0h7jHhlNClqJYpbqw== X-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=uDfYp4CI; arc=none smtp.remote-ip=95.215.58.192 X-Received: from mta1.migadu.com (out-192.mta1.migadu.com [95.215.58.192]) (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 20E66606A327 for <netdev@vger.kernel.org>; Tue, 3 Nov 2026 01:39:15 +0000 (UTC) X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 20E66606A327 X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev X-Envelope-To: netdev@vger.kernel.org X-DKIM-Signature: a=rsa-sha256; bh=HNSCS4mk/qPWR2K35tmQ3WR1yx22JuOv+/Tg+3LgkOQ=; c=simple/simple; d=linux.dev; h=from:to:subject:date:message-id:mime-version:content-type; s=key1; t=1793669952; v=1; x=1794274752; b=uDfYp4CIMXMT0YXcKpjF9YB3K5YdgLBw4c88NqUHwD/Lclmvn3GyDF3AeYlSAKjVzlZUoafv eeyU7b2yNVBPf6u3Uom/s9NH6qbZ1pAgOagbIhnxVGqmo6ypScxjhm6RO97oPf3OANgiusJem7v XjHbBbnFksp3s1WmK6Yr2+eM= X-Envelope-To: netdev@vger.kernel.org X-Received: by smtp.migadu.com with ESMTPS id 6da7c6571af7a7ce; Tue, 03 Nov 2026 01:39:11 +0000 X-Mizu-Trace-ID: 6da7c6571af7a7ce X-Migadu-Flow: FLOW_OUT 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-User-Agent: Mozilla Thunderbird X-Cc: daniel@iogearbox.net, andrii@kernel.org, eddyz87@gmail.com, memxor@gmail.com, john.fastabend@gmail.com, jakub@cloudflare.com, 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 X-In-Reply-To: <20261102072112.4160195-11-alexei.starovoitov@gmail.com>