Article View: linux.kernel.netdev
Article #671Re: [PATCH net] tcp: reject devmem tx with fastopen and repair
From: Pavel Begunkov
Date: Thu, 08 Oct 2026 12:53
Date: Thu, 08 Oct 2026 12:53
62 lines
10894 bytes
10894 bytes
On 10/5/26 22:40, Kaifeng Wang wrote:
> tcp_sendmsg_locked() enforces that devmem TX can only proceed if the
> zero-copy path is active and a valid dmabuf binding exists. However,
> subsequent branches in tcp_sendmsg_locked() can still intercept the
> message before it reaches the devmem zero-copy loop:
>
> 1. TCP Fast Open (MSG_FASTOPEN or DEFER_CONNECT):
> If TCP_FASTOPEN_CONNECT is set, the socket may have a valid dst with
> NETIF_F_SG (so zc == MSG_ZEROCOPY and binding is present), but
> tcp_sendmsg_fastopen() -> tcp_send_syn_data() will use
> copy_page_from_iter() to byte-copy from the iterator. Since iov_base
> represents dma-buf offsets rather than user virtual addresses, this
> misinterprets offsets as user pointers and copies arbitrary user memory
> into the SYN packet.
>
> 2. TCP repair mode:
> If tp->repair is enabled with TCP_RECV_QUEUE, tcp_send_rcvq() similarly
> calls skb_copy_datagram_from_iter(), byte-copying from the iterator.
>
> Neither path supports or makes sense for devmem transmission. Reject devmem
> sends if Fast Open or repair mode is active.
>
> This pre-existing issue was identified by Sashiko AI review on commit
> 125755776bc6 ("tcp: reject non zerocopy devmem tx") and has not been
> hit in production.
>
> Fixes: 125755776bc6 ("tcp: reject non zerocopy devmem tx")
> Fixes: bd61848900bf ("net: devmem: Implement TX path")
> Signed-off-by: Kaifeng Wang <kaifengw@google.com>
> ---
> net/ipv4/tcp.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
> index 87ef6d5cbfeb..225e758c194a 100644
> --- a/net/ipv4/tcp.c
> +++ b/net/ipv4/tcp.c
> @@ -1169,7 +1169,9 @@ int tcp_sendmsg_locked(struct sock *sk, struct msghdr *msg, size_t size)
> zc = MSG_SPLICE_PAGES;
> }
>
> - if (!sockc_err && sockc.dmabuf_id && (zc != MSG_ZEROCOPY || !binding)) {
> + if (!sockc_err && sockc.dmabuf_id &&
> + (zc != MSG_ZEROCOPY || !binding || tp->repair ||
> + (flags & MSG_FASTOPEN) || inet_test_bit(DEFER_CONNECT, sk))) {
It becomes unhandy, and taking into account the issue Stan commented
about, I think it'd make sense to do the checks under the repair and
fast open "ifs".
if (((1 << sk->sk_state) & ~(TCPF_ESTABLISHED | TCPF_CLOSE_WAIT)) &&
!tcp_passive_fastopen(sk)) {
if (binding) // fail;
}
if (unlikely(tp->repair)) {
if (binding) // fail;
}
--
Pavel Begunkov
Technical Details
Message-ID:
<7f377853-ae56-450b-889b-688ec335e81c@gmail.com>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-342970-linux-kernel-netdev=dewy.ruReferences:
<20261005214002.3226574-1-kaifengw@google.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-342970-linux-kernel-netdev=dewy.ru
From: asml.silence@gmail.com (Pavel Begunkov)
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net] tcp: reject devmem tx with fastopen and repair
Date: Thu, 8 Oct 2026 13:53:51 +0100
Organization: Usenet Network
Message-ID: <7f377853-ae56-450b-889b-688ec335e81c@gmail.com>
References: <20261005214002.3226574-1-kaifengw@google.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Info: usenet.network;
logging-data="883818"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:oYCj9m/eF0Qea2JmsUsQaUy+M00= sha256:kIknM8HBKCsEii2rpeFM8fc3VFuuw+lkmigIbb5Ys/o=
sha1:HNIcZ271adYC0d7Ibp4jMIPsAz8= sha256:YBSkJ0aSY0YdzD4PDs5yY1XvbVAfMUG0Wo4ENoIjQMs=
Content-Language: en-US
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 1723410F3E3; Thu, 8 Oct 2026 15:54:13 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.149
X-Spam-Status: No, score=-3.149 tagged_above=-9999 required=6.31
tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,
FREEMAIL_FORGED_FROMDOMAIN=0.001, FREEMAIL_FROM=0.001,
HEADER_FROM_DIFFERENT_DOMAINS=0.249, 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=gmail.com
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 tloo45cU1Ohl;
Thu, 8 Oct 2026 15:54:10 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.232.135.74; helo=sto.lore.kernel.org; envelope-from=netdev+bounces-342970-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN>
X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=gmail.com
X-Received: from sto.lore.kernel.org (sto.lore.kernel.org [172.232.135.74])
by mail.dewy.ru (Postfix) with ESMTPS id 7EC6D10F3DB; Thu, 8 Oct 2026 15:54:05 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.90.174.1])
by sto.lore.kernel.org (Postfix) with ESMTP id ED2F6607668; Thu, 8 Oct 2026 12:54:04 +0000 (UTC)
X-Received: from localhost.localdomain (localhost.localdomain [127.0.0.1])
by smtp.subspace.kernel.org (Postfix) with ESMTP id 358AB49EC63;
Thu, 8 Oct 2026 12:54:04 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Y2N6mnas"
X-Received: from mail-ej1-f44.google.com (mail-ej1-f44.google.com [209.85.218.44])
(using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
(No client certificate requested)
by smtp.subspace.kernel.org (Postfix) with ESMTPS id B65E64963B6
for <netdev@vger.kernel.org>; Thu, 8 Oct 2026 12:54:02 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.44
X-ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;
t=1791464044; cv=none; b=b6py7E1nkZ3UmyqNNQqM+gcVF/qrViFjU8dZG5HZ2M3OEHWHpiZPjgptDo1ModfsPg2hbeqDzonD3d5ZfpWGkROGOhJkZoRpqTX9kRgJkU9wM4xMgUmXV9OJTX0Rc79mugUny3Z58IwRwKnrkGC1BSEz1KoiF/kfm2ph/pISNhs=
X-ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org;
s=arc-20240116; t=1791464044; c=relaxed/simple;
bh=JeHG9pIy1UQJeD/81cUOb3EBRdHL9JOyJ6u+VtgVjwI=;
h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From:
In-Reply-To:Content-Type; b=CCkcWEiuGaMjlAvtJafSsl4dgHuMBArP8Eo7DofxPMxJ9DV0wl900n26UTLHQUdEB7Dz2ctVrtFcNcLK1xQ4qb2tj4Es8VBpfHqdVe7m4/dn9loAXrccrf/HHw5dCVZCs4oTUyfOf9buLgSprI1wpEoyoUnlvWJdZHZleKBsAh0=
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=Y2N6mnas; arc=none smtp.client-ip=209.85.218.44
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com
X-Received: by mail-ej1-f44.google.com with SMTP id a640c23a62f3a-c2055573c8cso400805866b.3
for <netdev@vger.kernel.org>; Thu, 08 Oct 2026 05:54:02 -0700 (PDT)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=gmail.com; s=20251104; t=1791464041; x=1792068841; darn=vger.kernel.org;
h=content-transfer-encoding:content-type:in-reply-to:from
:content-language:references:cc:to:subject:user-agent:mime-version
:date:message-id:from:to:cc:subject:date:message-id:reply-to
:content-type;
bh=ZOOwNvd1LPWlNAalgBjKqL+DRKIx4sSQk3LcKBQLXIU=;
b=Y2N6mnas+C7GFQW7uNyo8PktJDU+umDOsbdvPrw+so171d5enhf58pLFqj81zwbgpl
yxyTRDQlvue/F9xBRZXGJbekme/+40A0EQ1Rbi/pA1Hx7iNgWhLlyh6c7vbxvTQY0qu2
qp09tS+iq/C13zw/2gJvsFQaPboa/AV0Mxqk4X1hj54J5nTDRmfGT5j20M6efA3+Hgah
/xhXalgsuy4/l/lQSnbxyd3GfvfaFAPZmsCKsFcnLB47t2myFSlcqw/iundf+kj+4dPI
xs887GaoWdmreuXewswlSik+i66FMbuHIDBBzuNcoH6mzdKI6T7XhKWjKNCT7P3tuNhe
N4fg==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20260707; t=1791464041; x=1792068841;
h=content-transfer-encoding:content-type:in-reply-to:from
:content-language:references:cc:to:subject:user-agent:mime-version
:date:message-id:x-gm-gg:x-gm-message-state:from:to:cc:subject:date
:message-id:reply-to:content-type;
bh=ZOOwNvd1LPWlNAalgBjKqL+DRKIx4sSQk3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IiKcYqIzE554Uzru7RYOMIC3llpuoxJ8K1ZUyuFwnnGyqLJzAyq
uIx3MOHgN83xT00mA+uk0nEq6UAd0DQnPvpdpWDBzeAsjolfdMeqJlRi5lD+tSJoCwoq0rETJle
uGXtYJH9g8m9KEfWjqoawYMNiRo+SodZ0KAK6Bjk9w42Z/Gb
X-Received: by 2002:a17:907:3d51:b0:c29:4490:50d6 with SMTP id a640c23a62f3a-c317c0e090emr525786166b.47.1791464040879;
Thu, 08 Oct 2026 05:54:00 -0700 (PDT)
X-Received: from ?IPV6:2a01:4b00:bd21:4f00:7cc6:d3ca:494:116c? ([2a01:4b00:bd21:4f00:7cc6:d3ca:494:116c])
by smtp.gmail.com with ESMTPSA id a640c23a62f3a-c317c1c4f7csm220428966b.35.2026.10.08.05.53.59
(version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128);
Thu, 08 Oct 2026 05:54:00 -0700 (PDT)
X-Precedence: bulk
X-Mailing-List: netdev@vger.kernel.org
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>
X-User-Agent: Mozilla Thunderbird
X-Cc: edumazet@google.com, ncardwell@google.com, kuniyu@google.com,
davem@davemloft.net, kuba@kernel.org, pabeni@redhat.com, horms@kernel.org,
almasrymina@google.com, willemb@google.com, kaiyuanz@google.com,
sdf@fomichev.me, linux-kernel@vger.kernel.org
X-In-Reply-To: <20261005214002.3226574-1-kaifengw@google.com>