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>] [day] [month] [year] [list]
Message-Id: <9d7849fcbb9f7220363632e35b05ef01947ba5d5.1443880173.git.maciek.borzecki@gmail.com>
Date:	Sat,  3 Oct 2015 16:01:36 +0200
From:	Maciek Borzecki <maciek.borzecki@...il.com>
To:	Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
	devel@...verdev.osuosl.org, linux-kernel@...r.kernel.org,
	Masanari Iida <standby24x7@...il.com>,
	chaehyun lim <chaehyun.lim@...il.com>,
	Andy Shevchenko <andriy.shevchenko@...ux.intel.com>,
	Ioana Ciornei <ciorneiioana@...il.com>,
	Aya Mahfouz <mahfouz.saif.elyazal@...il.com>
Cc:	Maciek Borzecki <maciek.borzecki@...il.com>
Subject: [PATCH] staging: wlan-ng: prism2sta: replace memcmp with ether_addr_equal

Replace memcmp() with ether_addr_equal(). In every location where the
replacement was done, the addresses accessed are
__aligned(2). Structures accessed either stack or heap allocated, no
direct memory casts to possibly unaligned structs are used.

Involved structures:

typedef struct hfa384x_authenticateStation_data {
	u8 address[ETH_ALEN];   /* 0 offset */
	...
} __packed hfa384x_authenticateStation_data_t;

struct prism2sta_authlist {
	unsigned int cnt;
	u8 addr[WLAN_AUTH_MAX][ETH_ALEN]; /* 4 bytes offset,
					     addresses start
					     at u16 boundary */
	u8 assoc[WLAN_AUTH_MAX];
};

struct prism2sta_accesslist {
	unsigned int modify;
	unsigned int cnt;
	u8 addr[WLAN_ACCESS_MAX][ETH_ALEN]; /* 8 bytes offset,
					       multiple of u16 */
	...
	u8 addr1[WLAN_ACCESS_MAX][ETH_ALEN]; /* starts at u32 boundary,
						struct not packed */
};

typedef struct hfa384x_AssocStatus {
	u16 assocstatus;
	u8 sta_addr[ETH_ALEN];    /* 2 bytes offset,
				     struct is packed */
	u8 old_ap_addr[ETH_ALEN]; /* 8 bytes offset */
	...
} __packed hfa384x_AssocStatus_t;

The patch resolves the following checkpatch warnings:

  WARNING: Prefer ether_addr_equal() or ether_addr_equal_unaligned()
           over memcmp()

Signed-off-by: Maciek Borzecki <maciek.borzecki@...il.com>
---
 drivers/staging/wlan-ng/prism2sta.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/staging/wlan-ng/prism2sta.c b/drivers/staging/wlan-ng/prism2sta.c
index 0329c521d17c5c0ee5baa237c81383021daefe24..2b7efe05cc8f4e30c8b43c27fccda988ad9b756e 100644
--- a/drivers/staging/wlan-ng/prism2sta.c
+++ b/drivers/staging/wlan-ng/prism2sta.c
@@ -1483,7 +1483,7 @@ static void prism2sta_inf_assocstatus(wlandevice_t *wlandev,
 	 */
 
 	for (i = 0; i < hw->authlist.cnt; i++)
-		if (memcmp(rec.sta_addr, hw->authlist.addr[i], ETH_ALEN) == 0)
+		if (ether_addr_equal(rec.sta_addr, hw->authlist.addr[i]))
 			break;
 
 	if (i >= hw->authlist.cnt) {
@@ -1565,8 +1565,8 @@ static void prism2sta_inf_authreq_defer(wlandevice_t *wlandev,
 		 */
 
 		for (i = 0; i < hw->authlist.cnt; i++)
-			if (memcmp(rec.address, hw->authlist.addr[i],
-				   ETH_ALEN) == 0) {
+			if (ether_addr_equal(rec.address,
+					     hw->authlist.addr[i])) {
 				rec.status = P80211ENUM_status_successful;
 				break;
 			}
@@ -1603,7 +1603,7 @@ static void prism2sta_inf_authreq_defer(wlandevice_t *wlandev,
 		}
 
 		for (i = 0; i < cnt; i++, addr += ETH_ALEN)
-			if (memcmp(rec.address, addr, ETH_ALEN) == 0) {
+			if (ether_addr_equal(rec.address, addr)) {
 				rec.status = P80211ENUM_status_successful;
 				break;
 			}
@@ -1633,7 +1633,7 @@ static void prism2sta_inf_authreq_defer(wlandevice_t *wlandev,
 		rec.status = P80211ENUM_status_successful;
 
 		for (i = 0; i < cnt; i++, addr += ETH_ALEN)
-			if (memcmp(rec.address, addr, ETH_ALEN) == 0) {
+			if (ether_addr_equal(rec.address, addr)) {
 				rec.status = P80211ENUM_status_unspec_failure;
 				break;
 			}
@@ -1654,8 +1654,8 @@ static void prism2sta_inf_authreq_defer(wlandevice_t *wlandev,
 
 	if (rec.status == P80211ENUM_status_successful) {
 		for (i = 0; i < hw->authlist.cnt; i++)
-			if (memcmp(rec.address, hw->authlist.addr[i], ETH_ALEN)
-			    == 0)
+			if (ether_addr_equal(rec.address,
+					     hw->authlist.addr[i]))
 				break;
 
 		if (i >= hw->authlist.cnt) {
-- 
2.6.0

--
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