From: Simon Horman <horms@kernel.org>
To: Lorenzo Bianconi <lorenzo@kernel.org>
Cc: Andrew Lunn <andrew+netdev@lunn.ch>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
linux-arm-kernel@lists.infradead.org,
linux-mediatek@lists.infradead.org, netdev@vger.kernel.org
Subject: Re: [PATCH net v3] net: airoha: Validate egress gdm port in airoha_ppe_foe_entry_prepare()
Date: Mon, 31 Mar 2025 17:28:41 +0100 [thread overview]
Message-ID: <20250331162841.GD185681@horms.kernel.org> (raw)
In-Reply-To: <20250331-airoha-validate-egress-gdm-port-v3-1-c14e6ba9733a@kernel.org>
On Mon, Mar 31, 2025 at 12:14:09PM +0200, Lorenzo Bianconi wrote:
> Device pointer in airoha_ppe_foe_entry_prepare routine is not strictly
> necessary a device allocated by airoha_eth driver since it is an egress
nit: I think it would be clearer if "necessary" was dropped from the line
above.
> device and the flowtable can contain even wlan, pppoe or vlan devices.
> E.g:
>
> flowtable ft {
> hook ingress priority filter
> devices = { eth1, lan1, lan2, lan3, lan4, wlan0 }
> flags offload ^
> |
> "not allocated by airoha_eth" --
> }
>
> In this case airoha_get_dsa_port() will just return the original device
> pointer and we can't assume netdev priv pointer points to an
> airoha_gdm_port struct.
> Fix the issue validating egress gdm port in airoha_ppe_foe_entry_prepare
> routine before accessing net_device priv pointer.
>
> Fixes: 00a7678310fe ("net: airoha: Introduce flowtable offload support")
> Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
> ---
> Changes in v3:
> - Rebase on top of net tree
> - Fix commit log
> - Link to v2: https://lore.kernel.org/r/20250315-airoha-flowtable-null-ptr-fix-v2-1-94b923d30234@kernel.org
>
> Changes in v2:
> - Avoid checking netdev_priv pointer since it is always not NULL
> - Link to v1: https://lore.kernel.org/r/20250312-airoha-flowtable-null-ptr-fix-v1-1-6363fab884d0@kernel.org
> ---
> drivers/net/ethernet/airoha/airoha_eth.c | 13 +++++++++++++
> drivers/net/ethernet/airoha/airoha_eth.h | 3 +++
> drivers/net/ethernet/airoha/airoha_ppe.c | 10 ++++++++--
> 3 files changed, 24 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/net/ethernet/airoha/airoha_eth.c b/drivers/net/ethernet/airoha/airoha_eth.c
> index c0a642568ac115ea9df6fbaf7133627a4405a36c..bf9c882e9c8b087dbf5e907636547a0117d1b96a 100644
> --- a/drivers/net/ethernet/airoha/airoha_eth.c
> +++ b/drivers/net/ethernet/airoha/airoha_eth.c
> @@ -2454,6 +2454,19 @@ static void airoha_metadata_dst_free(struct airoha_gdm_port *port)
> }
> }
>
> +int airoha_is_valid_gdm_port(struct airoha_eth *eth,
> + struct airoha_gdm_port *port)
nit: given the name of the function, perhaps returning a bool is more
appropriate.
> +{
> + int i;
> +
> + for (i = 0; i < ARRAY_SIZE(eth->ports); i++) {
> + if (eth->ports[i] == port)
> + return 0;
> + }
> +
> + return -EINVAL;
> +}
> +
...
next prev parent reply other threads:[~2025-03-31 16:28 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-31 10:14 [PATCH net v3] net: airoha: Validate egress gdm port in airoha_ppe_foe_entry_prepare() Lorenzo Bianconi
2025-03-31 16:28 ` Simon Horman [this message]
2025-03-31 16:56 ` Lorenzo Bianconi
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=20250331162841.GD185681@horms.kernel.org \
--to=horms@kernel.org \
--cc=andrew+netdev@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=kuba@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-mediatek@lists.infradead.org \
--cc=lorenzo@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.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).