lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Wed, 22 May 2019 19:25:37 -0700
From:   Florian Fainelli <f.fainelli@...il.com>
To:     Ioana Ciornei <ioana.ciornei@....com>,
        "linux@...linux.org.uk" <linux@...linux.org.uk>,
        "andrew@...n.ch" <andrew@...n.ch>,
        "hkallweit1@...il.com" <hkallweit1@...il.com>,
        "maxime.chevallier@...tlin.com" <maxime.chevallier@...tlin.com>,
        "olteanv@...il.com" <olteanv@...il.com>
Cc:     "netdev@...r.kernel.org" <netdev@...r.kernel.org>,
        "davem@...emloft.net" <davem@...emloft.net>
Subject: Re: [RFC PATCH net-next 5/9] net: phylink: Add phylink_create_raw



On 5/22/2019 6:20 PM, Ioana Ciornei wrote:
> This adds a new entry point to PHYLINK that does not require a
> net_device structure.
> 
> The main intended use are DSA ports that do not have net devices
> registered for them (mainly because doing so would be redundant - see
> Documentation/networking/dsa/dsa.rst for details). So far DSA has been
> using PHYLIB fixed PHYs for these ports, driven manually with genphy
> instead of starting a full PHY state machine, but this does not scale
> well when there are actual PHYs that need a driver on those ports, or
> when a fixed-link is requested in DT that has a speed unsupported by the
> fixed PHY C22 emulation (such as SGMII-2500).
> 
> The proposed solution comes in the form of a notifier chain owned by the
> PHYLINK instance, and the passing of phylink_notifier_info structures
> back to the driver through a blocking notifier call.
> 
> The event API exposed by the new notifier mechanism is a 1:1 mapping to
> the existing PHYLINK mac_ops, plus the PHYLINK fixed-link callback.
> 
> Both the standard phylink_create() function, as well as its raw variant,
> call the same underlying function which initializes either the netdev
> field or the notifier block of the PHYLINK instance.
> 
> All PHYLINK driver callbacks have been extended to call the notifier
> chain in case the instance is a raw one.
> 
> Signed-off-by: Ioana Ciornei <ioana.ciornei@....com>
> Signed-off-by: Vladimir Oltean <olteanv@...il.com>
> ---

[snip]

> +	struct phylink_notifier_info info = {
> +		.link_an_mode = pl->link_an_mode,
> +		/* Discard const pointer */
> +		.state = (struct phylink_link_state *)state,
> +	};
> +
>  	netdev_dbg(pl->netdev,
>  		   "%s: mode=%s/%s/%s/%s adv=%*pb pause=%02x link=%u an=%u\n",
>  		   __func__, phylink_an_mode_str(pl->link_an_mode),
> @@ -299,7 +317,12 @@ static void phylink_mac_config(struct phylink *pl,
>  		   __ETHTOOL_LINK_MODE_MASK_NBITS, state->advertising,
>  		   state->pause, state->link, state->an_enabled);

Don't you need to guard that netdev_dbg() with an if (pl->ops) to avoid
de-referencing a NULL net_device?

Another possibility could be to change the signature of the
phylink_mac_ops to take an opaque pointer and in the case where we
called phylink_create() and passed down a net_device pointer, we somehow
remember that for doing any operation that requires a net_device
(printing, setting carrier). We lose strict typing in doing that, but
we'd have fewer places to patch for a blocking notifier call.
-- 
Florian

Powered by blists - more mailing lists