All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mina Almasry <almasrymina@google.com>
Cc: Mina Almasry <almasrymina@google.com>,
	Pavel Begunkov <asml.silence@gmail.com>,
	 Stanislav Fomichev <sdf@fomichev.me>,
	Bobby Eshleman <bobbyeshleman@gmail.com>,
	 Eric Dumazet <edumazet@google.com>,
	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>,
	 Kaiyuan Zhang <kaiyuanz@google.com>,
	"open list:NETWORKING [TCP]" <netdev@vger.kernel.org>,
	 open list <linux-kernel@vger.kernel.org>
Subject: [PATCH net v1 3/3] net: tcp: block standard payload injection into devmem skbs
Date: Sat,  1 Aug 2026 12:52:21 +0000	[thread overview]
Message-ID: <20260801125308.1342897-3-almasrymina@google.com> (raw)
In-Reply-To: <20260801125308.1342897-1-almasrymina@google.com>

Protect tcp_sendmsg_locked() from mistakenly appending non-zerocopy
page fragments to unreadable devmem skbs. Create a new segment instead.

Fixes: bd61848900bff ("net: devmem: Implement TX path")
Cc: Pavel Begunkov <asml.silence@gmail.com>
Cc: Stanislav Fomichev <sdf@fomichev.me>
Cc: Bobby Eshleman <bobbyeshleman@gmail.com>
Signed-off-by: Mina Almasry <almasrymina@google.com>
---
 net/ipv4/tcp.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
index 455441f1b6949..186a36c698798 100644
--- a/net/ipv4/tcp.c
+++ b/net/ipv4/tcp.c
@@ -1278,6 +1278,11 @@ int tcp_sendmsg_locked(struct sock *sk, struct msghdr *msg, size_t size)
 		if (copy > msg_data_left(msg))
 			copy = msg_data_left(msg);
 
+		if (zc != MSG_ZEROCOPY && unlikely(!skb_frags_readable(skb))) {
+			tcp_mark_push(tp, skb);
+			goto new_segment;
+		}
+
 		if (zc == 0) {
 			bool merge = true;
 			int i = skb_shinfo(skb)->nr_frags;
-- 
2.55.0.571.g244d577d93-goog


  parent reply	other threads:[~2026-08-01 12:53 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-01 12:52 [PATCH net v1 1/3] net: core: propagate unreadable flag in skb_zerocopy Mina Almasry
2026-08-01 12:52 ` [PATCH net v1 2/3] net: devmem: return EMSGSIZE on type mismatch Mina Almasry
2026-08-02 12:26   ` Pavel Begunkov
2026-08-01 12:52 ` Mina Almasry [this message]
2026-08-02 12:25   ` [PATCH net v1 3/3] net: tcp: block standard payload injection into devmem skbs Pavel Begunkov
2026-08-02 12:33 ` [PATCH net v1 1/3] net: core: propagate unreadable flag in skb_zerocopy Pavel Begunkov
2026-08-02 12:44   ` Pavel Begunkov
2026-08-03 15:49   ` Mina Almasry

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260801125308.1342897-3-almasrymina@google.com \
    --to=almasrymina@google.com \
    --cc=asml.silence@gmail.com \
    --cc=bobbyeshleman@gmail.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=horms@kernel.org \
    --cc=kaiyuanz@google.com \
    --cc=kuba@kernel.org \
    --cc=kuniyu@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=ncardwell@google.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=sdf@fomichev.me \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.