Skip to content

Commit 913a144

Browse files
nathanchancesre
authored andcommitted
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: ClangBuiltLinux#1750 Signed-off-by: Nathan Chancellor <[email protected]> Reviewed-by: Kees Cook <[email protected]> Signed-off-by: Sebastian Reichel <[email protected]>
1 parent 9abf231 commit 913a144

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

drivers/hsi/clients/ssi_protocol.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -968,7 +968,7 @@ static void ssip_xmit_work(struct work_struct *work)
968968
ssip_xmit(cl);
969969
}
970970

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)
972972
{
973973
struct hsi_client *cl = to_hsi_client(dev->dev.parent);
974974
struct ssi_protocol *ssi = hsi_client_drvdata(cl);
@@ -1027,15 +1027,15 @@ static int ssip_pn_xmit(struct sk_buff *skb, struct net_device *dev)
10271027
dev->stats.tx_packets++;
10281028
dev->stats.tx_bytes += skb->len;
10291029

1030-
return 0;
1030+
return NETDEV_TX_OK;
10311031
drop2:
10321032
hsi_free_msg(msg);
10331033
drop:
10341034
dev_kfree_skb(skb);
10351035
inc_dropped:
10361036
dev->stats.tx_dropped++;
10371037

1038-
return 0;
1038+
return NETDEV_TX_OK;
10391039
}
10401040

10411041
/* CMT reset event handler */

0 commit comments

Comments
 (0)