Search Linux Wireless

Re: [PATCH] wireless: Compare ethernet addresses by unaligned safe way

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, 2009-06-16 at 13:54 +0300, Yauhen Kharuzhy wrote:
> When we try to run RTL8187 driver on AD BlackFin platform, we got
> messages from kernel about unaligned memory access at
> compare_ether_addr() calls.
> 
> Replacing of compare_ether_addr() by memcmp() fixes this problem.

This shouldn't be necessary. Which operand is unaligned?

> --- a/net/mac80211/ibss.c
> +++ b/net/mac80211/ibss.c
> @@ -395,7 +395,7 @@ struct sta_info *ieee80211_ibss_add_sta(struct ieee80211_sub_if_data *sdata,
>  		return NULL;
>  	}
>  
> -	if (compare_ether_addr(bssid, sdata->u.ibss.bssid))
> +	if (memcmp(bssid, sdata->u.ibss.bssid, ETH_ALEN))
>  		return NULL;

So in this case it seems that it is possible that u.ibss.bssid is not
aligned, consider fixing by doing

--- ieee80211_i.h
+++ ieee80211_i.h
-	u8 bssid[ETH_ALEN];
+	u8 bssid[ETH_ALEN] __align(2);

or so instead.
 
> --- a/net/wireless/scan.c
> +++ b/net/wireless/scan.c
> @@ -134,7 +134,7 @@ static bool is_bss(struct cfg80211_bss *a,
>  {
>  	const u8 *ssidie;
>  
> -	if (bssid && compare_ether_addr(a->bssid, bssid))
> +	if (bssid && memcmp(a->bssid, bssid, ETH_ALEN))

Since a->bssid is after a pointer I can't see how it would be unaligned,
and bssid should be unaligned only if the call trace shows it's coming
from the above u.ibss.bssid.

johannes

Attachment: signature.asc
Description: This is a digitally signed message part


[Index of Archives]     [Linux Host AP]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Linux Kernel]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Device Mapper]
  Powered by Linux