netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Bobby Eshleman <bobbyeshleman@gmail.com>
To: Mina Almasry <almasrymina@google.com>
Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	davem@davemloft.net, edumazet@google.com, kuba@kernel.org,
	pabeni@redhat.com, horms@kernel.org, kerneljasonxing@gmail.com,
	kuniyu@google.com, bjorn@kernel.org, jiayuan.chen@linux.dev,
	kaiyuanz@google.com, willemb@google.com, asml.silence@gmail.com,
	sdf@fomichev.me, fw@strlen.de,
	Neal Cardwell <ncardwell@google.com>,
	Ralf Lici <ralf@mandelbit.com>, Will Deacon <will@kernel.org>
Subject: Re: [PATCH net v2 1/3] net: core: propagate unreadable flag in skb_zerocopy
Date: Mon, 3 Aug 2026 10:31:25 -0700	[thread overview]
Message-ID: <anDQbSNYlbzyQwOH@devvm29614.prn0.facebook.com> (raw)
In-Reply-To: <20260803171441.408014-1-almasrymina@google.com>

On Mon, Aug 03, 2026 at 05:14:39PM +0000, Mina Almasry wrote:
> 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.
> 
> Additionally, to prevent memory corruption, explicitly return -EFAULT
> if standard payload from the head is mixed into the same skb alongside
> unreadable devmem fragments during a head-to-frag extraction.
> 
> 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>
> Reviewed-by: Pavel Begunkov <asml.silence@gmail.com>
> 
> ---
> v2:
> - Return -EFAULT when mixing head-to-frag unreadable/readable frags to prevent memory corruption (Pavel).
> v1: https://lore.kernel.org/r/20260801125308.1342897-1-almasrymina@google.com
> ---
>  net/core/skbuff.c | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/net/core/skbuff.c b/net/core/skbuff.c
> index ba3dbac80fb49..8bacc6c4e16e1 100644
> --- a/net/core/skbuff.c
> +++ b/net/core/skbuff.c
> @@ -3905,6 +3905,9 @@ skb_zerocopy(struct sk_buff *to, struct sk_buff *from, int len, int hlen)
>  		}
>  	}
>  
> +	if (!skb_frags_readable(from) && j > 0 && len)
> +		return -EFAULT;
> +
>  	skb_len_add(to, len + plen);
>  
>  	if (unlikely(skb_orphan_frags(from, GFP_ATOMIC))) {
> @@ -3928,6 +3931,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);
> 
> base-commit: af39eb111ce6b5eba9c08513b62c4868eb7e7fd5
> -- 
> 2.55.0.571.g244d577d93-goog
> 

Reviewed-by: Bobby Eshleman <bobbyeshleman@meta.com>

      parent reply	other threads:[~2026-08-03 17:31 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-03 17:14 [PATCH net v2 1/3] net: core: propagate unreadable flag in skb_zerocopy Mina Almasry
2026-08-03 17:14 ` [PATCH net v2 2/3] net: devmem: return EMSGSIZE on type mismatch Mina Almasry
2026-08-03 17:32   ` Bobby Eshleman
2026-08-03 19:54   ` Jakub Kicinski
2026-08-04 15:36     ` Mina Almasry
2026-08-04 21:38       ` Jakub Kicinski
2026-08-03 17:14 ` [PATCH net v2 3/3] net: tcp: block standard payload injection into devmem skbs Mina Almasry
2026-08-03 17:35   ` Bobby Eshleman
2026-08-03 17:31 ` Bobby Eshleman [this message]

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=anDQbSNYlbzyQwOH@devvm29614.prn0.facebook.com \
    --to=bobbyeshleman@gmail.com \
    --cc=almasrymina@google.com \
    --cc=asml.silence@gmail.com \
    --cc=bjorn@kernel.org \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=fw@strlen.de \
    --cc=horms@kernel.org \
    --cc=jiayuan.chen@linux.dev \
    --cc=kaiyuanz@google.com \
    --cc=kerneljasonxing@gmail.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=ralf@mandelbit.com \
    --cc=sdf@fomichev.me \
    --cc=will@kernel.org \
    --cc=willemb@google.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).