linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Johannes Berg <johannes@sipsolutions.net>
To: Yauhen Kharuzhy <yauhen.kharuzhy@promwad.com>
Cc: linux-wireless@vger.kernel.org
Subject: Re: [PATCH] wireless: Compare ethernet addresses by unaligned safe way
Date: Tue, 16 Jun 2009 13:14:55 +0200	[thread overview]
Message-ID: <1245150895.8623.3.camel@johannes.local> (raw)
In-Reply-To: <1245149672-18063-1-git-send-email-yauhen.kharuzhy@promwad.com>

[-- Attachment #1: Type: text/plain, Size: 1353 bytes --]

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 #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 801 bytes --]

  reply	other threads:[~2009-06-16 11:15 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-06-16 10:54 [PATCH] wireless: Compare ethernet addresses by unaligned safe way Yauhen Kharuzhy
2009-06-16 11:14 ` Johannes Berg [this message]
2009-06-28 12:18   ` Ivan Kuten
2009-06-29  7:58     ` Johannes Berg
2009-07-23 17:56       ` Ivan Kuten
2009-07-23 17:59         ` Johannes Berg
2009-08-07 15:34           ` John W. Linville
2009-06-29  8:23     ` Johannes Berg

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1245150895.8623.3.camel@johannes.local \
    --to=johannes@sipsolutions.net \
    --cc=linux-wireless@vger.kernel.org \
    --cc=yauhen.kharuzhy@promwad.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).