blob: 1796f54de9a574b65383ef7b945a8948d637767e [file] [log] [blame]
b.liue9582032025-04-17 19:18:16 +08001From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2From: Jann Horn <jannh@google.com>
3Date: Mon, 22 Feb 2021 17:25:44 +0100
4Subject: [PATCH] wireguard: socket: remove bogus __be32 annotation
5
6commit 7f57bd8dc22de35ddd895294aa554003e4f19a72 upstream.
7
8The endpoint->src_if4 has nothing to do with fixed-endian numbers; remove
9the bogus annotation.
10
11This was introduced in
12https://git.zx2c4.com/wireguard-monolithic-historical/commit?id=14e7d0a499a676ec55176c0de2f9fcbd34074a82
13in the historical WireGuard repo because the old code used to
14zero-initialize multiple members as follows:
15
16 endpoint->src4.s_addr = endpoint->src_if4 = fl.saddr = 0;
17
18Because fl.saddr is fixed-endian and an assignment returns a value with the
19type of its left operand, this meant that sparse detected an assignment
20between values of different endianness.
21
22Since then, this assignment was already split up into separate statements;
23just the cast survived.
24
25Signed-off-by: Jann Horn <jannh@google.com>
26Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
27Signed-off-by: Jakub Kicinski <kuba@kernel.org>
28Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
29---
30 drivers/net/wireguard/socket.c | 4 ++--
31 1 file changed, 2 insertions(+), 2 deletions(-)
32
33--- a/drivers/net/wireguard/socket.c
34+++ b/drivers/net/wireguard/socket.c
35@@ -53,7 +53,7 @@ static int send4(struct wg_device *wg, s
36 if (unlikely(!inet_confirm_addr(sock_net(sock), NULL, 0,
37 fl.saddr, RT_SCOPE_HOST))) {
38 endpoint->src4.s_addr = 0;
39- *(__force __be32 *)&endpoint->src_if4 = 0;
40+ endpoint->src_if4 = 0;
41 fl.saddr = 0;
42 if (cache)
43 dst_cache_reset(cache);
44@@ -63,7 +63,7 @@ static int send4(struct wg_device *wg, s
45 PTR_ERR(rt) == -EINVAL) || (!IS_ERR(rt) &&
46 rt->dst.dev->ifindex != endpoint->src_if4)))) {
47 endpoint->src4.s_addr = 0;
48- *(__force __be32 *)&endpoint->src_if4 = 0;
49+ endpoint->src_if4 = 0;
50 fl.saddr = 0;
51 if (cache)
52 dst_cache_reset(cache);