net: can: rockchip: Fix rockchip_canfd_start_xmit return type for GKI error

rockchip_canfd_start_xmit is used as a callback function for the ndo_start_xmit
function pointer. ndo_start_xmit's return type is netdev_tx_t but
rockchip_canfd_start_xmit's return type is int.

This causes a failure with Control Flow Integrity (CFI), which requires
function pointer prototypes and callback function definitions to match
exactly. When CFI is in enforcing, the kernel panics. When booting a
CFI kernel with WSL 2, the VM is immediately terminated because of this.

The splat when CONFIG_CFI_PERMISSIVE is used:

[   82.432581][ T2211] CPU: 3 PID: 2211 Comm: cansend Tainted: G
E      6.1.57-android14-11-gfc4b04d84027-ab11318753 #1
[   82.433595][ T2211] Hardware name: Rockchip RK3568 EVB1 DDR4 V10
Board (DT)
[   82.434206][ T2211] pstate: 30400005 (nzCV daif +PAN -UAO -TCO -DIT
-SSBS BTYPE=--)
[   82.434887][ T2211] pc : dev_hard_start_xmit+0xd0/0x260
[   82.435367][ T2211] lr : sch_direct_xmit+0xf0/0x3d0
[   82.435815][ T2211] sp : ffffffc0110f3a70
[   82.436175][ T2211] x29: ffffffc0110f3a80 x28: ffffffc009f47000 x27:
ffffff800d078080
[   82.436873][ T2211] x26: ffffffc009f2ed80 x25: ffffffc009f50550 x24:
0000000000000010
[   82.437567][ T2211] x23: ffffff807bfefc00 x22: ffffff800d078000 x21:
ffffff81f41b7200
[   82.438261][ T2211] x20: 0000000000000000 x19: ffffffc0110f3ae4 x18:
ffffffc01075d070
[   82.438954][ T2211] x17: 0000000044e57e43 x16: 00000000ab1f26f7 x15:
0000007fec6a51b0
[   82.439646][ T2211] x14: 0000000000000001 x13: 0000000008000000 x12:
fffffffdeff6a120
[   82.440340][ T2211] x11: 0000000000000000 x10: 0000000000000000 x9 :
ffffff81f9bf5d80
[   82.441033][ T2211] x8 : ffffffc00262b620 x7 : 7f7f7f7f7f7f7f7f x6 :
fefefefefefefeff
[   82.441726][ T2211] x5 : 0000000000000001 x4 : 0000000000000000 x3 :
ffffffc0110f3ae4
[   82.442418][ T2211] x2 : ffffff81f41b7200 x1 : ffffff800d078000 x0 :
ffffff807bfefc00
[   82.443111][ T2211] Call trace:
[   82.443393][ T2211]  dev_hard_start_xmit+0xd0/0x260
[   82.443839][ T2211]  sch_direct_xmit+0xf0/0x3d0
[   82.444247][ T2211]  __dev_queue_xmit+0x5f0/0xd40
[   82.444667][ T2211]  can_send+0x22c/0x2b0 [can]
[   82.445098][ T2211]  raw_sendmsg+0x1b4/0x3ac [can_raw]
[   82.445585][ T2211]  sock_write_iter+0xdc/0x13c
[   82.445997][ T2211]  vfs_write+0x1e0/0x2c8
[   82.446375][ T2211]  ksys_write+0x78/0xe8
[   82.446737][ T2211]  __arm64_sys_write+0x1c/0x2c
[   82.447157][ T2211]  invoke_syscall+0x58/0x11c
[   82.447557][ T2211]  el0_svc_common+0xb4/0xf4
[   82.447954][ T2211]  do_el0_svc+0x2c/0xb0
[   82.448316][ T2211]  el0_svc+0x2c/0xa4
[   82.448661][ T2211]  el0t_64_sync_handler+0x68/0xb4
[   82.449102][ T2211]  el0t_64_sync+0x1a4/0x1a8
[   82.449504][ T2211] Code: 728fc871 72a89cb1 6b11021f 54000040
(d4304500)
[   82.450106][ T2211] ---[ end trace 0000000000000000 ]---
[   82.468041][ T2211] Kernel panic - not syncing: Oops - CFI: Fatal
exception in interrupt
[   82.468776][ T2211] SMP: stopping secondary CPUs
[   82.469267][ T2211] Kernel Offset: disabled
[   82.469643][ T2211] CPU features: 0x00,00040000,00040184,6600721b
[   82.470190][ T2211] Memory Limit: none
[   82.470530][ T2211] PMU CRU:

Signed-off-by: Elaine Zhang <zhangqing@rock-chips.com>
Change-Id: I62fa546e07984c7fd6acbd0bdf1278414b479829
This commit is contained in:
Elaine Zhang
2024-04-22 14:46:01 +08:00
committed by Tao Huang
parent 70df1f6919
commit a269396080
3 changed files with 6 additions and 5 deletions

View File

@@ -685,8 +685,8 @@ static int rk3576_canfd_set_mode(struct net_device *ndev,
* xx xx xx xx ff ll 00 11 22 33 44 55 66 77
* [ can_id ] [flags] [len] [can data (up to 8 bytes]
*/
static int rk3576_canfd_start_xmit(struct sk_buff *skb,
struct net_device *ndev)
static netdev_tx_t rk3576_canfd_start_xmit(struct sk_buff *skb,
struct net_device *ndev)
{
struct rk3576_canfd *rcan = netdev_priv(ndev);
struct canfd_frame *cf = (struct canfd_frame *)skb->data;

View File

@@ -271,7 +271,8 @@ static int rockchip_can_set_mode(struct net_device *ndev, enum can_mode mode)
* xx xx xx xx ff ll 00 11 22 33 44 55 66 77
* [ can_id ] [flags] [len] [can data (up to 8 bytes]
*/
static int rockchip_can_start_xmit(struct sk_buff *skb, struct net_device *ndev)
static netdev_tx_t rockchip_can_start_xmit(struct sk_buff *skb,
struct net_device *ndev)
{
struct rockchip_can *rcan = netdev_priv(ndev);
struct can_frame *cf = (struct can_frame *)skb->data;

View File

@@ -527,8 +527,8 @@ static void rockchip_canfd_tx_err_delay_work(struct work_struct *work)
* xx xx xx xx ff ll 00 11 22 33 44 55 66 77
* [ can_id ] [flags] [len] [can data (up to 8 bytes]
*/
static int rockchip_canfd_start_xmit(struct sk_buff *skb,
struct net_device *ndev)
static netdev_tx_t rockchip_canfd_start_xmit(struct sk_buff *skb,
struct net_device *ndev)
{
struct rockchip_canfd *rcan = netdev_priv(ndev);
struct canfd_frame *cf = (struct canfd_frame *)skb->data;