netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jakub Kicinski <kuba@kernel.org>
To: Kory Maincent <kory.maincent@bootlin.com>
Cc: Andrew Lunn <andrew@lunn.ch>,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	Oleksij Rempel <o.rempel@pengutronix.de>,
	thomas.petazzoni@bootlin.com,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Paolo Abeni <pabeni@redhat.com>
Subject: Re: [PATCH net] net: ethtool: pse-pd: Fix possible null-deref
Date: Tue, 9 Jul 2024 08:52:05 -0700	[thread overview]
Message-ID: <20240709085205.0fa41f8f@kernel.org> (raw)
In-Reply-To: <20240709164305.695e5612@kmaincent-XPS-13-7390>

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.

  reply	other threads:[~2024-07-09 15:52 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-09 13:12 [PATCH net] net: ethtool: pse-pd: Fix possible null-deref Kory Maincent
2024-07-09 14:18 ` Jakub Kicinski
2024-07-09 14:43   ` Kory Maincent
2024-07-09 15:52     ` Jakub Kicinski [this message]
2024-07-09 16:33       ` Kory Maincent

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=20240709085205.0fa41f8f@kernel.org \
    --to=kuba@kernel.org \
    --cc=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=kory.maincent@bootlin.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=o.rempel@pengutronix.de \
    --cc=pabeni@redhat.com \
    --cc=thomas.petazzoni@bootlin.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).