Skip to content

Commit 948f991

Browse files
hdellerkuba-moo
authored andcommitted
wireguard: allowedips: avoid unaligned 64-bit memory accesses
On the parisc platform, the kernel issues kernel warnings because swap_endian() tries to load a 128-bit IPv6 address from an unaligned memory location: Kernel: unaligned access to 0x55f4688c in wg_allowedips_insert_v6+0x2c/0x80 [wireguard] (iir 0xf3010df) Kernel: unaligned access to 0x55f46884 in wg_allowedips_insert_v6+0x38/0x80 [wireguard] (iir 0xf2010dc) Avoid such unaligned memory accesses by instead using the get_unaligned_be64() helper macro. Signed-off-by: Helge Deller <[email protected]> [Jason: replace src[8] in original patch with src+8] Cc: [email protected] Fixes: e7096c1 ("net: WireGuard secure network tunnel") Signed-off-by: Jason A. Donenfeld <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 2cb489e commit 948f991

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

drivers/net/wireguard/allowedips.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ static void swap_endian(u8 *dst, const u8 *src, u8 bits)
1515
if (bits == 32) {
1616
*(u32 *)dst = be32_to_cpu(*(const __be32 *)src);
1717
} else if (bits == 128) {
18-
((u64 *)dst)[0] = be64_to_cpu(((const __be64 *)src)[0]);
19-
((u64 *)dst)[1] = be64_to_cpu(((const __be64 *)src)[1]);
18+
((u64 *)dst)[0] = get_unaligned_be64(src);
19+
((u64 *)dst)[1] = get_unaligned_be64(src + 8);
2020
}
2121
}
2222

0 commit comments

Comments
 (0)