[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <Z-rJL6oFZa5jpjlo@lore-desk>
Date: Mon, 31 Mar 2025 18:56:15 +0200
From: Lorenzo Bianconi <lorenzo@...nel.org>
To: Simon Horman <horms@...nel.org>
Cc: Andrew Lunn <andrew+netdev@...n.ch>,
"David S. Miller" <davem@...emloft.net>,
Eric Dumazet <edumazet@...gle.com>,
Jakub Kicinski <kuba@...nel.org>, Paolo Abeni <pabeni@...hat.com>,
linux-arm-kernel@...ts.infradead.org,
linux-mediatek@...ts.infradead.org, netdev@...r.kernel.org
Subject: Re: [PATCH net v3] net: airoha: Validate egress gdm port in
airoha_ppe_foe_entry_prepare()
> 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.
ack, I will fix it in v4.
>
> > 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@...nel.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.
ack, I will fix it in v4.
Regards,
Lorenzo
>
> > +{
> > + int i;
> > +
> > + for (i = 0; i < ARRAY_SIZE(eth->ports); i++) {
> > + if (eth->ports[i] == port)
> > + return 0;
> > + }
> > +
> > + return -EINVAL;
> > +}
> > +
>
> ...
Download attachment "signature.asc" of type "application/pgp-signature" (229 bytes)
Powered by blists - more mailing lists