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, 12 Oct 2022 14:37:34 +0200
From:   Andrew Lunn <andrew@...n.ch>
To:     Christian Marangi <ansuelsmth@...il.com>
Cc:     Vivien Didelot <vivien.didelot@...il.com>,
        Florian Fainelli <f.fainelli@...il.com>,
        Vladimir Oltean <olteanv@...il.com>,
        "David S. Miller" <davem@...emloft.net>,
        Eric Dumazet <edumazet@...gle.com>,
        Jakub Kicinski <kuba@...nel.org>,
        Paolo Abeni <pabeni@...hat.com>,
        "Russell King (Oracle)" <rmk+kernel@...linux.org.uk>,
        netdev@...r.kernel.org, linux-kernel@...r.kernel.org,
        Pawel Dembicki <paweldembicki@...il.com>,
        Lech Perczak <lech.perczak@...il.com>
Subject: Re: [net PATCH 2/2] net: dsa: qca8k: fix ethtool autocast mib for
 big-endian systems

>  	struct qca8k_priv *priv = ds->priv;
>  	const struct qca8k_mib_desc *mib;
>  	struct mib_ethhdr *mib_ethhdr;
> -	int i, mib_len, offset = 0;
> -	u64 *data;
> +	__le32 *data2;
>  	u8 port;
> +	int i;
>  
>  	mib_ethhdr = (struct mib_ethhdr *)skb_mac_header(skb);
>  	mib_eth_data = &priv->mib_eth_data;
> @@ -1532,28 +1532,24 @@ static void qca8k_mib_autocast_handler(struct dsa_switch *ds, struct sk_buff *sk
>  	if (port != mib_eth_data->req_port)
>  		goto exit;
>  
> -	data = mib_eth_data->data;
> +	data2 = (__le32 *)skb->data;
>  
>  	for (i = 0; i < priv->info->mib_count; i++) {
>  		mib = &ar8327_mib[i];
>  
>  		/* First 3 mib are present in the skb head */
>  		if (i < 3) {
> -			data[i] = mib_ethhdr->data[i];
> +			mib_eth_data->data[i] = le32_to_cpu(mib_ethhdr->data[i]);
>  			continue;
>  		}
>  
> -		mib_len = sizeof(uint32_t);
> -
>  		/* Some mib are 64 bit wide */
>  		if (mib->size == 2)
> -			mib_len = sizeof(uint64_t);
> -
> -		/* Copy the mib value from packet to the */
> -		memcpy(data + i, skb->data + offset, mib_len);
> +			mib_eth_data->data[i] = le64_to_cpu(*(__le64 *)data2);
> +		else
> +			mib_eth_data->data[i] = le32_to_cpu(*data2);

Are there any alignment guarantees? The old memcpy did not care if the
source has oddly alignment. But when you start dereferencing a pointed,
you need to be sure those pointers are aligned. You might want to use
get_unaligned_le32 and get_unaligned_le64.

	   Andrew

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ