Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

HSI: ssi_protocol: Fix return type of ssip_pn_xmit()

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/hsi/clients/ssi_protocol.c:1053: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]
.ndo_start_xmit = ssip_pn_xmit,
^~~~~~~~~~~~
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 ssip_pn_xmit() to
match the prototype's to resolve the warning and CFI failure.
Additionally, use the enum 'NETDEV_TX_OK' instead of a raw '0' for the
return value of ssip_pn_xmit().

Link: https://github.com/ClangBuiltLinux/linux/issues/1750
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
Reviewed-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>

authored by

Nathan Chancellor and committed by
Sebastian Reichel
913a1441 9abf2313

+3 -3
+3 -3
drivers/hsi/clients/ssi_protocol.c
··· 968 968 ssip_xmit(cl); 969 969 } 970 970 971 - static int ssip_pn_xmit(struct sk_buff *skb, struct net_device *dev) 971 + static netdev_tx_t ssip_pn_xmit(struct sk_buff *skb, struct net_device *dev) 972 972 { 973 973 struct hsi_client *cl = to_hsi_client(dev->dev.parent); 974 974 struct ssi_protocol *ssi = hsi_client_drvdata(cl); ··· 1027 1027 dev->stats.tx_packets++; 1028 1028 dev->stats.tx_bytes += skb->len; 1029 1029 1030 - return 0; 1030 + return NETDEV_TX_OK; 1031 1031 drop2: 1032 1032 hsi_free_msg(msg); 1033 1033 drop: ··· 1035 1035 inc_dropped: 1036 1036 dev->stats.tx_dropped++; 1037 1037 1038 - return 0; 1038 + return NETDEV_TX_OK; 1039 1039 } 1040 1040 1041 1041 /* CMT reset event handler */