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]
Message-ID: <20221021141234.rgzd3znogpmm26tf@skbuf>
Date:   Fri, 21 Oct 2022 14:12:35 +0000
From:   Vladimir Oltean <vladimir.oltean@....com>
To:     Maxime Chevallier <maxime.chevallier@...tlin.com>
CC:     "davem@...emloft.net" <davem@...emloft.net>,
        Rob Herring <robh+dt@...nel.org>,
        Krzysztof Kozlowski <krzysztof.kozlowski@...aro.org>,
        "netdev@...r.kernel.org" <netdev@...r.kernel.org>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
        "devicetree@...r.kernel.org" <devicetree@...r.kernel.org>,
        "thomas.petazzoni@...tlin.com" <thomas.petazzoni@...tlin.com>,
        Andrew Lunn <andrew@...n.ch>,
        Florian Fainelli <f.fainelli@...il.com>,
        Heiner Kallweit <hkallweit1@...il.com>,
        Russell King <linux@...linux.org.uk>,
        "linux-arm-kernel@...ts.infradead.org" 
        <linux-arm-kernel@...ts.infradead.org>,
        Luka Perkov <luka.perkov@...tura.hr>,
        Robert Marko <robert.marko@...tura.hr>
Subject: Re: [PATCH net-next v5 4/5] net: ipqess: Add out-of-band DSA tagging
 support

On Fri, Oct 21, 2022 at 02:45:55PM +0200, Maxime Chevallier wrote:
> +static int ipqess_netdevice_event(struct notifier_block *nb,
> +				  unsigned long event, void *ptr)
> +{
> +	struct ipqess *ess = container_of(nb, struct ipqess, netdev_notifier);
> +	struct net_device *dev = netdev_notifier_info_to_dev(ptr);
> +	struct netdev_notifier_changeupper_info *info;
> +
> +	switch (event) {
> +	case NETDEV_CHANGEUPPER:
> +		info = ptr;
> +
> +		if (dev->netdev_ops != &ipqess_axi_netdev_ops)
> +			return NOTIFY_DONE;
> +
> +		if (!dsa_slave_dev_check(info->upper_dev))
> +			return NOTIFY_DONE;
> +
> +		if (info->linking)
> +			ess->dsa_ports++;
> +		else
> +			ess->dsa_ports--;

How many ipqess devices are there in a system? The netdev notifier
should be a singleton, meaning it should be registered at module_init()
and unregistered at module_exit(). You can then get the "ess" pointer as
netdev_priv(dev), once you ensure that dev->netdev_ops is what you expect.

The code is already wrong: you take *ess from the &ess->netdev_notifier
reference, then you increment ess->dsa_ports based on the sole condition
that "dev" (the interface on which the notification was already emitted)
was an ess netdevice. But the "dev" pointer could be ess1, and the "ess"
pointer could be the netdev_priv(ess0). Your logic would increment the
dsa_ports of ess0 when a DSA switch joined ess1 (because all notifier
handlers see the event).

> +
> +		return NOTIFY_DONE;
> +	}
> +	return NOTIFY_OK;
> +}
> +
> @@ -1201,12 +1255,19 @@ static int ipqess_axi_probe(struct platform_device *pdev)
>  		netif_napi_add(netdev, &ess->rx_ring[i].napi_rx, ipqess_rx_napi);
>  	}
>  
> -	err = register_netdev(netdev);
> +	ess->netdev_notifier.notifier_call = ipqess_netdevice_event;
> +	err = register_netdevice_notifier(&ess->netdev_notifier);
>  	if (err)
>  		goto err_hw_stop;
>  
> +	err = register_netdev(netdev);
> +	if (err)
> +		goto err_notifier_unregister;
> +
>  	return 0;
>  
> +err_notifier_unregister:
> +	unregister_netdevice_notifier(&ess->netdev_notifier);
>  err_hw_stop:
>  	ipqess_hw_stop(ess);
>  
> diff --git a/drivers/net/ethernet/qualcomm/ipqess/ipqess.h b/drivers/net/ethernet/qualcomm/ipqess/ipqess.h
> index 9a4ab6ce282a..33cccaf6f143 100644
> --- a/drivers/net/ethernet/qualcomm/ipqess/ipqess.h
> +++ b/drivers/net/ethernet/qualcomm/ipqess/ipqess.h
> @@ -171,6 +171,10 @@ struct ipqess {
>  	struct platform_device *pdev;
>  	struct phylink *phylink;
>  	struct phylink_config phylink_config;
> +
> +	struct notifier_block netdev_notifier;
> +	int dsa_ports;
> +
>  	struct ipqess_tx_ring tx_ring[IPQESS_NETDEV_QUEUES];
>  
>  	struct ipqess_statistics ipqess_stats;
> -- 
> 2.37.3
>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ