From: Vladimir Oltean <olteanv@gmail.com>
To: Luke Howard <lukeh@padl.com>
Cc: netdev@vger.kernel.org
Subject: Re: [PATCH net] net: dsa: validate source trunk against lags_len
Date: Thu, 31 Jul 2025 12:07:53 +0300 [thread overview]
Message-ID: <20250731090753.tr3d37mg4wsumdli@skbuf> (raw)
In-Reply-To: <DEC3889D-5C54-4648-B09F-44C7C69A1F91@padl.com>
Hello Luke,
On Thu, Jul 31, 2025 at 03:35:34PM +1000, Luke Howard wrote:
> A DSA frame with an invalid source trunk ID could cause an out-of-bounds read
> access of dst->lags.
>
> This patch adds a check to dsa_lag_by_id() to validate the LAG ID is not zero,
> and is less than or equal to dst->lags_len. (The LAG ID is derived by adding
> one to the source trunk ID.)
>
> Note: this is in the fast path for any frames within a trunk.
>
> Signed-off-by: Luke Howard <lukeh@padl.com>
> ---
> include/net/dsa.h | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/include/net/dsa.h b/include/net/dsa.h
> index 2e148823c366c..67672c5ff22e5 100644
> --- a/include/net/dsa.h
> +++ b/include/net/dsa.h
> @@ -180,6 +180,9 @@ struct dsa_switch_tree {
> static inline struct dsa_lag *dsa_lag_by_id(struct dsa_switch_tree *dst,
> unsigned int id)
> {
> + if (unlikely(id == 0 || id > dst->lags_len))
> + return NULL;
> +
> /* DSA LAG IDs are one-based, dst->lags is zero-based */
> return dst->lags[id - 1];
> }
> --
> 2.43.0
1. You need to add a Fixes: tag, like the following:
Fixes: 5b60dadb71db ("net: dsa: tag_dsa: Support reception of packets from LAG devices")
2. The problem statement must not remain in the theoretical realm if you
submit a patch intended as a bug fix. Normally the tagger is used to
process data coming from the switch hardware, so to trigger an
out-of-bounds array access would imply that the problem is elsewhere.
That, or you can make it clear that the patch is to prevent a
modified dsa_loop from crashing when receiving crafted packets over a
regular network interface. But using dsa_loop with a modified
dsa_loop_get_protocol() return value is a developer tool which
involves modifying kernel sources. I would say any fix that doesn't
fix any real life problem in production systems should be sent to
'net-next', not to 'net'. This is in accordance with
Documentation/process/stable-kernel-rules.rst.
3. As per Documentation/process/submitting-patches.rst, you should
replace the wording "This patch adds" with the imperative mood.
4. Please use ./scripts/get_maintainer.pl to generate the recipient
list, don't send patches just to the mailing list, reviewers might
miss them.
next prev parent reply other threads:[~2025-07-31 9:07 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-31 5:35 [PATCH net] net: dsa: validate source trunk against lags_len Luke Howard
2025-07-31 8:23 ` Dawid Osuchowski
2025-07-31 9:07 ` Vladimir Oltean [this message]
2025-07-31 9:55 ` Luke Howard
2025-07-31 11:37 ` Vladimir Oltean
[not found] ` <C867697B-7F5B-4500-8098-9C44630D7930@padl.com>
[not found] ` <CAD3ieB36VnKAQPXUGbnRdWYFThf-VfLkhZTRfb9=ddndZEW3=A@mail.gmail.com>
2025-08-05 7:42 ` Vladimir Oltean
2025-08-05 11:52 ` Andrew Lunn
2025-08-06 1:28 ` Luke Howard
2025-07-31 9:56 ` [PATCH v2 net-next] " Luke Howard
2025-07-31 11:44 ` Vladimir Oltean
2025-07-31 13:07 ` Andrew Lunn
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=20250731090753.tr3d37mg4wsumdli@skbuf \
--to=olteanv@gmail.com \
--cc=lukeh@padl.com \
--cc=netdev@vger.kernel.org \
/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