* [PATCH net-next] net: pasemi: Fix return type of pasemi_mac_start_tx()
@ 2023-03-19 23:41 Nathan Chancellor
2023-03-20 8:09 ` Horatiu Vultur
2023-03-21 13:00 ` patchwork-bot+netdevbpf
0 siblings, 2 replies; 3+ messages in thread
From: Nathan Chancellor @ 2023-03-19 23:41 UTC (permalink / raw)
To: davem, edumazet, kuba, pabeni
Cc: ndesaulniers, trix, netdev, llvm, patches, Nathan Chancellor
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/ethernet/pasemi/pasemi_mac.c:1665:21: 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]
.ndo_start_xmit = pasemi_mac_start_tx,
^~~~~~~~~~~~~~~~~~~
1 error generated.
->ndo_start_xmit() in 'struct net_device_ops' expects a return type of
'netdev_tx_t', not 'int'. Adjust the return type of
pasemi_mac_start_tx() to match the prototype's to resolve the warning.
While PowerPC does not currently implement support for kCFI, it could in
the future, which means this warning becomes a fatal CFI failure at run
time.
Link: https://github.com/ClangBuiltLinux/linux/issues/1750
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
---
drivers/net/ethernet/pasemi/pasemi_mac.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/pasemi/pasemi_mac.c b/drivers/net/ethernet/pasemi/pasemi_mac.c
index aaab590ef548..ed7dd0a04235 100644
--- a/drivers/net/ethernet/pasemi/pasemi_mac.c
+++ b/drivers/net/ethernet/pasemi/pasemi_mac.c
@@ -1423,7 +1423,7 @@ static void pasemi_mac_queue_csdesc(const struct sk_buff *skb,
write_dma_reg(PAS_DMA_TXCHAN_INCR(txring->chan.chno), 2);
}
-static int pasemi_mac_start_tx(struct sk_buff *skb, struct net_device *dev)
+static netdev_tx_t pasemi_mac_start_tx(struct sk_buff *skb, struct net_device *dev)
{
struct pasemi_mac * const mac = netdev_priv(dev);
struct pasemi_mac_txring * const txring = tx_ring(mac);
---
base-commit: e8d018dd0257f744ca50a729e3d042cf2ec9da65
change-id: 20230319-pasemi-incompatible-pointer-types-strict-8569226f4e10
Best regards,
--
Nathan Chancellor <nathan@kernel.org>
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH net-next] net: pasemi: Fix return type of pasemi_mac_start_tx()
2023-03-19 23:41 [PATCH net-next] net: pasemi: Fix return type of pasemi_mac_start_tx() Nathan Chancellor
@ 2023-03-20 8:09 ` Horatiu Vultur
2023-03-21 13:00 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 3+ messages in thread
From: Horatiu Vultur @ 2023-03-20 8:09 UTC (permalink / raw)
To: Nathan Chancellor
Cc: davem, edumazet, kuba, pabeni, ndesaulniers, trix, netdev, llvm,
patches
The 03/19/2023 16:41, 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/ethernet/pasemi/pasemi_mac.c:1665:21: 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]
> .ndo_start_xmit = pasemi_mac_start_tx,
> ^~~~~~~~~~~~~~~~~~~
> 1 error generated.
>
> ->ndo_start_xmit() in 'struct net_device_ops' expects a return type of
> 'netdev_tx_t', not 'int'. Adjust the return type of
> pasemi_mac_start_tx() to match the prototype's to resolve the warning.
> While PowerPC does not currently implement support for kCFI, it could in
> the future, which means this warning becomes a fatal CFI failure at run
> time.
Reviewed-by: Horatiu Vultur <horatiu.vultur@microchip.com>
>
> Link: https://github.com/ClangBuiltLinux/linux/issues/1750
> Signed-off-by: Nathan Chancellor <nathan@kernel.org>
> ---
> drivers/net/ethernet/pasemi/pasemi_mac.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/net/ethernet/pasemi/pasemi_mac.c b/drivers/net/ethernet/pasemi/pasemi_mac.c
> index aaab590ef548..ed7dd0a04235 100644
> --- a/drivers/net/ethernet/pasemi/pasemi_mac.c
> +++ b/drivers/net/ethernet/pasemi/pasemi_mac.c
> @@ -1423,7 +1423,7 @@ static void pasemi_mac_queue_csdesc(const struct sk_buff *skb,
> write_dma_reg(PAS_DMA_TXCHAN_INCR(txring->chan.chno), 2);
> }
>
> -static int pasemi_mac_start_tx(struct sk_buff *skb, struct net_device *dev)
> +static netdev_tx_t pasemi_mac_start_tx(struct sk_buff *skb, struct net_device *dev)
> {
> struct pasemi_mac * const mac = netdev_priv(dev);
> struct pasemi_mac_txring * const txring = tx_ring(mac);
>
> ---
> base-commit: e8d018dd0257f744ca50a729e3d042cf2ec9da65
> change-id: 20230319-pasemi-incompatible-pointer-types-strict-8569226f4e10
>
> Best regards,
> --
> Nathan Chancellor <nathan@kernel.org>
>
--
/Horatiu
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH net-next] net: pasemi: Fix return type of pasemi_mac_start_tx()
2023-03-19 23:41 [PATCH net-next] net: pasemi: Fix return type of pasemi_mac_start_tx() Nathan Chancellor
2023-03-20 8:09 ` Horatiu Vultur
@ 2023-03-21 13:00 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2023-03-21 13:00 UTC (permalink / raw)
To: Nathan Chancellor
Cc: davem, edumazet, kuba, pabeni, ndesaulniers, trix, netdev, llvm,
patches
Hello:
This patch was applied to netdev/net-next.git (main)
by Paolo Abeni <pabeni@redhat.com>:
On Sun, 19 Mar 2023 16:41:08 -0700 you 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:
>
> [...]
Here is the summary with links:
- [net-next] net: pasemi: Fix return type of pasemi_mac_start_tx()
https://git.kernel.org/netdev/net-next/c/c8384d4a51e7
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-03-21 13:00 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-03-19 23:41 [PATCH net-next] net: pasemi: Fix return type of pasemi_mac_start_tx() Nathan Chancellor
2023-03-20 8:09 ` Horatiu Vultur
2023-03-21 13:00 ` patchwork-bot+netdevbpf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox