* Re: [PATCH] can: rockchip_canfd: fix return type of rkcanfd_start_xmit()
@ 2024-09-09 8:57 ` Marc Kleine-Budde
0 siblings, 0 replies; 18+ messages in thread
From: Marc Kleine-Budde @ 2024-09-09 8:57 UTC (permalink / raw)
To: Simon Horman
Cc: Nathan Chancellor, kernel, Vincent Mailhol, David S. Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni, Heiko Stuebner,
linux-can, netdev, linux-arm-kernel, linux-rockchip, llvm,
patches
[-- Attachment #1.1: Type: text/plain, Size: 2028 bytes --]
On 09.09.2024 09:44:48, Simon Horman wrote:
> On Fri, Sep 06, 2024 at 01:26:41PM -0700, Nathan Chancellor wrote:
> > With clang's kernel control flow integrity (kCFI, CONFIG_CFI_CLANG),
> > indirect call targets are validated against the expected function
> > pointer prototype to make sure the call target is valid to help mitigate
> > ROP attacks. If they are not identical, there is a failure at run time,
> > which manifests as either a kernel panic or thread getting killed. A
> > warning in clang aims to catch these at compile time, which reveals:
> >
> > drivers/net/can/rockchip/rockchip_canfd-core.c:770:20: error: incompatible function pointer types initializing 'netdev_tx_t (*)(struct sk_buff *, struct net_device *)' (aka 'enum netdev_tx (*)(struct sk_buff *, struct net_device *)') with an expression of type 'int (struct sk_buff *, struct net_device *)' [-Werror,-Wincompatible-function-pointer-types-strict]
> > 770 | .ndo_start_xmit = rkcanfd_start_xmit,
> > | ^~~~~~~~~~~~~~~~~~
> >
> > ->ndo_start_xmit() in 'struct net_device_ops' expects a return type of
> > 'netdev_tx_t', not 'int' (although the types are ABI compatible). Adjust
> > the return type of rkcanfd_start_xmit() to match the prototype's to
> > resolve the warning.
> >
> > Fixes: ff60bfbaf67f ("can: rockchip_canfd: add driver for Rockchip CAN-FD controller")
> > Signed-off-by: Nathan Chancellor <nathan@kernel.org>
>
> Thanks, I was able to reproduce this problem at build time
> and that your patch addresses it.
FTR: the default clang in Debian unstable, clang-16.0.6 doesn't support
this. With clang-20 from experimental it works, haven't checked older
versions, though.
regards,
Marc
--
Pengutronix e.K. | Marc Kleine-Budde |
Embedded Linux | https://www.pengutronix.de |
Vertretung Nürnberg | Phone: +49-5121-206917-129 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-9 |
[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
[-- Attachment #2: Type: text/plain, Size: 170 bytes --]
_______________________________________________
Linux-rockchip mailing list
Linux-rockchip@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-rockchip
^ permalink raw reply [flat|nested] 18+ messages in thread* Re: [PATCH] can: rockchip_canfd: fix return type of rkcanfd_start_xmit()
2024-09-09 8:57 ` Marc Kleine-Budde
@ 2024-09-09 14:35 ` Simon Horman
-1 siblings, 0 replies; 18+ messages in thread
From: Simon Horman @ 2024-09-09 14:35 UTC (permalink / raw)
To: Marc Kleine-Budde
Cc: Nathan Chancellor, kernel, Vincent Mailhol, David S. Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni, Heiko Stuebner,
linux-can, netdev, linux-arm-kernel, linux-rockchip, llvm,
patches
On Mon, Sep 09, 2024 at 10:57:06AM +0200, Marc Kleine-Budde wrote:
> On 09.09.2024 09:44:48, Simon Horman wrote:
> > On Fri, Sep 06, 2024 at 01:26:41PM -0700, Nathan Chancellor wrote:
> > > With clang's kernel control flow integrity (kCFI, CONFIG_CFI_CLANG),
> > > indirect call targets are validated against the expected function
> > > pointer prototype to make sure the call target is valid to help mitigate
> > > ROP attacks. If they are not identical, there is a failure at run time,
> > > which manifests as either a kernel panic or thread getting killed. A
> > > warning in clang aims to catch these at compile time, which reveals:
> > >
> > > drivers/net/can/rockchip/rockchip_canfd-core.c:770:20: error: incompatible function pointer types initializing 'netdev_tx_t (*)(struct sk_buff *, struct net_device *)' (aka 'enum netdev_tx (*)(struct sk_buff *, struct net_device *)') with an expression of type 'int (struct sk_buff *, struct net_device *)' [-Werror,-Wincompatible-function-pointer-types-strict]
> > > 770 | .ndo_start_xmit = rkcanfd_start_xmit,
> > > | ^~~~~~~~~~~~~~~~~~
> > >
> > > ->ndo_start_xmit() in 'struct net_device_ops' expects a return type of
> > > 'netdev_tx_t', not 'int' (although the types are ABI compatible). Adjust
> > > the return type of rkcanfd_start_xmit() to match the prototype's to
> > > resolve the warning.
> > >
> > > Fixes: ff60bfbaf67f ("can: rockchip_canfd: add driver for Rockchip CAN-FD controller")
> > > Signed-off-by: Nathan Chancellor <nathan@kernel.org>
> >
> > Thanks, I was able to reproduce this problem at build time
> > and that your patch addresses it.
>
> FTR: the default clang in Debian unstable, clang-16.0.6 doesn't support
> this. With clang-20 from experimental it works, haven't checked older
> versions, though.
FTR: I checked using 18.1.8 from here [1][2].
[1] https://mirrors.edge.kernel.org/pub/tools/llvm/
[2] https://mirrors.edge.kernel.org/pub/tools/llvm/files/
^ permalink raw reply [flat|nested] 18+ messages in thread* Re: [PATCH] can: rockchip_canfd: fix return type of rkcanfd_start_xmit()
@ 2024-09-09 14:35 ` Simon Horman
0 siblings, 0 replies; 18+ messages in thread
From: Simon Horman @ 2024-09-09 14:35 UTC (permalink / raw)
To: Marc Kleine-Budde
Cc: Nathan Chancellor, kernel, Vincent Mailhol, David S. Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni, Heiko Stuebner,
linux-can, netdev, linux-arm-kernel, linux-rockchip, llvm,
patches
On Mon, Sep 09, 2024 at 10:57:06AM +0200, Marc Kleine-Budde wrote:
> On 09.09.2024 09:44:48, Simon Horman wrote:
> > On Fri, Sep 06, 2024 at 01:26:41PM -0700, Nathan Chancellor wrote:
> > > With clang's kernel control flow integrity (kCFI, CONFIG_CFI_CLANG),
> > > indirect call targets are validated against the expected function
> > > pointer prototype to make sure the call target is valid to help mitigate
> > > ROP attacks. If they are not identical, there is a failure at run time,
> > > which manifests as either a kernel panic or thread getting killed. A
> > > warning in clang aims to catch these at compile time, which reveals:
> > >
> > > drivers/net/can/rockchip/rockchip_canfd-core.c:770:20: error: incompatible function pointer types initializing 'netdev_tx_t (*)(struct sk_buff *, struct net_device *)' (aka 'enum netdev_tx (*)(struct sk_buff *, struct net_device *)') with an expression of type 'int (struct sk_buff *, struct net_device *)' [-Werror,-Wincompatible-function-pointer-types-strict]
> > > 770 | .ndo_start_xmit = rkcanfd_start_xmit,
> > > | ^~~~~~~~~~~~~~~~~~
> > >
> > > ->ndo_start_xmit() in 'struct net_device_ops' expects a return type of
> > > 'netdev_tx_t', not 'int' (although the types are ABI compatible). Adjust
> > > the return type of rkcanfd_start_xmit() to match the prototype's to
> > > resolve the warning.
> > >
> > > Fixes: ff60bfbaf67f ("can: rockchip_canfd: add driver for Rockchip CAN-FD controller")
> > > Signed-off-by: Nathan Chancellor <nathan@kernel.org>
> >
> > Thanks, I was able to reproduce this problem at build time
> > and that your patch addresses it.
>
> FTR: the default clang in Debian unstable, clang-16.0.6 doesn't support
> this. With clang-20 from experimental it works, haven't checked older
> versions, though.
FTR: I checked using 18.1.8 from here [1][2].
[1] https://mirrors.edge.kernel.org/pub/tools/llvm/
[2] https://mirrors.edge.kernel.org/pub/tools/llvm/files/
_______________________________________________
Linux-rockchip mailing list
Linux-rockchip@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-rockchip
^ permalink raw reply [flat|nested] 18+ messages in thread* Re: [PATCH] can: rockchip_canfd: fix return type of rkcanfd_start_xmit()
2024-09-09 14:35 ` Simon Horman
@ 2024-09-10 9:56 ` Marc Kleine-Budde
-1 siblings, 0 replies; 18+ messages in thread
From: Marc Kleine-Budde @ 2024-09-10 9:56 UTC (permalink / raw)
To: Simon Horman, Nathan Chancellor
Cc: kernel, Vincent Mailhol, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Heiko Stuebner, linux-can, netdev,
linux-arm-kernel, linux-rockchip, llvm, patches
[-- Attachment #1: Type: text/plain, Size: 7150 bytes --]
On 09.09.2024 15:35:46, Simon Horman wrote:
> On Mon, Sep 09, 2024 at 10:57:06AM +0200, Marc Kleine-Budde wrote:
> > On 09.09.2024 09:44:48, Simon Horman wrote:
> > > On Fri, Sep 06, 2024 at 01:26:41PM -0700, Nathan Chancellor wrote:
> > > > With clang's kernel control flow integrity (kCFI, CONFIG_CFI_CLANG),
> > > > indirect call targets are validated against the expected function
> > > > pointer prototype to make sure the call target is valid to help mitigate
> > > > ROP attacks. If they are not identical, there is a failure at run time,
> > > > which manifests as either a kernel panic or thread getting killed. A
> > > > warning in clang aims to catch these at compile time, which reveals:
> > > >
> > > > drivers/net/can/rockchip/rockchip_canfd-core.c:770:20: error: incompatible function pointer types initializing 'netdev_tx_t (*)(struct sk_buff *, struct net_device *)' (aka 'enum netdev_tx (*)(struct sk_buff *, struct net_device *)') with an expression of type 'int (struct sk_buff *, struct net_device *)' [-Werror,-Wincompatible-function-pointer-types-strict]
> > > > 770 | .ndo_start_xmit = rkcanfd_start_xmit,
> > > > | ^~~~~~~~~~~~~~~~~~
> > > >
> > > > ->ndo_start_xmit() in 'struct net_device_ops' expects a return type of
> > > > 'netdev_tx_t', not 'int' (although the types are ABI compatible). Adjust
> > > > the return type of rkcanfd_start_xmit() to match the prototype's to
> > > > resolve the warning.
> > > >
> > > > Fixes: ff60bfbaf67f ("can: rockchip_canfd: add driver for Rockchip CAN-FD controller")
> > > > Signed-off-by: Nathan Chancellor <nathan@kernel.org>
> > >
> > > Thanks, I was able to reproduce this problem at build time
> > > and that your patch addresses it.
> >
> > FTR: the default clang in Debian unstable, clang-16.0.6 doesn't support
> > this. With clang-20 from experimental it works, haven't checked older
> > versions, though.
>
> FTR: I checked using 18.1.8 from here [1][2].
>
> [1] https://mirrors.edge.kernel.org/pub/tools/llvm/
> [2] https://mirrors.edge.kernel.org/pub/tools/llvm/files/
I was a bit hasty yesterday, clang-20 and W=1 produces these errors:
| include/linux/vmstat.h:517:36: error: arithmetic between different enumeration types ('enum node_stat_item' and 'enum lru_list') [-Werror,-Wenum-enum-conversion]
| 517 | return node_stat_name(NR_LRU_BASE + lru) + 3; // skip "nr_"
| | ~~~~~~~~~~~ ^ ~~~
| 1 error generated.
However I fail to reproduce the ndo_start_xmit problem. Even with 18.1.8
from kernel.org.
The following command (ARCH is unset, compiling x86 -> x86) produces the
above shown "vmstat.h" problems....
| $ make LLVM=1 LLVM_IAS=1 LLVM_SUFFIX=-20 drivers/net/can/rockchip/ W=1 CONFIG_WERROR=0
... but not the ndo_start_xmit problem.
Am I missing a vital .config option?
| $ grep "CLANG\|CFI" .config
| CONFIG_CC_IS_CLANG=y
| CONFIG_CLANG_VERSION=200000
| CONFIG_CFI_AUTO_DEFAULT=y
| CONFIG_FUNCTION_PADDING_CFI=11
| CONFIG_LTO_CLANG=y
| CONFIG_ARCH_SUPPORTS_LTO_CLANG=y
| CONFIG_ARCH_SUPPORTS_LTO_CLANG_THIN=y
| CONFIG_HAS_LTO_CLANG=y
| CONFIG_LTO_CLANG_THIN=y
| CONFIG_ARCH_SUPPORTS_CFI_CLANG=y
| CONFIG_ARCH_USES_CFI_TRAPS=y
| CONFIG_CFI_CLANG=y
| # CONFIG_CFI_PERMISSIVE is not set
V=1 gives this output:
| clang-20 -Wp,-MMD,drivers/net/can/rockchip/.rockchip_canfd-core.o.d
| -nostdinc -Iarch/x86/include -I./arch/x86/include/generated
| -Iinclude -I./include -Iarch/x86/include/uapi
| -I./arch/x86/include/generated/uapi -Iinclude/uapi
| -I./include/generated/uapi -include include/linux/compiler-version.h
| -include include/linux/kconfig.h -include
| include/linux/compiler_types.h -D__KERNEL__
| --target=x86_64-linux-gnu -fintegrated-as
| -Werror=unknown-warning-option -Werror=ignored-optimization-argument
| -Werror=option-ignored -Werror=unused-command-line-argument
| -fmacro-prefix-map== -Wundef -DKBUILD_EXTRA_WARN1 -std=gnu11
| -fshort-wchar -funsigned-char -fno-common -fno-PIE
| -fno-strict-aliasing -mno-sse -mno-mmx -mno-sse2 -mno-3dnow -mno-avx
| -fcf-protection=branch -fno-jump-tables -m64 -falign-loops=1
| -mno-80387 -mno-fp-ret-in-387 -mstack-alignment=8 -mskip-rax-setup
| -mtune=generic -mno-red-zone -mcmodel=kernel -Wno-sign-compare
| -fno-asynchronous-unwind-tables -mretpoline-external-thunk
| -mindirect-branch-cs-prefix -mfunction-return=thunk-extern
| -fpatchable-function-entry=11,11 -fno-delete-null-pointer-checks -O2
| -fstack-protector-strong -fomit-frame-pointer
| -fno-stack-clash-protection -fno-lto -flto=thin -fsplit-lto-unit
| -fvisibility=hidden -fsanitize=kcfi -falign-functions=16
| -fstrict-flex-arrays=3 -fno-strict-overflow -fno-stack-check -Wall
| -Wundef -Werror=implicit-function-declaration -Werror=implicit-int
| -Werror=return-type -Werror=strict-prototypes -Wno-format-security
| -Wno-trigraphs -Wno-frame-address -Wno-address-of-packed-member
| -Wmissing-declarations -Wmissing-prototypes -Wframe-larger-than=2048
| -Wno-gnu -Wvla -Wno-pointer-sign -Wcast-function-type
| -Wimplicit-fallthrough -Werror=date-time
| -Werror=incompatible-pointer-types -Wenum-conversion -Wextra
| -Wunused -Wmissing-format-attribute -Wmissing-include-dirs
| -Wunused-const-variable -Wno-missing-field-initializers
| -Wno-type-limits -Wno-shift-negative-value -Wno-sign-compare
| -Wno-unused-parameter -g -gdwarf-5 -DDEBUG
| -Idrivers/net/can/rockchip -Idrivers/net/can/rockchip -DMODULE
| -DKBUILD_BASENAME='"rockchip_canfd_core"'
| -DKBUILD_MODNAME='"rockchip_canfd"'
| -D__KBUILD_MODNAME=kmod_rockchip_canfd -c -o
| drivers/net/can/rockchip/rockchip_canfd-core.o
| drivers/net/can/rockchip/rockchip_canfd-core.c
| In file included from drivers/net/can/rockchip/rockchip_canfd-core.c:25:
| In file included from drivers/net/can/rockchip/rockchip_canfd.h:11:
| In file included from include/linux/can/dev.h:18:
| In file included from include/linux/can/bittiming.h:9:
| In file included from include/linux/netdevice.h:38:
| In file included from include/net/net_namespace.h:43:
| In file included from include/linux/skbuff.h:17:
| In file included from include/linux/bvec.h:10:
| In file included from include/linux/highmem.h:8:
| In file included from include/linux/cacheflush.h:5:
| In file included from arch/x86/include/asm/cacheflush.h:5:
| In file included from include/linux/mm.h:2232:
| include/linux/vmstat.h:517:36: warning: arithmetic between different enumeration types ('enum node_stat_item' and 'enum lru_list') [-Wenum-enum-conversion]
| 517 | return node_stat_name(NR_LRU_BASE + lru) + 3; // skip "nr_"
| | ~~~~~~~~~~~ ^ ~~~
| 1 warning generated.
regards,
Marc
--
Pengutronix e.K. | Marc Kleine-Budde |
Embedded Linux | https://www.pengutronix.de |
Vertretung Nürnberg | Phone: +49-5121-206917-129 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-9 |
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 18+ messages in thread* Re: [PATCH] can: rockchip_canfd: fix return type of rkcanfd_start_xmit()
@ 2024-09-10 9:56 ` Marc Kleine-Budde
0 siblings, 0 replies; 18+ messages in thread
From: Marc Kleine-Budde @ 2024-09-10 9:56 UTC (permalink / raw)
To: Simon Horman, Nathan Chancellor
Cc: kernel, Vincent Mailhol, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Heiko Stuebner, linux-can, netdev,
linux-arm-kernel, linux-rockchip, llvm, patches
[-- Attachment #1.1: Type: text/plain, Size: 7150 bytes --]
On 09.09.2024 15:35:46, Simon Horman wrote:
> On Mon, Sep 09, 2024 at 10:57:06AM +0200, Marc Kleine-Budde wrote:
> > On 09.09.2024 09:44:48, Simon Horman wrote:
> > > On Fri, Sep 06, 2024 at 01:26:41PM -0700, Nathan Chancellor wrote:
> > > > With clang's kernel control flow integrity (kCFI, CONFIG_CFI_CLANG),
> > > > indirect call targets are validated against the expected function
> > > > pointer prototype to make sure the call target is valid to help mitigate
> > > > ROP attacks. If they are not identical, there is a failure at run time,
> > > > which manifests as either a kernel panic or thread getting killed. A
> > > > warning in clang aims to catch these at compile time, which reveals:
> > > >
> > > > drivers/net/can/rockchip/rockchip_canfd-core.c:770:20: error: incompatible function pointer types initializing 'netdev_tx_t (*)(struct sk_buff *, struct net_device *)' (aka 'enum netdev_tx (*)(struct sk_buff *, struct net_device *)') with an expression of type 'int (struct sk_buff *, struct net_device *)' [-Werror,-Wincompatible-function-pointer-types-strict]
> > > > 770 | .ndo_start_xmit = rkcanfd_start_xmit,
> > > > | ^~~~~~~~~~~~~~~~~~
> > > >
> > > > ->ndo_start_xmit() in 'struct net_device_ops' expects a return type of
> > > > 'netdev_tx_t', not 'int' (although the types are ABI compatible). Adjust
> > > > the return type of rkcanfd_start_xmit() to match the prototype's to
> > > > resolve the warning.
> > > >
> > > > Fixes: ff60bfbaf67f ("can: rockchip_canfd: add driver for Rockchip CAN-FD controller")
> > > > Signed-off-by: Nathan Chancellor <nathan@kernel.org>
> > >
> > > Thanks, I was able to reproduce this problem at build time
> > > and that your patch addresses it.
> >
> > FTR: the default clang in Debian unstable, clang-16.0.6 doesn't support
> > this. With clang-20 from experimental it works, haven't checked older
> > versions, though.
>
> FTR: I checked using 18.1.8 from here [1][2].
>
> [1] https://mirrors.edge.kernel.org/pub/tools/llvm/
> [2] https://mirrors.edge.kernel.org/pub/tools/llvm/files/
I was a bit hasty yesterday, clang-20 and W=1 produces these errors:
| include/linux/vmstat.h:517:36: error: arithmetic between different enumeration types ('enum node_stat_item' and 'enum lru_list') [-Werror,-Wenum-enum-conversion]
| 517 | return node_stat_name(NR_LRU_BASE + lru) + 3; // skip "nr_"
| | ~~~~~~~~~~~ ^ ~~~
| 1 error generated.
However I fail to reproduce the ndo_start_xmit problem. Even with 18.1.8
from kernel.org.
The following command (ARCH is unset, compiling x86 -> x86) produces the
above shown "vmstat.h" problems....
| $ make LLVM=1 LLVM_IAS=1 LLVM_SUFFIX=-20 drivers/net/can/rockchip/ W=1 CONFIG_WERROR=0
... but not the ndo_start_xmit problem.
Am I missing a vital .config option?
| $ grep "CLANG\|CFI" .config
| CONFIG_CC_IS_CLANG=y
| CONFIG_CLANG_VERSION=200000
| CONFIG_CFI_AUTO_DEFAULT=y
| CONFIG_FUNCTION_PADDING_CFI=11
| CONFIG_LTO_CLANG=y
| CONFIG_ARCH_SUPPORTS_LTO_CLANG=y
| CONFIG_ARCH_SUPPORTS_LTO_CLANG_THIN=y
| CONFIG_HAS_LTO_CLANG=y
| CONFIG_LTO_CLANG_THIN=y
| CONFIG_ARCH_SUPPORTS_CFI_CLANG=y
| CONFIG_ARCH_USES_CFI_TRAPS=y
| CONFIG_CFI_CLANG=y
| # CONFIG_CFI_PERMISSIVE is not set
V=1 gives this output:
| clang-20 -Wp,-MMD,drivers/net/can/rockchip/.rockchip_canfd-core.o.d
| -nostdinc -Iarch/x86/include -I./arch/x86/include/generated
| -Iinclude -I./include -Iarch/x86/include/uapi
| -I./arch/x86/include/generated/uapi -Iinclude/uapi
| -I./include/generated/uapi -include include/linux/compiler-version.h
| -include include/linux/kconfig.h -include
| include/linux/compiler_types.h -D__KERNEL__
| --target=x86_64-linux-gnu -fintegrated-as
| -Werror=unknown-warning-option -Werror=ignored-optimization-argument
| -Werror=option-ignored -Werror=unused-command-line-argument
| -fmacro-prefix-map== -Wundef -DKBUILD_EXTRA_WARN1 -std=gnu11
| -fshort-wchar -funsigned-char -fno-common -fno-PIE
| -fno-strict-aliasing -mno-sse -mno-mmx -mno-sse2 -mno-3dnow -mno-avx
| -fcf-protection=branch -fno-jump-tables -m64 -falign-loops=1
| -mno-80387 -mno-fp-ret-in-387 -mstack-alignment=8 -mskip-rax-setup
| -mtune=generic -mno-red-zone -mcmodel=kernel -Wno-sign-compare
| -fno-asynchronous-unwind-tables -mretpoline-external-thunk
| -mindirect-branch-cs-prefix -mfunction-return=thunk-extern
| -fpatchable-function-entry=11,11 -fno-delete-null-pointer-checks -O2
| -fstack-protector-strong -fomit-frame-pointer
| -fno-stack-clash-protection -fno-lto -flto=thin -fsplit-lto-unit
| -fvisibility=hidden -fsanitize=kcfi -falign-functions=16
| -fstrict-flex-arrays=3 -fno-strict-overflow -fno-stack-check -Wall
| -Wundef -Werror=implicit-function-declaration -Werror=implicit-int
| -Werror=return-type -Werror=strict-prototypes -Wno-format-security
| -Wno-trigraphs -Wno-frame-address -Wno-address-of-packed-member
| -Wmissing-declarations -Wmissing-prototypes -Wframe-larger-than=2048
| -Wno-gnu -Wvla -Wno-pointer-sign -Wcast-function-type
| -Wimplicit-fallthrough -Werror=date-time
| -Werror=incompatible-pointer-types -Wenum-conversion -Wextra
| -Wunused -Wmissing-format-attribute -Wmissing-include-dirs
| -Wunused-const-variable -Wno-missing-field-initializers
| -Wno-type-limits -Wno-shift-negative-value -Wno-sign-compare
| -Wno-unused-parameter -g -gdwarf-5 -DDEBUG
| -Idrivers/net/can/rockchip -Idrivers/net/can/rockchip -DMODULE
| -DKBUILD_BASENAME='"rockchip_canfd_core"'
| -DKBUILD_MODNAME='"rockchip_canfd"'
| -D__KBUILD_MODNAME=kmod_rockchip_canfd -c -o
| drivers/net/can/rockchip/rockchip_canfd-core.o
| drivers/net/can/rockchip/rockchip_canfd-core.c
| In file included from drivers/net/can/rockchip/rockchip_canfd-core.c:25:
| In file included from drivers/net/can/rockchip/rockchip_canfd.h:11:
| In file included from include/linux/can/dev.h:18:
| In file included from include/linux/can/bittiming.h:9:
| In file included from include/linux/netdevice.h:38:
| In file included from include/net/net_namespace.h:43:
| In file included from include/linux/skbuff.h:17:
| In file included from include/linux/bvec.h:10:
| In file included from include/linux/highmem.h:8:
| In file included from include/linux/cacheflush.h:5:
| In file included from arch/x86/include/asm/cacheflush.h:5:
| In file included from include/linux/mm.h:2232:
| include/linux/vmstat.h:517:36: warning: arithmetic between different enumeration types ('enum node_stat_item' and 'enum lru_list') [-Wenum-enum-conversion]
| 517 | return node_stat_name(NR_LRU_BASE + lru) + 3; // skip "nr_"
| | ~~~~~~~~~~~ ^ ~~~
| 1 warning generated.
regards,
Marc
--
Pengutronix e.K. | Marc Kleine-Budde |
Embedded Linux | https://www.pengutronix.de |
Vertretung Nürnberg | Phone: +49-5121-206917-129 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-9 |
[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
[-- Attachment #2: Type: text/plain, Size: 170 bytes --]
_______________________________________________
Linux-rockchip mailing list
Linux-rockchip@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-rockchip
^ permalink raw reply [flat|nested] 18+ messages in thread* Re: [PATCH] can: rockchip_canfd: fix return type of rkcanfd_start_xmit()
2024-09-10 9:56 ` Marc Kleine-Budde
@ 2024-09-10 19:05 ` Nathan Chancellor
-1 siblings, 0 replies; 18+ messages in thread
From: Nathan Chancellor @ 2024-09-10 19:05 UTC (permalink / raw)
To: Marc Kleine-Budde
Cc: Simon Horman, kernel, Vincent Mailhol, David S. Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni, Heiko Stuebner,
linux-can, netdev, linux-arm-kernel, linux-rockchip, llvm,
patches
Hi Marc,
On Tue, Sep 10, 2024 at 11:56:56AM +0200, Marc Kleine-Budde wrote:
> On 09.09.2024 15:35:46, Simon Horman wrote:
> > On Mon, Sep 09, 2024 at 10:57:06AM +0200, Marc Kleine-Budde wrote:
> > > On 09.09.2024 09:44:48, Simon Horman wrote:
> > > > On Fri, Sep 06, 2024 at 01:26:41PM -0700, Nathan Chancellor wrote:
> > > > > With clang's kernel control flow integrity (kCFI, CONFIG_CFI_CLANG),
> > > > > indirect call targets are validated against the expected function
> > > > > pointer prototype to make sure the call target is valid to help mitigate
> > > > > ROP attacks. If they are not identical, there is a failure at run time,
> > > > > which manifests as either a kernel panic or thread getting killed. A
> > > > > warning in clang aims to catch these at compile time, which reveals:
> > > > >
> > > > > drivers/net/can/rockchip/rockchip_canfd-core.c:770:20: error: incompatible function pointer types initializing 'netdev_tx_t (*)(struct sk_buff *, struct net_device *)' (aka 'enum netdev_tx (*)(struct sk_buff *, struct net_device *)') with an expression of type 'int (struct sk_buff *, struct net_device *)' [-Werror,-Wincompatible-function-pointer-types-strict]
> > > > > 770 | .ndo_start_xmit = rkcanfd_start_xmit,
> > > > > | ^~~~~~~~~~~~~~~~~~
> > > > >
> > > > > ->ndo_start_xmit() in 'struct net_device_ops' expects a return type of
> > > > > 'netdev_tx_t', not 'int' (although the types are ABI compatible). Adjust
> > > > > the return type of rkcanfd_start_xmit() to match the prototype's to
> > > > > resolve the warning.
> > > > >
> > > > > Fixes: ff60bfbaf67f ("can: rockchip_canfd: add driver for Rockchip CAN-FD controller")
> > > > > Signed-off-by: Nathan Chancellor <nathan@kernel.org>
> > > >
> > > > Thanks, I was able to reproduce this problem at build time
> > > > and that your patch addresses it.
> > >
> > > FTR: the default clang in Debian unstable, clang-16.0.6 doesn't support
> > > this. With clang-20 from experimental it works, haven't checked older
> > > versions, though.
> >
> > FTR: I checked using 18.1.8 from here [1][2].
> >
> > [1] https://mirrors.edge.kernel.org/pub/tools/llvm/
> > [2] https://mirrors.edge.kernel.org/pub/tools/llvm/files/
>
> I was a bit hasty yesterday, clang-20 and W=1 produces these errors:
>
> | include/linux/vmstat.h:517:36: error: arithmetic between different enumeration types ('enum node_stat_item' and 'enum lru_list') [-Werror,-Wenum-enum-conversion]
> | 517 | return node_stat_name(NR_LRU_BASE + lru) + 3; // skip "nr_"
> | | ~~~~~~~~~~~ ^ ~~~
> | 1 error generated.
Unfortunately, this is a completely tangential issue. You can see some
backstory behind it in commit 75b5ab134bb5 ("kbuild: Move
-Wenum-{compare-conditional,enum-conversion} into W=1"). To be honest, I
should consider moving that to W=2...
> However I fail to reproduce the ndo_start_xmit problem. Even with 18.1.8
> from kernel.org.
>
>
> The following command (ARCH is unset, compiling x86 -> x86) produces the
> above shown "vmstat.h" problems....
>
> | $ make LLVM=1 LLVM_IAS=1 LLVM_SUFFIX=-20 drivers/net/can/rockchip/ W=1 CONFIG_WERROR=0
FYI, you could shorten this to just:
$ make LLVM=-20 drivers/net/can/rockchip/ W=1 CONFIG_WERROR=0
As LLVM_SUFFIX will be set through LLVM and LLVM_IAS has defaulted to 1
since 5.15.
Does CONFIG_WERROR=0 work? It seems like it is still present above.
> ... but not the ndo_start_xmit problem.
>
>
> Am I missing a vital .config option?
No, I might not have made it clear in this commit message but this
warning is not on by default. I am looking to turn it on at some point
so I keep up with the warnings that it produces but there is one
subsystem that has several instances and I am unsure of how to solve
them to the maintainer's satisfaction. You can test it by adding
KCFLAGS=-Wincompatible-function-pointer-types-strict
to your make command above and it should reproduce.
Cheers,
Nathan
^ permalink raw reply [flat|nested] 18+ messages in thread* Re: [PATCH] can: rockchip_canfd: fix return type of rkcanfd_start_xmit()
@ 2024-09-10 19:05 ` Nathan Chancellor
0 siblings, 0 replies; 18+ messages in thread
From: Nathan Chancellor @ 2024-09-10 19:05 UTC (permalink / raw)
To: Marc Kleine-Budde
Cc: Simon Horman, kernel, Vincent Mailhol, David S. Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni, Heiko Stuebner,
linux-can, netdev, linux-arm-kernel, linux-rockchip, llvm,
patches
Hi Marc,
On Tue, Sep 10, 2024 at 11:56:56AM +0200, Marc Kleine-Budde wrote:
> On 09.09.2024 15:35:46, Simon Horman wrote:
> > On Mon, Sep 09, 2024 at 10:57:06AM +0200, Marc Kleine-Budde wrote:
> > > On 09.09.2024 09:44:48, Simon Horman wrote:
> > > > On Fri, Sep 06, 2024 at 01:26:41PM -0700, Nathan Chancellor wrote:
> > > > > With clang's kernel control flow integrity (kCFI, CONFIG_CFI_CLANG),
> > > > > indirect call targets are validated against the expected function
> > > > > pointer prototype to make sure the call target is valid to help mitigate
> > > > > ROP attacks. If they are not identical, there is a failure at run time,
> > > > > which manifests as either a kernel panic or thread getting killed. A
> > > > > warning in clang aims to catch these at compile time, which reveals:
> > > > >
> > > > > drivers/net/can/rockchip/rockchip_canfd-core.c:770:20: error: incompatible function pointer types initializing 'netdev_tx_t (*)(struct sk_buff *, struct net_device *)' (aka 'enum netdev_tx (*)(struct sk_buff *, struct net_device *)') with an expression of type 'int (struct sk_buff *, struct net_device *)' [-Werror,-Wincompatible-function-pointer-types-strict]
> > > > > 770 | .ndo_start_xmit = rkcanfd_start_xmit,
> > > > > | ^~~~~~~~~~~~~~~~~~
> > > > >
> > > > > ->ndo_start_xmit() in 'struct net_device_ops' expects a return type of
> > > > > 'netdev_tx_t', not 'int' (although the types are ABI compatible). Adjust
> > > > > the return type of rkcanfd_start_xmit() to match the prototype's to
> > > > > resolve the warning.
> > > > >
> > > > > Fixes: ff60bfbaf67f ("can: rockchip_canfd: add driver for Rockchip CAN-FD controller")
> > > > > Signed-off-by: Nathan Chancellor <nathan@kernel.org>
> > > >
> > > > Thanks, I was able to reproduce this problem at build time
> > > > and that your patch addresses it.
> > >
> > > FTR: the default clang in Debian unstable, clang-16.0.6 doesn't support
> > > this. With clang-20 from experimental it works, haven't checked older
> > > versions, though.
> >
> > FTR: I checked using 18.1.8 from here [1][2].
> >
> > [1] https://mirrors.edge.kernel.org/pub/tools/llvm/
> > [2] https://mirrors.edge.kernel.org/pub/tools/llvm/files/
>
> I was a bit hasty yesterday, clang-20 and W=1 produces these errors:
>
> | include/linux/vmstat.h:517:36: error: arithmetic between different enumeration types ('enum node_stat_item' and 'enum lru_list') [-Werror,-Wenum-enum-conversion]
> | 517 | return node_stat_name(NR_LRU_BASE + lru) + 3; // skip "nr_"
> | | ~~~~~~~~~~~ ^ ~~~
> | 1 error generated.
Unfortunately, this is a completely tangential issue. You can see some
backstory behind it in commit 75b5ab134bb5 ("kbuild: Move
-Wenum-{compare-conditional,enum-conversion} into W=1"). To be honest, I
should consider moving that to W=2...
> However I fail to reproduce the ndo_start_xmit problem. Even with 18.1.8
> from kernel.org.
>
>
> The following command (ARCH is unset, compiling x86 -> x86) produces the
> above shown "vmstat.h" problems....
>
> | $ make LLVM=1 LLVM_IAS=1 LLVM_SUFFIX=-20 drivers/net/can/rockchip/ W=1 CONFIG_WERROR=0
FYI, you could shorten this to just:
$ make LLVM=-20 drivers/net/can/rockchip/ W=1 CONFIG_WERROR=0
As LLVM_SUFFIX will be set through LLVM and LLVM_IAS has defaulted to 1
since 5.15.
Does CONFIG_WERROR=0 work? It seems like it is still present above.
> ... but not the ndo_start_xmit problem.
>
>
> Am I missing a vital .config option?
No, I might not have made it clear in this commit message but this
warning is not on by default. I am looking to turn it on at some point
so I keep up with the warnings that it produces but there is one
subsystem that has several instances and I am unsure of how to solve
them to the maintainer's satisfaction. You can test it by adding
KCFLAGS=-Wincompatible-function-pointer-types-strict
to your make command above and it should reproduce.
Cheers,
Nathan
_______________________________________________
Linux-rockchip mailing list
Linux-rockchip@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-rockchip
^ permalink raw reply [flat|nested] 18+ messages in thread* Re: [PATCH] can: rockchip_canfd: fix return type of rkcanfd_start_xmit()
2024-09-10 19:05 ` Nathan Chancellor
@ 2024-09-11 8:18 ` Marc Kleine-Budde
-1 siblings, 0 replies; 18+ messages in thread
From: Marc Kleine-Budde @ 2024-09-11 8:18 UTC (permalink / raw)
To: Nathan Chancellor
Cc: Simon Horman, kernel, Vincent Mailhol, David S. Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni, Heiko Stuebner,
linux-can, netdev, linux-arm-kernel, linux-rockchip, llvm,
patches
[-- Attachment #1: Type: text/plain, Size: 2462 bytes --]
On 10.09.2024 12:05:25, Nathan Chancellor wrote:
> > I was a bit hasty yesterday, clang-20 and W=1 produces these errors:
> >
> > | include/linux/vmstat.h:517:36: error: arithmetic between different enumeration types ('enum node_stat_item' and 'enum lru_list') [-Werror,-Wenum-enum-conversion]
> > | 517 | return node_stat_name(NR_LRU_BASE + lru) + 3; // skip "nr_"
> > | | ~~~~~~~~~~~ ^ ~~~
> > | 1 error generated.
>
> Unfortunately, this is a completely tangential issue. You can see some
> backstory behind it in commit 75b5ab134bb5 ("kbuild: Move
> -Wenum-{compare-conditional,enum-conversion} into W=1"). To be honest, I
> should consider moving that to W=2...
Thanks for the background info. I wanted to point out that at least
clang-20 with W=1 finds _something_, though not that what I wanted to
reproduce :)
> > However I fail to reproduce the ndo_start_xmit problem. Even with 18.1.8
> > from kernel.org.
> >
> >
> > The following command (ARCH is unset, compiling x86 -> x86) produces the
> > above shown "vmstat.h" problems....
> >
> > | $ make LLVM=1 LLVM_IAS=1 LLVM_SUFFIX=-20 drivers/net/can/rockchip/ W=1 CONFIG_WERROR=0
>
> FYI, you could shorten this to just:
>
> $ make LLVM=-20 drivers/net/can/rockchip/ W=1 CONFIG_WERROR=0
>
> As LLVM_SUFFIX will be set through LLVM and LLVM_IAS has defaulted to 1
> since 5.15.
Thanks, scripts updated :)
> Does CONFIG_WERROR=0 work? It seems like it is still present above.
Yes, it works.
> > ... but not the ndo_start_xmit problem.
> >
> > Am I missing a vital .config option?
>
> No, I might not have made it clear in this commit message but this
> warning is not on by default. I am looking to turn it on at some point
> so I keep up with the warnings that it produces but there is one
> subsystem that has several instances and I am unsure of how to solve
> them to the maintainer's satisfaction. You can test it by adding
>
> KCFLAGS=-Wincompatible-function-pointer-types-strict
>
> to your make command above and it should reproduce.
That was the missing link. Can reproduce now, thanks!
regards,
Marc
--
Pengutronix e.K. | Marc Kleine-Budde |
Embedded Linux | https://www.pengutronix.de |
Vertretung Nürnberg | Phone: +49-5121-206917-129 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-9 |
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 18+ messages in thread* Re: [PATCH] can: rockchip_canfd: fix return type of rkcanfd_start_xmit()
@ 2024-09-11 8:18 ` Marc Kleine-Budde
0 siblings, 0 replies; 18+ messages in thread
From: Marc Kleine-Budde @ 2024-09-11 8:18 UTC (permalink / raw)
To: Nathan Chancellor
Cc: Simon Horman, kernel, Vincent Mailhol, David S. Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni, Heiko Stuebner,
linux-can, netdev, linux-arm-kernel, linux-rockchip, llvm,
patches
[-- Attachment #1.1: Type: text/plain, Size: 2462 bytes --]
On 10.09.2024 12:05:25, Nathan Chancellor wrote:
> > I was a bit hasty yesterday, clang-20 and W=1 produces these errors:
> >
> > | include/linux/vmstat.h:517:36: error: arithmetic between different enumeration types ('enum node_stat_item' and 'enum lru_list') [-Werror,-Wenum-enum-conversion]
> > | 517 | return node_stat_name(NR_LRU_BASE + lru) + 3; // skip "nr_"
> > | | ~~~~~~~~~~~ ^ ~~~
> > | 1 error generated.
>
> Unfortunately, this is a completely tangential issue. You can see some
> backstory behind it in commit 75b5ab134bb5 ("kbuild: Move
> -Wenum-{compare-conditional,enum-conversion} into W=1"). To be honest, I
> should consider moving that to W=2...
Thanks for the background info. I wanted to point out that at least
clang-20 with W=1 finds _something_, though not that what I wanted to
reproduce :)
> > However I fail to reproduce the ndo_start_xmit problem. Even with 18.1.8
> > from kernel.org.
> >
> >
> > The following command (ARCH is unset, compiling x86 -> x86) produces the
> > above shown "vmstat.h" problems....
> >
> > | $ make LLVM=1 LLVM_IAS=1 LLVM_SUFFIX=-20 drivers/net/can/rockchip/ W=1 CONFIG_WERROR=0
>
> FYI, you could shorten this to just:
>
> $ make LLVM=-20 drivers/net/can/rockchip/ W=1 CONFIG_WERROR=0
>
> As LLVM_SUFFIX will be set through LLVM and LLVM_IAS has defaulted to 1
> since 5.15.
Thanks, scripts updated :)
> Does CONFIG_WERROR=0 work? It seems like it is still present above.
Yes, it works.
> > ... but not the ndo_start_xmit problem.
> >
> > Am I missing a vital .config option?
>
> No, I might not have made it clear in this commit message but this
> warning is not on by default. I am looking to turn it on at some point
> so I keep up with the warnings that it produces but there is one
> subsystem that has several instances and I am unsure of how to solve
> them to the maintainer's satisfaction. You can test it by adding
>
> KCFLAGS=-Wincompatible-function-pointer-types-strict
>
> to your make command above and it should reproduce.
That was the missing link. Can reproduce now, thanks!
regards,
Marc
--
Pengutronix e.K. | Marc Kleine-Budde |
Embedded Linux | https://www.pengutronix.de |
Vertretung Nürnberg | Phone: +49-5121-206917-129 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-9 |
[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
[-- Attachment #2: Type: text/plain, Size: 170 bytes --]
_______________________________________________
Linux-rockchip mailing list
Linux-rockchip@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-rockchip
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH] can: rockchip_canfd: fix return type of rkcanfd_start_xmit()
2024-09-09 8:57 ` Marc Kleine-Budde
@ 2024-09-09 15:27 ` Nathan Chancellor
-1 siblings, 0 replies; 18+ messages in thread
From: Nathan Chancellor @ 2024-09-09 15:27 UTC (permalink / raw)
To: Marc Kleine-Budde
Cc: Simon Horman, kernel, Vincent Mailhol, David S. Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni, Heiko Stuebner,
linux-can, netdev, linux-arm-kernel, linux-rockchip, llvm,
patches
Hi Marc,
On Mon, Sep 09, 2024 at 10:57:06AM +0200, Marc Kleine-Budde wrote:
> On 09.09.2024 09:44:48, Simon Horman wrote:
> > On Fri, Sep 06, 2024 at 01:26:41PM -0700, Nathan Chancellor wrote:
> > > drivers/net/can/rockchip/rockchip_canfd-core.c:770:20: error: incompatible function pointer types initializing 'netdev_tx_t (*)(struct sk_buff *, struct net_device *)' (aka 'enum netdev_tx (*)(struct sk_buff *, struct net_device *)') with an expression of type 'int (struct sk_buff *, struct net_device *)' [-Werror,-Wincompatible-function-pointer-types-strict]
> > > 770 | .ndo_start_xmit = rkcanfd_start_xmit,
> > > | ^~~~~~~~~~~~~~~~~~
...
> FTR: the default clang in Debian unstable, clang-16.0.6 doesn't support
> this. With clang-20 from experimental it works, haven't checked older
> versions, though.
Hmmm, interesting, the patch that added
-Wincompatible-function-pointer-types-strict was added in LLVM 16, so it
should work for 16.0.6...
https://github.com/llvm/llvm-project/commits/41ce74e6e983f523d44d3a80be5ae778c35df85a
I don't have easy access to Debian at the moment so I can double check
it later. I would like to get this turned on for the whole kernel soon
but there is still one subsystem that has several instances that I have
not been able to workaround at this point so I've just stuck to adding
it via KCFLAGS when testing.
Cheers,
Nathan
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH] can: rockchip_canfd: fix return type of rkcanfd_start_xmit()
@ 2024-09-09 15:27 ` Nathan Chancellor
0 siblings, 0 replies; 18+ messages in thread
From: Nathan Chancellor @ 2024-09-09 15:27 UTC (permalink / raw)
To: Marc Kleine-Budde
Cc: Simon Horman, kernel, Vincent Mailhol, David S. Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni, Heiko Stuebner,
linux-can, netdev, linux-arm-kernel, linux-rockchip, llvm,
patches
Hi Marc,
On Mon, Sep 09, 2024 at 10:57:06AM +0200, Marc Kleine-Budde wrote:
> On 09.09.2024 09:44:48, Simon Horman wrote:
> > On Fri, Sep 06, 2024 at 01:26:41PM -0700, Nathan Chancellor wrote:
> > > drivers/net/can/rockchip/rockchip_canfd-core.c:770:20: error: incompatible function pointer types initializing 'netdev_tx_t (*)(struct sk_buff *, struct net_device *)' (aka 'enum netdev_tx (*)(struct sk_buff *, struct net_device *)') with an expression of type 'int (struct sk_buff *, struct net_device *)' [-Werror,-Wincompatible-function-pointer-types-strict]
> > > 770 | .ndo_start_xmit = rkcanfd_start_xmit,
> > > | ^~~~~~~~~~~~~~~~~~
...
> FTR: the default clang in Debian unstable, clang-16.0.6 doesn't support
> this. With clang-20 from experimental it works, haven't checked older
> versions, though.
Hmmm, interesting, the patch that added
-Wincompatible-function-pointer-types-strict was added in LLVM 16, so it
should work for 16.0.6...
https://github.com/llvm/llvm-project/commits/41ce74e6e983f523d44d3a80be5ae778c35df85a
I don't have easy access to Debian at the moment so I can double check
it later. I would like to get this turned on for the whole kernel soon
but there is still one subsystem that has several instances that I have
not been able to workaround at this point so I've just stuck to adding
it via KCFLAGS when testing.
Cheers,
Nathan
_______________________________________________
Linux-rockchip mailing list
Linux-rockchip@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-rockchip
^ permalink raw reply [flat|nested] 18+ messages in thread