netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Jason A. Donenfeld" <Jason@zx2c4.com>
To: netdev@vger.kernel.org, davem@davemloft.net
Subject: [PATCH net 2/7] wireguard: socket: remove bogus __be32 annotation
Date: Mon, 22 Feb 2021 17:25:44 +0100	[thread overview]
Message-ID: <20210222162549.3252778-3-Jason@zx2c4.com> (raw)
In-Reply-To: <20210222162549.3252778-1-Jason@zx2c4.com>

From: Jann Horn <jannh@google.com>

The endpoint->src_if4 has nothing to do with fixed-endian numbers; remove
the bogus annotation.

This was introduced in
https://git.zx2c4.com/wireguard-monolithic-historical/commit?id=14e7d0a499a676ec55176c0de2f9fcbd34074a82
in the historical WireGuard repo because the old code used to
zero-initialize multiple members as follows:

    endpoint->src4.s_addr = endpoint->src_if4 = fl.saddr = 0;

Because fl.saddr is fixed-endian and an assignment returns a value with the
type of its left operand, this meant that sparse detected an assignment
between values of different endianness.

Since then, this assignment was already split up into separate statements;
just the cast survived.

Signed-off-by: Jann Horn <jannh@google.com>
Fixes: e7096c131e51 ("net: WireGuard secure network tunnel")
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
---
 drivers/net/wireguard/socket.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/wireguard/socket.c b/drivers/net/wireguard/socket.c
index 41430c0e465a..d9ad850daa79 100644
--- a/drivers/net/wireguard/socket.c
+++ b/drivers/net/wireguard/socket.c
@@ -53,7 +53,7 @@ static int send4(struct wg_device *wg, struct sk_buff *skb,
 		if (unlikely(!inet_confirm_addr(sock_net(sock), NULL, 0,
 						fl.saddr, RT_SCOPE_HOST))) {
 			endpoint->src4.s_addr = 0;
-			*(__force __be32 *)&endpoint->src_if4 = 0;
+			endpoint->src_if4 = 0;
 			fl.saddr = 0;
 			if (cache)
 				dst_cache_reset(cache);
@@ -63,7 +63,7 @@ static int send4(struct wg_device *wg, struct sk_buff *skb,
 			     PTR_ERR(rt) == -EINVAL) || (!IS_ERR(rt) &&
 			     rt->dst.dev->ifindex != endpoint->src_if4)))) {
 			endpoint->src4.s_addr = 0;
-			*(__force __be32 *)&endpoint->src_if4 = 0;
+			endpoint->src_if4 = 0;
 			fl.saddr = 0;
 			if (cache)
 				dst_cache_reset(cache);
-- 
2.30.1


  parent reply	other threads:[~2021-02-22 16:28 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-22 16:25 [PATCH net 0/7] wireguard fixes for 5.12-rc1 Jason A. Donenfeld
2021-02-22 16:25 ` [PATCH net 1/7] wireguard: avoid double unlikely() notation when using IS_ERR() Jason A. Donenfeld
2021-02-22 16:25 ` Jason A. Donenfeld [this message]
2021-02-22 16:25 ` [PATCH net 3/7] wireguard: selftests: test multiple parallel streams Jason A. Donenfeld
2021-02-22 16:25 ` [PATCH net 4/7] wireguard: peer: put frequently used members above cache lines Jason A. Donenfeld
2021-02-22 16:25 ` [PATCH net 5/7] wireguard: device: do not generate ICMP for non-IP packets Jason A. Donenfeld
2021-02-22 16:25 ` [PATCH net 6/7] wireguard: queueing: get rid of per-peer ring buffers Jason A. Donenfeld
2021-02-22 16:25 ` [PATCH net 7/7] wireguard: kconfig: use arm chacha even with no neon Jason A. Donenfeld
2021-02-24  0:02 ` [PATCH net 0/7] wireguard fixes for 5.12-rc1 Jakub Kicinski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210222162549.3252778-3-Jason@zx2c4.com \
    --to=jason@zx2c4.com \
    --cc=davem@davemloft.net \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).