diff mbox series

net: b44: fix clang-specific fortify warning

Message ID 20240112103743.188072-1-dmantipov@yandex.ru (mailing list archive)
State Deferred
Delegated to: Netdev Maintainers
Headers show
Series net: b44: fix clang-specific fortify warning | expand

Checks

Context Check Description
netdev/series_format warning Single patches do not need cover letters; Target tree name not specified in the subject
netdev/tree_selection success Guessed tree name to be net-next
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 1092 this patch: 1092
netdev/cc_maintainers success CCed 0 of 0 maintainers
netdev/build_clang success Errors and warnings before: 1109 this patch: 1107
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 1107 this patch: 1107
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 8 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Dmitry Antipov Jan. 12, 2024, 10:37 a.m. UTC
When compiling with clang 17.0.6 and CONFIG_FORTIFY_SOURCE=y, I've
noticed the following warning (somewhat confusing due to absence of
an actual source code location):

In file included from ./drivers/net/ethernet/broadcom/b44.c:17:
In file included from ./include/linux/module.h:13:
In file included from ./include/linux/stat.h:6:
In file included from ./arch/arm64/include/asm/stat.h:12:
In file included from ./include/linux/time.h:60:
In file included from ./include/linux/time32.h:13:
In file included from ./include/linux/timex.h:67:
In file included from ./arch/arm64/include/asm/timex.h:8:
In file included from ./arch/arm64/include/asm/arch_timer.h:12:
In file included from ./arch/arm64/include/asm/hwcap.h:9:
In file included from ./arch/arm64/include/asm/cpufeature.h:26:
In file included from ./include/linux/cpumask.h:12:
In file included from ./include/linux/bitmap.h:12:
In file included from ./include/linux/string.h:295:
./include/linux/fortify-string.h:588:4: warning: call to '__read_overflow2_field'
declared with 'warning' attribute: detected read beyond size of field (2nd parameter);
maybe use struct_group()? [-Wattribute-warning]
  588 |                         __read_overflow2_field(q_size_field, size);
      |                         ^

The compiler actually complains on 'b44_get_strings()' because the
fortification logic inteprets call to 'memcpy()' as an attempt to
copy the whole array from its first member and so issues an overread
warning. This warning may be silenced by passing an address of the
whole array and not the first member to 'memcpy()'.

Signed-off-by: Dmitry Antipov <dmantipov@yandex.ru>
---
 drivers/net/ethernet/broadcom/b44.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Simon Horman Jan. 13, 2024, 3:56 p.m. UTC | #1
On Fri, Jan 12, 2024 at 01:37:33PM +0300, Dmitry Antipov wrote:
> When compiling with clang 17.0.6 and CONFIG_FORTIFY_SOURCE=y, I've
> noticed the following warning (somewhat confusing due to absence of
> an actual source code location):
> 
> In file included from ./drivers/net/ethernet/broadcom/b44.c:17:
> In file included from ./include/linux/module.h:13:
> In file included from ./include/linux/stat.h:6:
> In file included from ./arch/arm64/include/asm/stat.h:12:
> In file included from ./include/linux/time.h:60:
> In file included from ./include/linux/time32.h:13:
> In file included from ./include/linux/timex.h:67:
> In file included from ./arch/arm64/include/asm/timex.h:8:
> In file included from ./arch/arm64/include/asm/arch_timer.h:12:
> In file included from ./arch/arm64/include/asm/hwcap.h:9:
> In file included from ./arch/arm64/include/asm/cpufeature.h:26:
> In file included from ./include/linux/cpumask.h:12:
> In file included from ./include/linux/bitmap.h:12:
> In file included from ./include/linux/string.h:295:
> ./include/linux/fortify-string.h:588:4: warning: call to '__read_overflow2_field'
> declared with 'warning' attribute: detected read beyond size of field (2nd parameter);
> maybe use struct_group()? [-Wattribute-warning]
>   588 |                         __read_overflow2_field(q_size_field, size);
>       |                         ^
> 
> The compiler actually complains on 'b44_get_strings()' because the
> fortification logic inteprets call to 'memcpy()' as an attempt to
> copy the whole array from its first member and so issues an overread
> warning. This warning may be silenced by passing an address of the
> whole array and not the first member to 'memcpy()'.
> 
> Signed-off-by: Dmitry Antipov <dmantipov@yandex.ru>

This patch is for net-next, when reposting please annotate this
in the subject.

	Subject: [PATCH net-next v2] ...

[adapted from text by Jakub]

## Form letter - net-next-closed

The merge window for v6.8 has begun and therefore net-next is closed
for new drivers, features, code refactoring and optimizations.
We are currently accepting bug fixes only.

Please repost when net-next reopens on or after 22nd January.

RFC patches sent for review only are obviously welcome at any time.

See: https://www.kernel.org/doc/html/next/process/maintainer-netdev.html#development-cycle
--
pw-bot: defer
diff mbox series

Patch

diff --git a/drivers/net/ethernet/broadcom/b44.c b/drivers/net/ethernet/broadcom/b44.c
index 3e4fb3c3e834..d87d995a1a15 100644
--- a/drivers/net/ethernet/broadcom/b44.c
+++ b/drivers/net/ethernet/broadcom/b44.c
@@ -2027,7 +2027,7 @@  static void b44_get_strings(struct net_device *dev, u32 stringset, u8 *data)
 {
 	switch(stringset) {
 	case ETH_SS_STATS:
-		memcpy(data, *b44_gstrings, sizeof(b44_gstrings));
+		memcpy(data, b44_gstrings, sizeof(b44_gstrings));
 		break;
 	}
 }