The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Brendan Jackman" <jackmanb@google.com>
Cc: linux-rt-devel@lists.linux.dev, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v5 12/18] net/funeth: Switch to higher-level allocator API
Date: Fri, 03 Jul 2026 12:53:05 +0000	[thread overview]
Message-ID: <20260703125305.7B7E21F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260703-alloc-trylock-v5-12-c87b714e19d3@google.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:

Pre-existing issues:
- [Critical] Untrusted packet length from hardware CQE leads to stack buffer overflow and OOB memory corruption.
--

commit fd0faaa7ff432d936af6fe6e5da6c09cbf2f16eb
Author: Brendan Jackman <jackmanb@google.com>

net/funeth: Switch to higher-level allocator API

This commit replaces the deprecated __alloc_pages_node() with
alloc_pages_node(). The new API supports passing NUMA_NO_NODE. No functional
changes are intended by this switch.

> diff --git a/drivers/net/ethernet/fungible/funeth/funeth_rx.c b/drivers/net/ethernet/fungible/funeth/funeth_rx.c
> index 7e2584895de39..d7000017ac2bd 100644
> --- a/drivers/net/ethernet/fungible/funeth/funeth_rx.c
> +++ b/drivers/net/ethernet/fungible/funeth/funeth_rx.c
> @@ -103,7 +103,7 @@ static int funeth_alloc_page(struct funeth_rxq *q, struct funeth_rxbuf *rb,
>  	if (cache_get(q, rb))
>  		return 0;
>  
> -	p = __alloc_pages_node(node, gfp | __GFP_NOWARN, 0);
> +	p = alloc_pages_node(node, gfp | __GFP_NOWARN, 0);

[Severity: Critical]
This is a pre-existing issue, but while reviewing this file I noticed a
potential stack buffer overflow when handling untrusted packet lengths
from the hardware CQE.

In fun_handle_cqe_pkt(), the untrusted packet length and fragment count
are read from the CQE:

    unsigned int i, tot_len, pkt_len = be32_to_cpu(rxreq->pkt_len);
    ...
    tot_len = pkt_len;
    ...
    ref_ok = fun_gather_pkt(q, tot_len, frags);
    ...
    skb = napi_build_skb(va, ALIGN(tot_len, FUN_EPRQ_PKT_ALIGN));
    ...
    si->nr_frags = rxreq->nsgl;
    for (i = 0; i < si->nr_frags; i++)
        si->frags[i] = frags[i];

Does the loop in fun_gather_pkt() iterate until tot_len is exhausted without
validating the size?

    for (;;) {
        ...
        skb_frag_fill_page_desc(frags++, buf->page, q->buf_offset, frag_len);
        tot_len -= frag_len;
        if (!tot_len)
            break;
    }

If rxreq->pkt_len is maliciously large, could this increment the frags array
pointer past the bounds of the stack-allocated frags array (size 4),
resulting in a stack buffer overflow?

Furthermore, could napi_build_skb() use this untrusted length to place
skb_shared_info at an out-of-bounds offset, corrupting unrelated memory?

>  	if (unlikely(!p))
>  		return -ENOMEM;
>

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260703-alloc-trylock-v5-0-c87b714e19d3@google.com?part=12

  reply	other threads:[~2026-07-03 12:53 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-03 12:31 [PATCH v5 00/18] mm: Some cleanups for page allocator APIs Brendan Jackman
2026-07-03 12:31 ` [PATCH v5 01/18] mm/page_alloc: rename ALLOC_TRYLOCK -> ALLOC_NOLOCK Brendan Jackman
2026-07-03 13:59   ` Zi Yan
2026-07-03 12:31 ` [PATCH v5 02/18] mm/page_alloc: some renames to clarify alloc_flags scopes Brendan Jackman
2026-07-03 14:01   ` Zi Yan
2026-07-03 12:31 ` [PATCH v5 03/18] mm: name some args in a function declaration Brendan Jackman
2026-07-03 14:02   ` Zi Yan
2026-07-03 12:31 ` [PATCH v5 04/18] mm: Split out internal page_alloc.h Brendan Jackman
2026-07-03 14:07   ` Zi Yan
2026-07-03 12:31 ` [PATCH v5 05/18] mm/page_alloc: unify __alloc_frozen_pages[_nolock]_noprof() Brendan Jackman
2026-07-03 14:42   ` Zi Yan
2026-07-03 12:31 ` [PATCH v5 06/18] mm/page_alloc: relax GFP WARN in nolock allocs Brendan Jackman
2026-07-03 12:43   ` sashiko-bot
2026-07-03 14:44   ` Zi Yan
2026-07-03 12:31 ` [PATCH v5 07/18] mm: move some stuff to mm/page_alloc.h Brendan Jackman
2026-07-03 14:46   ` Zi Yan
2026-07-03 12:31 ` [PATCH v5 08/18] perf/x86/intel: Use higher-level allocator API Brendan Jackman
2026-07-03 14:49   ` Zi Yan
2026-07-03 12:31 ` [PATCH v5 09/18] KVM: VMX: " Brendan Jackman
2026-07-03 14:49   ` Zi Yan
2026-07-03 12:31 ` [PATCH v5 10/18] x86/virt: " Brendan Jackman
2026-07-03 14:50   ` Zi Yan
2026-07-03 12:31 ` [PATCH v5 11/18] sgi-xp: " Brendan Jackman
2026-07-03 12:48   ` sashiko-bot
2026-07-03 14:51   ` Zi Yan
2026-07-03 12:31 ` [PATCH v5 12/18] net/funeth: Switch to " Brendan Jackman
2026-07-03 12:53   ` sashiko-bot [this message]
2026-07-03 14:52   ` Zi Yan
2026-07-03 12:31 ` [PATCH v5 13/18] mm: Remove __alloc_pages_node() Brendan Jackman
2026-07-03 12:54   ` sashiko-bot
2026-07-03 14:57   ` Zi Yan
2026-07-03 12:31 ` [PATCH v5 14/18] mm: Move __alloc_pages() to mm/page_alloc.h Brendan Jackman
2026-07-03 15:05   ` Zi Yan
2026-07-03 12:31 ` [PATCH v5 15/18] mm: replace __GFP_NO_CODETAG with ALLOC_NO_CODETAG Brendan Jackman
2026-07-03 12:31 ` [PATCH v5 16/18] mm: remove the __GFP_NO_OBJ_EXT flag Brendan Jackman
2026-07-03 12:31 ` [PATCH v5 17/18] mm/page_alloc: drop alloc_flags arg from alloc_flags_cma() Brendan Jackman
2026-07-03 15:10   ` Zi Yan
2026-07-03 12:31 ` [PATCH v5 18/18] mm: factor out can_spin_trylock() Brendan Jackman
2026-07-03 12:55   ` sashiko-bot
2026-07-03 15:12   ` Zi Yan
2026-07-03 12:47 ` [PATCH v5 00/18] mm: Some cleanups for page allocator APIs Vlastimil Babka (SUSE)

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=20260703125305.7B7E21F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=jackmanb@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rt-devel@lists.linux.dev \
    --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