Skip to content

Commit d444cdd

Browse files
nathanchanceintel-lab-lkp
authored andcommitted
s390/netiucv: Fix return type of netiucv_tx()
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 proposed warning in clang aims to catch these at compile time, which reveals: drivers/s390/net/netiucv.c:1854: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 = netiucv_tx, ^~~~~~~~~~ ->ndo_start_xmit() in 'struct net_device_ops' expects a return type of 'netdev_tx_t', not 'int'. Adjust the return type of netiucv_tx() to match the prototype's to resolve the warning and potential CFI failure, should s390 select ARCH_SUPPORTS_CFI_CLANG in the future. Additionally, while in the area, remove a comment block that is no longer relevant. Link: ClangBuiltLinux#1750 Reviewed-by: Alexandra Winter <[email protected]> Reviewed-by: Kees Cook <[email protected]> Signed-off-by: Nathan Chancellor <[email protected]>
1 parent 8b5c388 commit d444cdd

File tree

1 file changed

+1
-8
lines changed

1 file changed

+1
-8
lines changed

drivers/s390/net/netiucv.c

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1248,15 +1248,8 @@ static int netiucv_close(struct net_device *dev)
12481248
/*
12491249
* Start transmission of a packet.
12501250
* Called from generic network device layer.
1251-
*
1252-
* @param skb Pointer to buffer containing the packet.
1253-
* @param dev Pointer to interface struct.
1254-
*
1255-
* @return 0 if packet consumed, !0 if packet rejected.
1256-
* Note: If we return !0, then the packet is free'd by
1257-
* the generic network layer.
12581251
*/
1259-
static int netiucv_tx(struct sk_buff *skb, struct net_device *dev)
1252+
static netdev_tx_t netiucv_tx(struct sk_buff *skb, struct net_device *dev)
12601253
{
12611254
struct netiucv_priv *privptr = netdev_priv(dev);
12621255
int rc;

0 commit comments

Comments
 (0)