🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #6391

Re: [PATCH] bpf, sockmap: Propagate sk_msg_memcopy_from_iter error code

#6391
From: Jiayuan Chen
Date: Thu, 22 Oct 2026 10:07
46 lines
10314 bytes
On 10/22/26 5:58 PM, Rui Qi wrote:
> tcp_bpf_sendmsg() stores the return value of sk_msg_memcopy_from_iter()
> in a local variable "ret" and jumps to out_err on failure, but never
> copies that value into "err".  The "err" variable therefore keeps
> whatever it held before the copy: 0 on the normal allocation path, or
> the stale -ENOSPC left behind by a partial sk_msg_alloc().
>
> On the first loop iteration "copied" is still 0, so the function
> returns "copied > 0 ? copied : err" -- 0 on the normal path and the
> stale -ENOSPC on the partial-allocation path -- instead of the real
> error such as -EFAULT.  A blocking sendmsg() handed data but returning
> 0 with no errno can drive userspace into a busy retry loop or be taken
> for a successful short write, and the wrong errno misleads recovery on
> the other path.
>
> Propagate the memcopy failure so the real errno reaches userspace,
> consistent with every other out_err path in the function.
>
> Fixes: 5153a75ef34b ("tcp_bpf: Fix copied value in tcp_bpf_sendmsg")
> Signed-off-by: Rui Qi <qirui.001@bytedance.com>
> ---
>   net/ipv4/tcp_bpf.c | 1 +
>   1 file changed, 1 insertion(+)
>
> diff --git a/net/ipv4/tcp_bpf.c b/net/ipv4/tcp_bpf.c
> index 97541acb3cce..8cf63a9e7fed 100644
> --- a/net/ipv4/tcp_bpf.c
> +++ b/net/ipv4/tcp_bpf.c
> @@ -578,6 +578,7 @@ static int tcp_bpf_sendmsg(struct sock *sk, struct msghdr *msg, size_t size)
>   					       copy);
>   		if (ret < 0) {
>   			sk_msg_trim(sk, msg_tx, osize);
> +			err = ret;
>   			goto out_err;
>   		}
>   


Thanks for your report but it has been fixed.

https://lore.kernel.org/netdev/20261019082214.102398-1-dmantipov@yandex.ru/


pw-bot: cr
Technical Details
Message-ID: <677e01d0-6226-4670-a4d5-8900f8a88cde@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-350498-linux-kernel-netdev=dewy.ru
References: <20261022095853.1829161-1-qirui.001@bytedance.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-350498-linux-kernel-netdev=dewy.ru
From: jiayuan.chen@linux.dev (Jiayuan Chen)
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH] bpf, sockmap: Propagate sk_msg_memcopy_from_iter error
 code
Date: Thu, 22 Oct 2026 18:07:04 +0800
Organization: Usenet Network
Message-ID: <677e01d0-6226-4670-a4d5-8900f8a88cde@linux.dev>
References: <20261022095853.1829161-1-qirui.001@bytedance.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Info: usenet.network;
	logging-data="184647"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:lCbZRx72h6blu0yMfhkNF1ORskc= sha256:6T1OuUiT2hYXBj+2c0VLSRJjvrTdSMPhJ4tP81cWFc8=
	sha1:1J0PlRQYl3CYlx80uyOPkFhYEeg= sha256:HSbT1Qve0N+czbkBQJbi7yv9ylP0BocoWGKgFSdL0m0=
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 9939C111234; Thu, 22 Oct 2026 13:13:28 +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.25,
	HK_RANDOM_FROM=0.999, 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 MYIPTk1wM7l9;
	Thu, 22 Oct 2026 13:13:25 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-350498-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 sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])
	by mail.dewy.ru (Postfix) with ESMTPS id A4F341111F4; Thu, 22 Oct 2026 13:13:15 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by sea.lore.kernel.org (Postfix) with ESMTP id 116843BC08; Thu, 22 Oct 2026 10:07:20 +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=1792663639;
	b=OIycT80uMeWzscSL6OWEUW9tTZLzxO4W6wcjSFuueBp4L2UAoRl8fScv5oDxf0VoOfAn
	 5e7xqNoKG1uCTQvRlPCwRac+a23slV9ctj4zHUUU+9ctFNnAEoqWT+w6NrGp+Nl/ubmVt
	 GVt3ec8LGFA0lNR93yP2+oLz114ylBlzDHe0yj9QFuKG/mXkZsHK8eyLU6iHQgx/bP6Yc
	 Z9sccSL3CnzVU59sagMrqQsj9er9PBEKp2pxNcPXzVDykifL8qMZ57DHL7yFLfm4W3iL0
	 lnVkQpZGuTbMIPIeY1kNdy0sOOt1QUOoiK8ZDLAIW+fvN3XnNChBkYzB4gbs5Xtc3vQ==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1792663639;
	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=Ll4SV3bdtwckm24BNpifgTpXaQLWXCqLJuIxLlH5XTc=;
	b=0RxfczfOp+ZZF/Vzn931/AKhG1TK9b0R6GLfqkJnMnYs9ziBnXcGx3iaIeV29VR4dGAc
	 Pm+yUUBzmDIEqDRae3hampZOZywIFaAgQdNo1K7/hBVf3JsEYkzEr3jp1sr5F4PulaxTw
	 OxnZEJG2OacC8nyAQD4TMSIAGgzNstV53013nVZnOo+j+p0mBCnj7QYBZBQjPx6I0R9wf
	 HtW/X2yyOcVUnU7UxF7N7jh70LNcglI1AKFC5Sog4orofw6gruFlbbdLmIBt7GQriP6U0
	 h4ZvkMtI/jUrMnPNuO2diE3TURR85DglRRvcfAr24rW7OqQOkHwR4FCtBk7Mas8fkMA==
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=UiVFB9BP;
	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 D432D606A33E;
	Thu, 22 Oct 2026 10:07:19 +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=UiVFB9BP
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=95.215.58.52
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1792663639;
	b=l7jkT3W2HFs7DSfUmDwhw8WWQvk6BASHOG7NorB93UKFW0PB1CSRxjVMgIoN3Gj4NI+6
	 J426uEB2WBqVXOj2Q4VdNUNf5eCvigV2oF772O+iscAe0hBMN7xohdXthZVr++D6UYJor
	 /8NKBR8KDuH16S4M6egLGiu8ticYFsNDTArxPAVB0UvDbzjnKRQ59iEup6CVyFEdnc5Pp
	 7I+or3shEqaHuAytfL4sb3o8+blLluTVKntKqQoRtmVw61XIpfRTVcD1ZdTzt310tNBPM
	 hAUYb2ViiwV6DdVBCW+pJbxRVSaY5sSMsAqpFEKFsbpZ/SLZ2ZtWzCrRWIecpTIa7ug==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1792663639;
	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=Ll4SV3bdtwckm24BNpifgTpXaQLWXCqLJuIxLlH5XTc=;
	b=wEQToudJlkv1KFnOJh+ikQJosuzthfiXLdqzLzdTqUlHulk5yhJp00ImKkEvPvQ0Mb4k
	 n+OZOKO+xTlZ9foq/yxaTuIlQScAt859R57B9rlkVVaEwUVZgIXtBRy1L+gfnJkIRz942
	 ddb0AwDvkpQ5NH3XSB7ohntCq/OAN+7dFq1R6t+2tee33n8r/9EYZ4tCk2PYJymbvZry9
	 VDI4uCacPYj3T6pd6taBucFVmeaLn3BaYHIsNjExffwDyspVO7ZJPB7cYulNhVH4/JZdc
	 BQOIX4494JCdmISvAzsrgyEBaJjoEaHQGcQXBDPQYBmOm66ABMlR56bJjgSEgVD4ijg==
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=UiVFB9BP;
	arc=none smtp.remote-ip=95.215.58.52
X-Received: from mta1.migadu.com (out-52.mta1.migadu.com [95.215.58.52])
	(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 0EF02606A323
	for <netdev@vger.kernel.org>; Thu, 22 Oct 2026 10:07:17 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 0EF02606A323
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=cUVZFAauvYfdrMN84AtZG9D1SbyolDZQ3ZjIcFK8qXg=;
 c=simple/simple; d=linux.dev;
 h=from:to:subject:date:message-id:mime-version:content-type; s=key1;
 t=1792663636; v=1; x=1793268436;
 b=UiVFB9BPDPcE4Dx3uDCvucjTrKhPfvN6NXrH/lVzcQ0i5Sl82+NlJyzQNtsaDE+FfrWv33zH
 mbF73QAU1rMPGi4hvqfzoCE1BI1tgcS9f9e2i6o7dc4zzhkogSEgn6IVc09V+4j3u9xUUeaBNL7
 RcfMZwPrqxgxhnfISVVY3k+4=
X-Envelope-To: netdev@vger.kernel.org
X-Received: by smtp.migadu.com with ESMTPS id 8363c2b801802ffb;
	Thu, 22 Oct 2026 10:07:15 +0000
X-Mizu-Trace-ID: 8363c2b801802ffb
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: John Fastabend <john.fastabend@gmail.com>,
 Jakub Sitnicki <jakub@cloudflare.com>, Eric Dumazet <edumazet@kernel.org>,
 Neal Cardwell <ncardwell@google.com>, Kuniyuki Iwashima <kuniyu@google.com>,
 "David S. Miller" <davem@davemloft.net>, Jakub Kicinski <kuba@kernel.org>,
 Paolo Abeni <pabeni@redhat.com>, Simon Horman <horms@kernel.org>,
 Daniel Borkmann <daniel@iogearbox.net>, Levi Zim <rsworktech@outlook.com>,
 "open list:BPF [L7 FRAMEWORK] (sockmap)" <bpf@vger.kernel.org>,
 open list <linux-kernel@vger.kernel.org>
X-In-Reply-To: <20261022095853.1829161-1-qirui.001@bytedance.com>