Skip to contentSkip to conversation

mac80211: fix unaligned access in mesh table hash function

PATCH New Felix Fietkau 1 participant 1 message Mar 13, 2019 mac80211

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mac80211: fix unaligned access in mesh table hash function

The pointer to the last four bytes of the address is not guaranteed to be aligned, so we need to use __get_unaligned_cpu32 here

---
 net/mac80211/mesh_pathtbl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/mac80211/mesh_pathtbl.c +1 -1
index 8822c4f3dc48..0a1148328f19 100644
@@ -23,7 +23,7 @@ static void mesh_path_free_rcu(struct mesh_table *tbl, struct mesh_path *mpath);
 static u32 mesh_table_hash(const void *addr, u32 len, u32 seed)
 {
 	/* Use last four bytes of hw addr as hash index */
-	return jhash_1word(*(u32 *)(addr+2), seed);
+	return jhash_1word(__get_unaligned_cpu32(addr+2), seed);
 }
 
 static const struct rhashtable_params mesh_rht_params = {
Signature · 1 line
2.17.0