blob: b6da77d3871a47d4eeaa262317f3f4e87ef59ebd [file] [log] [blame]
Patrick Williams2194f502022-10-16 14:26:09 -05001From 37948a54f3e49fc2fef157f89d5bb52cefcfe68e Mon Sep 17 00:00:00 2001
2From: Kees Cook <keescook@chromium.org>
3Date: Sat, 12 Feb 2022 09:14:49 -0800
4Subject: [PATCH] etherdevice: Adjust ether_addr* prototypes to silence
5 -Wstringop-overead
6MIME-Version: 1.0
7Content-Type: text/plain; charset=UTF-8
8Content-Transfer-Encoding: 8bit
9
10With GCC 12, -Wstringop-overread was warning about an implicit cast from
11char[6] to char[8]. However, the extra 2 bytes are always thrown away,
12alignment doesn't matter, and the risk of hitting the edge of unallocated
13memory has been accepted, so this prototype can just be converted to a
14regular char *. Silences:
15
16net/core/dev.c: In function ‘bpf_prog_run_generic_xdp’: net/core/dev.c:4618:21: warning: ‘ether_addr_equal_64bits’ reading 8 bytes from a region of size 6 [-Wstringop-overread]
17 4618 | orig_host = ether_addr_equal_64bits(eth->h_dest, > skb->dev->dev_addr);
18 | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
19net/core/dev.c:4618:21: note: referencing argument 1 of type ‘const u8[8]’ {aka ‘const unsigned char[8]’}
20net/core/dev.c:4618:21: note: referencing argument 2 of type ‘const u8[8]’ {aka ‘const unsigned char[8]’}
21In file included from net/core/dev.c:91: include/linux/etherdevice.h:375:20: note: in a call to function ‘ether_addr_equal_64bits’
22 375 | static inline bool ether_addr_equal_64bits(const u8 addr1[6+2],
23 | ^~~~~~~~~~~~~~~~~~~~~~~
24
25Reported-by: Marc Kleine-Budde <mkl@pengutronix.de>
26Tested-by: Marc Kleine-Budde <mkl@pengutronix.de>
27Link: https://lore.kernel.org/netdev/20220212090811.uuzk6d76agw2vv73@pengutronix.de
28Cc: Jakub Kicinski <kuba@kernel.org>
29Cc: "David S. Miller" <davem@davemloft.net>
30Cc: netdev@vger.kernel.org
31Signed-off-by: Kees Cook <keescook@chromium.org>
32Signed-off-by: David S. Miller <davem@davemloft.net>
33
34Upstream-Status: Backport [https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=2618a0dae09ef37728dab89ff60418cbe25ae6bd]
35Change-Id: I41ed4ace65094964eacddf0c56f9fc779f7d4e0c
36Signed-off-by: Davidson K <davidson.kumaresan@arm.com>
37---
38 include/linux/etherdevice.h | 5 ++---
39 1 file changed, 2 insertions(+), 3 deletions(-)
40
41diff --git a/include/linux/etherdevice.h b/include/linux/etherdevice.h
42index c58d50451485..7f28fa702bb7 100644
43--- a/include/linux/etherdevice.h
44+++ b/include/linux/etherdevice.h
45@@ -127,7 +127,7 @@ static inline bool is_multicast_ether_addr(const u8 *addr)
46 #endif
47 }
48
49-static inline bool is_multicast_ether_addr_64bits(const u8 addr[6+2])
50+static inline bool is_multicast_ether_addr_64bits(const u8 *addr)
51 {
52 #if defined(CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS) && BITS_PER_LONG == 64
53 #ifdef __BIG_ENDIAN
54@@ -364,8 +364,7 @@ static inline bool ether_addr_equal(const u8 *addr1, const u8 *addr2)
55 * Please note that alignment of addr1 & addr2 are only guaranteed to be 16 bits.
56 */
57
58-static inline bool ether_addr_equal_64bits(const u8 addr1[6+2],
59- const u8 addr2[6+2])
60+static inline bool ether_addr_equal_64bits(const u8 *addr1, const u8 *addr2)
61 {
62 #if defined(CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS) && BITS_PER_LONG == 64
63 u64 fold = (*(const u64 *)addr1) ^ (*(const u64 *)addr2);
64--
652.34.1
66