Patrick Williams | 2194f50 | 2022-10-16 14:26:09 -0500 | [diff] [blame^] | 1 | From 37948a54f3e49fc2fef157f89d5bb52cefcfe68e Mon Sep 17 00:00:00 2001 |
| 2 | From: Kees Cook <keescook@chromium.org> |
| 3 | Date: Sat, 12 Feb 2022 09:14:49 -0800 |
| 4 | Subject: [PATCH] etherdevice: Adjust ether_addr* prototypes to silence |
| 5 | -Wstringop-overead |
| 6 | MIME-Version: 1.0 |
| 7 | Content-Type: text/plain; charset=UTF-8 |
| 8 | Content-Transfer-Encoding: 8bit |
| 9 | |
| 10 | With GCC 12, -Wstringop-overread was warning about an implicit cast from |
| 11 | char[6] to char[8]. However, the extra 2 bytes are always thrown away, |
| 12 | alignment doesn't matter, and the risk of hitting the edge of unallocated |
| 13 | memory has been accepted, so this prototype can just be converted to a |
| 14 | regular char *. Silences: |
| 15 | |
| 16 | net/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 | | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 19 | net/core/dev.c:4618:21: note: referencing argument 1 of type ‘const u8[8]’ {aka ‘const unsigned char[8]’} |
| 20 | net/core/dev.c:4618:21: note: referencing argument 2 of type ‘const u8[8]’ {aka ‘const unsigned char[8]’} |
| 21 | In 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 | |
| 25 | Reported-by: Marc Kleine-Budde <mkl@pengutronix.de> |
| 26 | Tested-by: Marc Kleine-Budde <mkl@pengutronix.de> |
| 27 | Link: https://lore.kernel.org/netdev/20220212090811.uuzk6d76agw2vv73@pengutronix.de |
| 28 | Cc: Jakub Kicinski <kuba@kernel.org> |
| 29 | Cc: "David S. Miller" <davem@davemloft.net> |
| 30 | Cc: netdev@vger.kernel.org |
| 31 | Signed-off-by: Kees Cook <keescook@chromium.org> |
| 32 | Signed-off-by: David S. Miller <davem@davemloft.net> |
| 33 | |
| 34 | Upstream-Status: Backport [https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=2618a0dae09ef37728dab89ff60418cbe25ae6bd] |
| 35 | Change-Id: I41ed4ace65094964eacddf0c56f9fc779f7d4e0c |
| 36 | Signed-off-by: Davidson K <davidson.kumaresan@arm.com> |
| 37 | --- |
| 38 | include/linux/etherdevice.h | 5 ++--- |
| 39 | 1 file changed, 2 insertions(+), 3 deletions(-) |
| 40 | |
| 41 | diff --git a/include/linux/etherdevice.h b/include/linux/etherdevice.h |
| 42 | index 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 | -- |
| 65 | 2.34.1 |
| 66 | |