b.liu | e958203 | 2025-04-17 19:18:16 +0800 | [diff] [blame] | 1 | From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 |
| 2 | From: Jann Horn <jannh@google.com> |
| 3 | Date: Mon, 22 Feb 2021 17:25:44 +0100 |
| 4 | Subject: [PATCH] wireguard: socket: remove bogus __be32 annotation |
| 5 | |
| 6 | commit 7f57bd8dc22de35ddd895294aa554003e4f19a72 upstream. |
| 7 | |
| 8 | The endpoint->src_if4 has nothing to do with fixed-endian numbers; remove |
| 9 | the bogus annotation. |
| 10 | |
| 11 | This was introduced in |
| 12 | https://git.zx2c4.com/wireguard-monolithic-historical/commit?id=14e7d0a499a676ec55176c0de2f9fcbd34074a82 |
| 13 | in the historical WireGuard repo because the old code used to |
| 14 | zero-initialize multiple members as follows: |
| 15 | |
| 16 | endpoint->src4.s_addr = endpoint->src_if4 = fl.saddr = 0; |
| 17 | |
| 18 | Because fl.saddr is fixed-endian and an assignment returns a value with the |
| 19 | type of its left operand, this meant that sparse detected an assignment |
| 20 | between values of different endianness. |
| 21 | |
| 22 | Since then, this assignment was already split up into separate statements; |
| 23 | just the cast survived. |
| 24 | |
| 25 | Signed-off-by: Jann Horn <jannh@google.com> |
| 26 | Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com> |
| 27 | Signed-off-by: Jakub Kicinski <kuba@kernel.org> |
| 28 | Signed-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); |