BPF List
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Mina Almasry" <almasrymina@google.com>
Cc: bpf@vger.kernel.org
Subject: Re: [PATCH net-next v2 1/2] net: netmem: document netmem and memory provider design in comments
Date: Fri, 09 Oct 2026 02:30:37 +0000	[thread overview]
Message-ID: <sashiko-outbox-164727@kernel.org> (raw)
In-Reply-To: <20261008023030.1089616-2-almasrymina@google.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] net: skb_try_coalesce() mixes page and net_iov frags, deadlocking tcp_recvmsg()
--

commit 9c60c371b94dbd05fff282258637a7b536efd5da
Author: Mina Almasry <almasrymina@google.com>

net: netmem: document netmem and memory provider design in comments

Clarify the netmem, memory provider, page_pool, and skb fragment design
principles in header and code comments. It documents that all fragments in
an skb must share the same backing memory type and adds a check to avoid
coalescing skbs with different fragment memory types.

> diff --git a/net/core/skbuff.c b/net/core/skbuff.c
> index 43ebe61c7fc48..2c42a218dcc00 100644
> --- a/net/core/skbuff.c
> +++ b/net/core/skbuff.c
> @@ -6206,6 +6206,9 @@ bool skb_try_coalesce(struct sk_buff *to, struct sk_buff *from,
>  	if (to->pp_recycle != from->pp_recycle)
>  		return false;
>  
> +	/* All frags in an skb must have the same backing netmem memory type;
> +	 * do not coalesce skbs with different frag memory types.
> +	 */
>  	if (skb_frags_readable(from) != skb_frags_readable(to))
>  		return false;
>  

[Severity: High]
Does this fully prevent mixing fragment types if the source skb has
linear payload?

If both skbs are unreadable, they pass this check. But if the source skb
has linear payload, skb_try_coalesce() unconditionally converts the
linear payload into a struct page fragment and appends it to the target skb:

skb_try_coalesce() {
    ...
    if (skb_headlen(from) != 0) {
        ...
        page = virt_to_head_page(from->head);
        ...
        skb_fill_page_desc(to, to_shinfo->nr_frags,
                           page, offset, skb_headlen(from));
        ...
    }
}

Would this result in the unreadable target skb containing a mix of net_iov
fragments and a struct page fragment?

If this mixed skb reaches tcp_recvmsg_locked(), could it cause a permanent
socket deadlock? An skb marked unreadable forces reads through
tcp_recvmsg_dmabuf(), which aborts upon encountering a readable struct page
fragment. This causes recvmsg to repeatedly return -EFAULT without advancing
the offset.

Additionally, on transmit paths, validate_xmit_unreadable_skb() only checks
the first fragment. Could mixed skbs bypass these transmit checks and reach
drivers, potentially causing issues if they incorrectly cast the page to
net_iov?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261008023030.1089616-1-almasrymina@google.com?part=1

  parent reply	other threads:[~2026-10-09  2:30 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-08  2:30 [PATCH net-next v2 0/2] net: netmem: document design principles and intended direction Mina Almasry
2026-10-08  2:30 ` [PATCH net-next v2 1/2] net: netmem: document netmem and memory provider design in comments Mina Almasry
2026-10-08 11:29   ` Björn Töpel
2026-10-09  2:30   ` sashiko-bot [this message]
2026-10-08  2:30 ` [PATCH net-next v2 2/2] docs: netmem: document netmem and memory provider design principles Mina Almasry
2026-10-08 11:33   ` Björn Töpel
2026-10-08 22:09 ` [PATCH net-next v2 0/2] net: netmem: document design principles and intended direction Stanislav Fomichev

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=sashiko-outbox-164727@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=almasrymina@google.com \
    --cc=bpf@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /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