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:   Tue, 23 Mar 2021 00:38:10 +0100
From:   Andrew Lunn <andrew@...n.ch>
To:     Cristian Ciocaltea <cristian.ciocaltea@...il.com>
Cc:     "David S. Miller" <davem@...emloft.net>,
        Jakub Kicinski <kuba@...nel.org>,
        Rob Herring <robh+dt@...nel.org>,
        Andreas Färber <afaerber@...e.de>,
        Manivannan Sadhasivam <mani@...nel.org>,
        Philipp Zabel <p.zabel@...gutronix.de>, netdev@...r.kernel.org,
        devicetree@...r.kernel.org, linux-arm-kernel@...ts.infradead.org,
        linux-actions@...ts.infradead.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH v3 2/3] net: ethernet: actions: Add Actions Semi Owl
 Ethernet MAC driver

> +static void owl_emac_set_multicast(struct net_device *netdev, int count)
> +{
> +	struct owl_emac_priv *priv = netdev_priv(netdev);
> +	struct netdev_hw_addr *ha;
> +	int index = 0;
> +
> +	if (count <= 0) {
> +		priv->mcaddr_list.count = 0;
> +		return;
> +	}
> +
> +	netdev_for_each_mc_addr(ha, netdev) {
> +		if (!is_multicast_ether_addr(ha->addr))
> +			continue;

Is this possible?

> +
> +		WARN_ON(index >= OWL_EMAC_MAX_MULTICAST_ADDRS);
> +		ether_addr_copy(priv->mcaddr_list.addrs[index++], ha->addr);
> +	}
> +
> +	priv->mcaddr_list.count = index;
> +
> +	owl_emac_setup_frame_xmit(priv);
> +}
> +
> +static void owl_emac_ndo_set_rx_mode(struct net_device *netdev)
> +{
> +	struct owl_emac_priv *priv = netdev_priv(netdev);
> +	u32 status, val = 0;
> +	int mcast_count = 0;
> +
> +	if (netdev->flags & IFF_PROMISC) {
> +		val = OWL_EMAC_BIT_MAC_CSR6_PR;
> +	} else if (netdev->flags & IFF_ALLMULTI) {
> +		val = OWL_EMAC_BIT_MAC_CSR6_PM;
> +	} else if (netdev->flags & IFF_MULTICAST) {
> +		mcast_count = netdev_mc_count(netdev);
> +
> +		if (mcast_count > OWL_EMAC_MAX_MULTICAST_ADDRS) {
> +			val = OWL_EMAC_BIT_MAC_CSR6_PM;
> +			mcast_count = 0;
> +		}
> +	}
> +
> +	spin_lock_bh(&priv->lock);
> +
> +	/* Temporarily stop DMA TX & RX. */
> +	status = owl_emac_dma_cmd_stop(priv);
> +
> +	/* Update operation modes. */
> +	owl_emac_reg_update(priv, OWL_EMAC_REG_MAC_CSR6,
> +			    OWL_EMAC_BIT_MAC_CSR6_PR | OWL_EMAC_BIT_MAC_CSR6_PM,
> +			    val);
> +
> +	/* Restore DMA TX & RX status. */
> +	owl_emac_dma_cmd_set(priv, status);
> +
> +	spin_unlock_bh(&priv->lock);
> +
> +	/* Set/reset multicast addr list. */
> +	owl_emac_set_multicast(netdev, mcast_count);
> +}

I think this can be simplified. At least, you had me going around in
circles a while trying to see if WARN_ON() could be triggered from
user space.

If you have more than OWL_EMAC_MAX_MULTICAST_ADDRS MC addresses, you
go into promisc mode. Can you then skip calling
owl_emac_set_multicast(), which appears not to do too much useful when
passed 0?

       Andrew

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ