🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #10012

Re: [PATCH bpf v2 11/15] bpf, sockmap: Don't copy 0 bytes into a full cork

#10012
From: Jiayuan Chen
Date: Tue, 03 Nov 2026 01:41
31 lines
9982 bytes
On 11/2/26 3:21 PM, Alexei Starovoitov wrote:
> From: Chris Mason <mason@kernel.org>
>
> psock->cork is a ring. sk_msg_memcopy_from_iter() writes at sg.curr.
> sk_msg_alloc() adds room at sg.end, where a full ring has a spare element.
>
> When only a part of the data fits, tcp_bpf_sendmsg() copies this part and
> flushes the cork. If nothing fits, it copies 0 bytes. This copy writes
> nothing, but it moves sg.curr to sg.end and returns -ENOSPC. Thus sendmsg()
> fails without a flush. sg.curr stays at sg.end, and from there a copy moves
> it past the spare element. Then a copy can skip the first new element, and
> the peer gets memory that nobody wrote.
>
> Skip the copy when sk_msg_alloc() adds nothing, as tls_sw_sendmsg_locked()
> does. This pass of the loop flushes the cork. The flush empties the element
> at sg.curr, thus the copy in the next pass starts at the first new element.
> Now sendmsg() on a full cork does not fail with ENOSPC. The prog runs on
> less data than it wants to cork, as it does when a part fits.
>
> The first Fixes tag is for the -ENOSPC without a flush. The commit in the
> second tag added the spare element. Since then sg.curr can move past it.
>
> Fixes: 604326b41a6f ("bpf, sockmap: convert to generic sk_msg interface")
> Fixes: 031097d9e079 ("net: skmsg: fix TLS 1.3 crash with full sk_msg")
> 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: <f64dd211-6449-4522-92e2-af1d5f238f73@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-355146-linux-kernel-netdev=dewy.ru
References: <20261102072112.4160195-1-alexei.starovoitov@gmail.com> <20261102072112.4160195-12-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-355146-linux-kernel-netdev=dewy.ru
From: jiayuan.chen@linux.dev (Jiayuan Chen)
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH bpf v2 11/15] bpf, sockmap: Don't copy 0 bytes into a full
 cork
Date: Tue, 3 Nov 2026 09:41:52 +0800
Organization: Usenet Network
Message-ID: <f64dd211-6449-4522-92e2-af1d5f238f73@linux.dev>
References: <20261102072112.4160195-1-alexei.starovoitov@gmail.com>
 <20261102072112.4160195-12-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="3074622"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:n99Af2n5ijeVJ7Vc2x31qboAOUQ= sha256:aHQVi0L+u1HyhGmJRZJIkvYgeZ2lRY//BDwz/EPOZrQ=
	sha1:yIJKvN1B7Q3QGbSsZvSutFWm2gE= sha256:GPKLRnyfUN2Djz6lvyInQyPWMJ36FFUJdZXyY2Np40Y=
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 5D2EC1126F6; Tue,  3 Nov 2026 04:42:25 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -2.151
X-Spam-Status: No, score=-2.151 tagged_above=-9999 required=6.31
	tests=[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 UiHWOh-8FBHN;
	Tue,  3 Nov 2026 04:42:17 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.232.135.74; helo=sto.lore.kernel.org; envelope-from=netdev+bounces-355146-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 sto.lore.kernel.org (sto.lore.kernel.org [172.232.135.74])
	by mail.dewy.ru (Postfix) with ESMTPS id 0D7CF111D53; Tue,  3 Nov 2026 04:42:08 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by sto.lore.kernel.org (Postfix) with ESMTP id 25363601922; Tue,  3 Nov 2026 01:42:07 +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=1793670124;
	b=J2OAsdAA/CHzrrJQHyywCJQZpNx2KIREx7GkqdnIQcKnYVmfbv8pDYVdhi+qMiv71Cdu
	 DNeJJdAMyI3GsDaGCZLcwDE6ANjW4p1ToJXgflNTV0kQsTwATuLV9XV446V32GGzrmll/
	 IIPgbj3RZCQZzH9Wq6LDImuDAg1+Nf1RSCBL61wEdcFi+v1+Jzo8OFAsRx+1HCBy3hk4t
	 ATi4CngwjEnKHKk8iJr/5zaiwYQ2pmyfQ4vNagPYeBSPUyXQ2ciBhT0mG8s16en3iv17d
	 Z8NkVMLVLdVsyNK63FW3/YCzoAY7yYxjpOI3f3X5I1aR1V84A7NiJQbLgzlpwdUbUwA==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1793670124;
	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=dGnaZBUj0XNcB11772fHKRR4jnMCSTKoOZ96EtQkLP8=;
	b=NQqQmwFivdljey2EVinAZ7aI1hYQqx8vASz529tdVll55hKzIZAWZ4jQSXN1wUtxCGS1
	 PB9je2atJulnwPEiT+gMY8Gr/HPRZjtyHxaX+9vodc4wdU20LA+8+0vdnezuMVAOmIwpR
	 MVeRcPr4TbVavjtlTKZ1LaIqj6ARoQz9zRfZePj7MDX4Y5PNIFiDYDs/hMTOpHtqVPRw/
	 DlnP7fkTuZ9Ec2nKhQ0ReXuU0NUii4PL8jTWfjD2LaiX1kKrDCceiBNB3qoA5W7n64/Fo
	 ANQmjkWU239tBU6qfigttj3lEM9kxrzdSkcmDy6kBWiUZRZINVi538E+L62NTYesicg==
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=fKH70yEb;
	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 B1767606A334;
	Tue,  3 Nov 2026 01:42:04 +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=fKH70yEb
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=91.218.175.235
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1793670123;
	b=Vf5/G5xi26ywkOEnH35eB5x01WnP6bXK1MHtUdBdgTPd3zwX1V3xEc9JbnlgEfhDbUG8
	 uQm4rorkbMKq55vOR8WQTH2I/wIROZ2ujAsbcb5WLSRd2Yc5snVY4P824CikDupugaQNe
	 GGRI0TjEBhsq7mAr9f3FJZnFKb+RuCZrUvoaRJzQb8G803mPSJ747qJM9tZCZbo6mbv6b
	 rek2cVwdX19jHilGhTu69BFek0tXkkwgOQIa1+eeQ60uPXbC9VYaMr4+GbyPikmhfV2pd
	 VQig3h5+XfWaantTkfyZein3WfSi1RwuILZvWagf1zUkXwymlPSOncx7A4qJzD0hnSw==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1793670123;
	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=dGnaZBUj0XNcB11772fHKRR4jnMCSTKoOZ96EtQkLP8=;
	b=QGm9t4D8eAbTLxdNMwDQDlVXwNOcmirwR5h7oFb6sj9l2Jpg2ZLZhO1YbqhaiE20wJb0
	 yeWWEfANZzij6w0GIw7G25PaxmMs52Uzrkpz7vIqv3tyAVmhz4u/9mvpW4asMy0aMk7r3
	 G8NOkBPkFVhGu3BPAp4SWVPkLDMZ8ZWTIaYcQaq/D5K6TNj5jprt66PxtbDPh5ud/ZWzU
	 aYv18NEbdg1F9INz+Vmo6G5rpeG/Ph3ljG+/4PG+n2Vkb2cEwsyMIKgfSPP5KTmpOZADG
	 gmz5PV/LkK59TIly8HZb0ty5BRro/GlZz1k8RRNGr2OVjGpYUaZszvDJUkmxAjEM3pw==
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=fKH70yEb;
	arc=none smtp.remote-ip=91.218.175.235
X-Received: from mta0.migadu.com (out-235.mta0.migadu.com [91.218.175.235])
	(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 F39DD606A324
	for <netdev@vger.kernel.org>; Tue,  3 Nov 2026 01:42:02 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org F39DD606A324
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=dGnaZBUj0XNcB11772fHKRR4jnMCSTKoOZ96EtQkLP8=;
 c=simple/simple; d=linux.dev;
 h=from:to:subject:date:message-id:mime-version:content-type; s=key1;
 t=1793670121; v=1; x=1794274921;
 b=fKH70yEbYDywQGAwgfKSS+FjmYqpdNjx/QAS6L7HT/xmTPtjFKacyw2MbKh0akpklTS9OHgd
 koVAORicRuRu3tQLsfJU9vw1xGIoAAdyPRjlLZcrpLoB9v3kYqa4Gj0jnTKUox/RvMJ0oLPNMh6
 k8yttt+zw5PAe78xF3bDXib8=
X-Envelope-To: netdev@vger.kernel.org
X-Received: by smtp.migadu.com with ESMTPS id 4aed7de82dbe24fe;
	Tue, 03 Nov 2026 01:42:01 +0000
X-Mizu-Trace-ID: 4aed7de82dbe24fe
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-12-alexei.starovoitov@gmail.com>