* [PATCH net v1 1/3] net: core: propagate unreadable flag in skb_zerocopy
@ 2026-08-01 12:52 Mina Almasry
2026-08-01 12:52 ` [PATCH net v1 2/3] net: devmem: return EMSGSIZE on type mismatch Mina Almasry
2026-08-01 12:52 ` [PATCH net v1 3/3] net: tcp: block standard payload injection into devmem skbs Mina Almasry
0 siblings, 2 replies; 3+ messages in thread
From: Mina Almasry @ 2026-08-01 12:52 UTC (permalink / raw)
Cc: Mina Almasry, Pavel Begunkov, Stanislav Fomichev, Bobby Eshleman,
Florian Westphal, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Simon Horman, Jason Xing, Kuniyuki Iwashima,
Björn Töpel, Jiayuan Chen, Willem de Bruijn,
Kaiyuan Zhang, open list:NETWORKING [GENERAL], open list
When skb_zerocopy() copies devmem payload fragments, it fails to update
the target skb's unreadable flag. This causes the target to appear as
readable memory.
Propagate the unreadable flag if any devmem fragments were copied from
the source.
Fixes: 65249feb6b3d ("net: add support for skbs with unreadable frags")
Cc: Pavel Begunkov <asml.silence@gmail.com>
Cc: Stanislav Fomichev <sdf@fomichev.me>
Cc: Bobby Eshleman <bobbyeshleman@gmail.com>
Cc: Florian Westphal <fw@strlen.de>
Signed-off-by: Mina Almasry <almasrymina@google.com>
---
net/core/skbuff.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index ba3dbac80fb49..aebe8ea74776a 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -3928,6 +3928,9 @@ skb_zerocopy(struct sk_buff *to, struct sk_buff *from, int len, int hlen)
}
skb_shinfo(to)->nr_frags = j;
+ if (i > 0 && from->unreadable)
+ to->unreadable = 1;
+
return 0;
}
EXPORT_SYMBOL_GPL(skb_zerocopy);
--
2.55.0.571.g244d577d93-goog
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH net v1 2/3] net: devmem: return EMSGSIZE on type mismatch
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 ` Mina Almasry
2026-08-01 12:52 ` [PATCH net v1 3/3] net: tcp: block standard payload injection into devmem skbs Mina Almasry
1 sibling, 0 replies; 3+ messages in thread
From: Mina Almasry @ 2026-08-01 12:52 UTC (permalink / raw)
Cc: Mina Almasry, Pavel Begunkov, Stanislav Fomichev, Bobby Eshleman,
David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Simon Horman, Will Deacon, Antonio Quartulli, Ralf Lici,
Kaiyuan Zhang, open list:NETWORKING [GENERAL], open list
When a devmem payload mixes with a standard page payload, return
-EMSGSIZE instead of -EFAULT. This enables tcp_sendmsg to seamlessly
fall back to creating a new segment instead of failing the socket send.
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/core/datagram.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/net/core/datagram.c b/net/core/datagram.c
index 173b5d97bd409..6f8ffd61bcab4 100644
--- a/net/core/datagram.c
+++ b/net/core/datagram.c
@@ -638,7 +638,7 @@ int zerocopy_fill_skb_from_iter(struct sk_buff *skb,
int frag = skb_shinfo(skb)->nr_frags;
if (!skb_frags_readable(skb))
- return -EFAULT;
+ return -EMSGSIZE;
while (length && iov_iter_count(from)) {
struct page *head, *last_head = NULL;
@@ -713,7 +713,7 @@ zerocopy_fill_skb_from_devmem(struct sk_buff *skb, struct iov_iter *from,
struct net_iov *niov;
if (i && skb_frags_readable(skb))
- return -EFAULT;
+ return -EMSGSIZE;
/* Devmem filling works by taking an IOVEC from the user where the
* iov_addrs are interpreted as an offset in bytes into the dma-buf to
--
2.55.0.571.g244d577d93-goog
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH net v1 3/3] net: tcp: block standard payload injection into devmem skbs
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-01 12:52 ` Mina Almasry
1 sibling, 0 replies; 3+ messages in thread
From: Mina Almasry @ 2026-08-01 12:52 UTC (permalink / raw)
Cc: Mina Almasry, Pavel Begunkov, Stanislav Fomichev, Bobby Eshleman,
Eric Dumazet, Neal Cardwell, Kuniyuki Iwashima, David S. Miller,
Jakub Kicinski, Paolo Abeni, Simon Horman, Kaiyuan Zhang,
open list:NETWORKING [TCP], open list
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
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-08-01 12:53 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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-01 12:52 ` [PATCH net v1 3/3] net: tcp: block standard payload injection into devmem skbs Mina Almasry
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox