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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-id: <000101cf426d$cba30240$62e906c0$%han@samsung.com>
Date:	Tue, 18 Mar 2014 14:49:15 +0900
From:	Jingoo Han <jg1.han@...sung.com>
To:	'Joel Pelaez Jorge' <joelpelaez@...il.com>
Cc:	'Greg Kroah-Hartman' <gregkh@...uxfoundation.org>,
	'Joe Perches' <joe@...ches.com>,
	'Rashika Kheria' <rashika.kheria@...il.com>,
	'Peter P Waskiewicz Jr' <peter.p.waskiewicz.jr@...el.com>,
	linux-kernel@...r.kernel.org, devel@...verdev.osuosl.org,
	'Wei Yongjun' <yongjun_wei@...ndmicro.com.cn>,
	'Dan Carpenter' <dan.carpenter@...cle.com>,
	'Jingoo Han' <jg1.han@...sung.com>
Subject: Re: [PATCH] staging: slicoss: Fix prefer ether_addr_copy over memcpy

On Tuesday, March 18, 2014 2:04 PM, Joel Pelaez Jorge wrote:
> 
> This patch fixes the following checkpatch.pl issues caused by the new
> function: ether_addr_copy
> 
> Signed-off-by: Joel Pelaez Jorge <joelpelaez@...il.com>
> ---
>   drivers/staging/slicoss/slicoss.c |   20 ++++++++++----------
>   1 file changed, 10 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/staging/slicoss/slicoss.c
> b/drivers/staging/slicoss/slicoss.c
> index 12aafe3..0e0e374 100644
> --- a/drivers/staging/slicoss/slicoss.c
> +++ b/drivers/staging/slicoss/slicoss.c
> @@ -581,15 +581,15 @@ static void slic_adapter_set_hwaddr(struct adapter
> *adapter)
>   	struct sliccard *card = adapter->card;
> 
>   	if ((adapter->card) && (card->config_set)) {
> -		memcpy(adapter->macaddr,
> -		       card->config.MacInfo[adapter->functionnumber].macaddrA,
> -		       sizeof(struct slic_config_mac));
> +		ether_addr_copy(adapter->macaddr,
> +				card->config.MacInfo[adapter->functionnumber]
> +				.macaddrA);

As declared in ./include/linux/etherdevice.h,
Copied size should be a six-byte.

static inline void ether_addr_copy(u8 *dst, const u8 *src)
{
#if defined(CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS)
        *(u32 *)dst = *(const u32 *)src;
        *(u16 *)(dst + 4) = *(const u16 *)(src + 4);
#else
        u16 *a = (u16 *)dst;
        const u16 *b = (const u16 *)src;

        a[0] = b[0];
        a[1] = b[1];
        a[2] = b[2];
#endif
}

In this case, sizeof(struct slic_config_mac) will be 6 byte,
as below. So, it looks good.

./drivers/staging/slicoss/slichw.h
struct slic_config_mac {
        u8 macaddrA[6];
};

>   		if (is_zero_ether_addr(adapter->currmacaddr))
> -			memcpy(adapter->currmacaddr, adapter->macaddr,
> -			       ETH_ALEN);
> +			ether_addr_copy(adapter->currmacaddr,
> +					adapter->macaddr);
>   		if (adapter->netdev)
> -			memcpy(adapter->netdev->dev_addr, adapter->currmacaddr,
> -			       ETH_ALEN);
> +			ether_addr_copy(adapter->netdev->dev_addr,
> +					adapter->currmacaddr);
>   	}
>   }

ETH_ALEN is defined as 6. It looks good, too.

./include/uapi/linux/if_ether.h
#define ETH_ALEN     6

> 
> @@ -810,8 +810,8 @@ static int slic_mac_set_address(struct net_device
> *dev, void *ptr)
>   	if (!is_valid_ether_addr(addr->sa_data))
>   		return -EINVAL;
> 
> -	memcpy(dev->dev_addr, addr->sa_data, dev->addr_len);
> -	memcpy(adapter->currmacaddr, addr->sa_data, dev->addr_len);
> +	ether_addr_copy(dev->dev_addr, addr->sa_data);
> +	ether_addr_copy(adapter->currmacaddr, addr->sa_data);

By the way, I am wondering if 'dev->addr_len' is 6 bytes.
Is there anyone who can confirm it?

If nobody can confirm 'dev->addr_len' is 6 bytes, it should
not be changed to 'ether_addr_copy()'.

Best regards,
Jingoo Han

> 
>   	slic_config_set(adapter, true);
>   	return 0;
> @@ -2313,7 +2313,7 @@ static int slic_mcast_add_list(struct adapter
> *adapter, char *address)
>   	if (mcaddr == NULL)
>   		return 1;
> 
> -	memcpy(mcaddr->address, address, ETH_ALEN);
> +	ether_addr_copy(mcaddr->address, address);
> 
>   	mcaddr->next = adapter->mcastaddrs;
>   	adapter->mcastaddrs = mcaddr;
> --
> 1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ