[PATCH net] neighbour: fix unaligned access to pneigh_entry

Qingfang DENG posted 1 patch 2 years, 8 months ago
There is a newer version of this series
include/net/neighbour.h | 4 ++++
1 file changed, 4 insertions(+)
[PATCH net] neighbour: fix unaligned access to pneigh_entry
Posted by Qingfang DENG 2 years, 8 months ago
From: Qingfang DENG <qingfang.deng@siflower.com.cn>

After the blamed commit, the member key is longer 4-byte aligned. On
platforms that do not support unaligned access, e.g., MIPS32R2 with
unaligned_action set to 2, this will trigger a crash when accessing
an IPv6 pneigh_entry, as the key is cast to an in6_addr pointer.

Align the member to 4 bytes on said platforms.

Fixes: 62dd93181aaa ("[IPV6] NDISC: Set per-entry is_router flag in Proxy NA.")
Signed-off-by: Qingfang DENG <qingfang.deng@siflower.com.cn>
---
 include/net/neighbour.h | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/include/net/neighbour.h b/include/net/neighbour.h
index 3fa5774bddac..c0195ed9d111 100644
--- a/include/net/neighbour.h
+++ b/include/net/neighbour.h
@@ -180,7 +180,11 @@ struct pneigh_entry {
 	netdevice_tracker	dev_tracker;
 	u32			flags;
 	u8			protocol;
+#ifdef CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS
 	u8			key[];
+#else
+	u8			key[] __aligned(4);
+#endif
 };
 
 /*
-- 
2.34.1