[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20240709183351.79ba61ea@kmaincent-XPS-13-7390>
Date: Tue, 9 Jul 2024 18:33:51 +0200
From: Kory Maincent <kory.maincent@...tlin.com>
To: Jakub Kicinski <kuba@...nel.org>
Cc: Andrew Lunn <andrew@...n.ch>, netdev@...r.kernel.org,
linux-kernel@...r.kernel.org, Oleksij Rempel <o.rempel@...gutronix.de>,
thomas.petazzoni@...tlin.com, "David S. Miller" <davem@...emloft.net>, Eric
Dumazet <edumazet@...gle.com>, Paolo Abeni <pabeni@...hat.com>
Subject: Re: [PATCH net] net: ethtool: pse-pd: Fix possible null-deref
On Tue, 9 Jul 2024 08:52:05 -0700
Jakub Kicinski <kuba@...nel.org> wrote:
> On Tue, 9 Jul 2024 16:43:05 +0200 Kory Maincent wrote:
> > > Normal ethtool flow is to first fill in the data with a ->get() then
> > > modify what user wants to change.
> > >
> > > Either we need:
> > > - an explanation in the commit message how this keeps old config; or
> > > - a ->get() to keep the previous values; or
> > > - just reject setting one value but not the other in
> > > ethnl_set_pse_validate() (assuming it never worked, anyway).
> >
> > In fact it is the contrary we can't set both value at the same time because
> > a PSE port can't be a PoE and a PoDL power interface at the same time.
>
> In that case maybe we should have an inverse condition in validate, too?
> Something like:
>
> if ((pse_has_podl(phydev->psec) &&
> GENL_REQ_ATTR_CHECK(info, ETHTOOL_A_PODL_PSE_ADMIN_CONTROL)) ||
> (pse_has_c33(phydev->psec) &&
> GENL_REQ_ATTR_CHECK(info, ETHTOOL_A_C33_PSE_ADMIN_CONTROL)))
> return -EINVAL;
>
> GENL_REQ_ATTR_CHECK will set the extack for us.
I don't think it will work.
In a case a PSE controller have one PoDL port and one PoE port.
Your code will always return EINVAL if we try to set the config of only one of
those ports.
I think the patch I sent plus a change in pse-pd core to do nothing in case of
an empty config will do.
Regards,
--
Köry Maincent, Bootlin
Embedded Linux and kernel engineering
https://bootlin.com
Powered by blists - more mailing lists