Skip to content

Commit 2aec909

Browse files
committed
wifi: use struct_group to copy addresses
We sometimes copy all the addresses from the 802.11 header for the AAD, which may cause complaints from fortify checks. Use struct_group() to avoid the compiler warnings/errors. Change-Id: Ic3ea389105e7813b22095b295079eecdabde5045 Signed-off-by: Johannes Berg <johannes.berg@intel.com>
1 parent 8c04278 commit 2aec909

3 files changed

Lines changed: 8 additions & 6 deletions

File tree

include/linux/ieee80211.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -310,9 +310,11 @@ static inline u16 ieee80211_sn_sub(u16 sn1, u16 sn2)
310310
struct ieee80211_hdr {
311311
__le16 frame_control;
312312
__le16 duration_id;
313-
u8 addr1[ETH_ALEN];
314-
u8 addr2[ETH_ALEN];
315-
u8 addr3[ETH_ALEN];
313+
struct_group(addrs,
314+
u8 addr1[ETH_ALEN];
315+
u8 addr2[ETH_ALEN];
316+
u8 addr3[ETH_ALEN];
317+
);
316318
__le16 seq_ctrl;
317319
u8 addr4[ETH_ALEN];
318320
} __packed __aligned(2);

net/mac80211/wpa.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,7 @@ static u8 ccmp_gcmp_aad(struct sk_buff *skb, u8 *aad)
351351
* FC | A1 | A2 | A3 | SC | [A4] | [QC] */
352352
put_unaligned_be16(len_a, &aad[0]);
353353
put_unaligned(mask_fc, (__le16 *)&aad[2]);
354-
memcpy(&aad[4], &hdr->addr1, 3 * ETH_ALEN);
354+
memcpy(&aad[4], &hdr->addrs, 3 * ETH_ALEN);
355355

356356
/* Mask Seq#, leave Frag# */
357357
aad[22] = *((u8 *) &hdr->seq_ctrl) & 0x0f;
@@ -792,7 +792,7 @@ static void bip_aad(struct sk_buff *skb, u8 *aad)
792792
IEEE80211_FCTL_MOREDATA);
793793
put_unaligned(mask_fc, (__le16 *) &aad[0]);
794794
/* A1 || A2 || A3 */
795-
memcpy(aad + 2, &hdr->addr1, 3 * ETH_ALEN);
795+
memcpy(aad + 2, &hdr->addrs, 3 * ETH_ALEN);
796796
}
797797

798798

net/wireless/lib80211_crypt_ccmp.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ static int ccmp_init_iv_and_aad(const struct ieee80211_hdr *hdr,
136136
pos = (u8 *) hdr;
137137
aad[0] = pos[0] & 0x8f;
138138
aad[1] = pos[1] & 0xc7;
139-
memcpy(aad + 2, hdr->addr1, 3 * ETH_ALEN);
139+
memcpy(aad + 2, &hdr->addrs, 3 * ETH_ALEN);
140140
pos = (u8 *) & hdr->seq_ctrl;
141141
aad[20] = pos[0] & 0x0f;
142142
aad[21] = 0; /* all bits masked */

0 commit comments

Comments
 (0)