Bug 217693

Summary: UBSAN: index 1 is out of range for type 'xen_netif_rx_sring_entry [1]'
Product: Drivers Reporter: sander44 (ionut_n2001)
Component: NetworkAssignee: drivers_network (drivers_network)
Status: NEW ---    
Severity: normal CC: arthurborsboom, bagasdotme, christophermounce, kernel
Priority: P3    
Hardware: Intel   
OS: Linux   
Kernel Version: 6.5.0-rc2 Subsystem:
Regression: No Bisected commit-id:
Attachments: 6.5.0-rc2 config kernel
dmesg-6.5.0-rc2-1-generation1.txt
Ubuntu Xen/PVH domU dmesg
Kernel log

Description sander44 2023-07-21 15:20:10 UTC
Hi Kernel Team,

I rebuild today latest version from mainline repo.
And i notice issue regarding xen-netfront.c.

Error:
[    3.477400] ================================================================================
[    3.477633] UBSAN: array-index-out-of-bounds in drivers/net/xen-netfront.c:1291:3
[    3.477858] index 1 is out of range for type 'xen_netif_rx_sring_entry [1]'
[    3.478085] CPU: 0 PID: 700 Comm: NetworkManager Not tainted 6.5.0-rc2-1-generation1 #3
[    3.478088] Hardware name: Intel Corporation W2600CR/W2600CR, BIOS SE5C600.86B.02.06.0007.082420181029 01/13/2022
[    3.478090] Call Trace:
[    3.478092]  <IRQ>
[    3.478097]  dump_stack_lvl+0x48/0x70
[    3.478105]  dump_stack+0x10/0x20
[    3.478107]  __ubsan_handle_out_of_bounds+0xc6/0x110
[    3.478114]  xennet_poll+0xa94/0xac0
[    3.478118]  ? generic_smp_call_function_single_interrupt+0x13/0x20
[    3.478125]  __napi_poll+0x33/0x200
[    3.478131]  net_rx_action+0x181/0x2e0
[    3.478135]  __do_softirq+0xd9/0x346
[    3.478139]  do_softirq.part.0+0x41/0x80
[    3.478144]  </IRQ>
[    3.478145]  <TASK>
[    3.478146]  __local_bh_enable_ip+0x72/0x80
[    3.478149]  _raw_spin_unlock_bh+0x1d/0x30
[    3.478151]  xennet_open+0x75/0x160
[    3.478154]  __dev_open+0x105/0x1d0
[    3.478156]  __dev_change_flags+0x1b5/0x230
[    3.478158]  dev_change_flags+0x27/0x80
[    3.478160]  do_setlink+0x3d2/0x12b0
[    3.478164]  ? __nla_validate_parse+0x5b/0xdb0
[    3.478169]  __rtnl_newlink+0x6f6/0xb10
[    3.478173]  ? rtnl_newlink+0x2f/0x80
[    3.478177]  rtnl_newlink+0x48/0x80
[    3.478180]  rtnetlink_rcv_msg+0x170/0x430
[    3.478183]  ? fib6_clean_node+0xad/0x190
[    3.478188]  ? __pfx_rtnetlink_rcv_msg+0x10/0x10
[    3.478191]  netlink_rcv_skb+0x5d/0x110
[    3.478195]  rtnetlink_rcv+0x15/0x30
[    3.478198]  netlink_unicast+0x247/0x390
[    3.478200]  netlink_sendmsg+0x25e/0x4e0
[    3.478202]  sock_sendmsg+0xaf/0xc0
[    3.478204]  ____sys_sendmsg+0x2a9/0x350
[    3.478206]  ___sys_sendmsg+0x9a/0xf0
[    3.478212]  ? _copy_from_iter+0x80/0x4a0
[    3.478217]  __sys_sendmsg+0x89/0xf0
[    3.478220]  __x64_sys_sendmsg+0x1d/0x30
[    3.478222]  do_syscall_64+0x5c/0x90
[    3.478226]  ? do_syscall_64+0x68/0x90
[    3.478228]  ? ksys_write+0xe6/0x100
[    3.478232]  ? exit_to_user_mode_prepare+0x49/0x220
[    3.478236]  ? syscall_exit_to_user_mode+0x1b/0x50
[    3.478240]  ? do_syscall_64+0x68/0x90
[    3.478242]  ? do_syscall_64+0x68/0x90
[    3.478243]  ? irqentry_exit_to_user_mode+0x9/0x30
[    3.478246]  ? irqentry_exit+0x43/0x50
[    3.478248]  ? sysvec_xen_hvm_callback+0x4b/0xd0
[    3.478250]  entry_SYSCALL_64_after_hwframe+0x6e/0xd8
[    3.478253] RIP: 0033:0x7f973c244e4d
[    3.478268] Code: 28 89 54 24 1c 48 89 74 24 10 89 7c 24 08 e8 ca ee ff ff 8b 54 24 1c 48 8b 74 24 10 41 89 c0 8b 7c 24 08 b8 2e 00 00 00 0f 05 <48> 3d 00 f0 ff ff 77 33 44 89 c7 48 89 44 24 08 e8 fe ee ff ff 48
[    3.478270] RSP: 002b:00007fff4777f470 EFLAGS: 00000293 ORIG_RAX: 000000000000002e
[    3.478273] RAX: ffffffffffffffda RBX: 00005583087c6480 RCX: 00007f973c244e4d
[    3.478274] RDX: 0000000000000000 RSI: 00007fff4777f4c0 RDI: 000000000000000c
[    3.478276] RBP: 00007fff4777f4c0 R08: 0000000000000000 R09: 0000000000000000
[    3.478277] R10: 0000000000000000 R11: 0000000000000293 R12: 00005583087c6480
[    3.478279] R13: 00007fff4777f668 R14: 00007fff4777f65c R15: 0000000000000000
[    3.478283]  </TASK>
[    3.478284] ================================================================================
[    3.685513] ================================================================================
[    3.685751] UBSAN: array-index-out-of-bounds in drivers/net/xen-netfront.c:485:7
[    3.686111] index 1 is out of range for type 'xen_netif_tx_sring_entry [1]'
[    3.686379] CPU: 1 PID: 697 Comm: avahi-daemon Not tainted 6.5.0-rc2-1-generation1 #3
[    3.686381] Hardware name: Intel Corporation W2600CR/W2600CR, BIOS SE5C600.86B.02.06.0007.082420181029 01/13/2022
[    3.686385] Call Trace:
[    3.686388]  <TASK>
[    3.686391]  dump_stack_lvl+0x48/0x70
[    3.686399]  dump_stack+0x10/0x20
[    3.686399]  __ubsan_handle_out_of_bounds+0xc6/0x110
[    3.686403]  xennet_tx_setup_grant+0x1f7/0x230
[    3.686403]  ? __pfx_xennet_tx_setup_grant+0x10/0x10
[    3.686403]  gnttab_foreach_grant_in_range+0x5c/0x100
[    3.686415]  xennet_start_xmit+0x428/0x990
[    3.686415]  ? kmem_cache_alloc_node+0x1b1/0x3b0
[    3.686415]  dev_hard_start_xmit+0x68/0x1e0
[    3.686415]  sch_direct_xmit+0x10b/0x350
[    3.686415]  __dev_queue_xmit+0x512/0xda0
[    3.686439]  ? ___neigh_create+0x6cb/0x970
[    3.686439]  neigh_resolve_output+0x118/0x1e0
[    3.686446]  ip_finish_output2+0x181/0x540
[    3.686450]  ? netif_rx_internal+0x46/0x140
[    3.686456]  __ip_finish_output+0xb6/0x180
[    3.686456]  ? dev_loopback_xmit+0x86/0x110
[    3.686456]  ip_finish_output+0x29/0x100
[    3.686456]  ip_mc_output+0x95/0x2e0
[    3.686456]  ? __pfx_ip_finish_output+0x10/0x10
[    3.686456]  ip_send_skb+0x9f/0xb0
[    3.686456]  udp_send_skb+0x158/0x380
[    3.686475]  udp_sendmsg+0xb84/0xf20
[    3.686475]  ? do_sys_poll+0x3a1/0x5f0
[    3.686483]  ? __pfx_ip_generic_getfrag+0x10/0x10
[    3.686483]  inet_sendmsg+0x76/0x80
[    3.686483]  ? inet_sendmsg+0x76/0x80
[    3.686483]  sock_sendmsg+0xa8/0xc0
[    3.686483]  ? _copy_from_user+0x30/0xa0
[    3.686483]  ____sys_sendmsg+0x2a9/0x350
[    3.686483]  ___sys_sendmsg+0x9a/0xf0
[    3.686483]  __sys_sendmsg+0x89/0xf0
[    3.686483]  __x64_sys_sendmsg+0x1d/0x30
[    3.686483]  do_syscall_64+0x5c/0x90
[    3.686483]  ? exit_to_user_mode_prepare+0x49/0x220
[    3.686483]  ? syscall_exit_to_user_mode+0x1b/0x50
[    3.686483]  ? do_syscall_64+0x68/0x90
[    3.686483]  ? syscall_exit_to_user_mode+0x1b/0x50
[    3.686483]  ? do_syscall_64+0x68/0x90
[    3.686483]  entry_SYSCALL_64_after_hwframe+0x6e/0xd8
[    3.686483] RIP: 0033:0x7ff365942e13
[    3.686483] Code: 8b 15 b9 a1 00 00 f7 d8 64 89 02 48 c7 c0 ff ff ff ff eb b8 0f 1f 00 64 8b 04 25 18 00 00 00 85 c0 75 14 b8 2e 00 00 00 0f 05 <48> 3d 00 f0 ff ff 77 55 c3 0f 1f 40 00 48 83 ec 28 89 54 24 1c 48
[    3.686483] RSP: 002b:00007ffc7bf1ca78 EFLAGS: 00000246 ORIG_RAX: 000000000000002e
[    3.686483] RAX: ffffffffffffffda RBX: 00005596bd24c900 RCX: 00007ff365942e13
[    3.686483] RDX: 0000000000000000 RSI: 00007ffc7bf1cb30 RDI: 000000000000000c
[    3.686483] RBP: 000000000000000c R08: 0000000000000004 R09: 0000000000000019
[    3.686483] R10: 00007ff365a1ca94 R11: 0000000000000246 R12: 00007ffc7bf1cb30
[    3.686483] R13: 0000000000000002 R14: 00005596bd235f9c R15: 0000000000000000
[    3.686483]  </TASK>
[    3.686483] ================================================================================
[    3.686858] ================================================================================
[    3.687190] UBSAN: array-index-out-of-bounds in drivers/net/xen-netfront.c:413:4
[    3.687501] index 1 is out of range for type 'xen_netif_tx_sring_entry [1]'
[    3.687800] CPU: 18 PID: 0 Comm: swapper/18 Not tainted 6.5.0-rc2-1-generation1 #3
[    3.687804] Hardware name: Intel Corporation W2600CR/W2600CR, BIOS SE5C600.86B.02.06.0007.082420181029 01/13/2022
[    3.687806] Call Trace:
[    3.687808]  <IRQ>
[    3.687812]  dump_stack_lvl+0x48/0x70
[    3.687819]  dump_stack+0x10/0x20
[    3.687821]  __ubsan_handle_out_of_bounds+0xc6/0x110
[    3.687827]  xennet_tx_buf_gc+0x34a/0x440
[    3.687831]  xennet_handle_tx.constprop.0+0x49/0x90
[    3.687834]  xennet_tx_interrupt+0x32/0x70
[    3.687837]  __handle_irq_event_percpu+0x4f/0x1b0
[    3.687842]  handle_irq_event+0x39/0x80
[    3.687846]  handle_edge_irq+0x8c/0x230
[    3.687849]  handle_irq_desc+0x40/0x60
[    3.687851]  generic_handle_irq+0x1f/0x30
[    3.687854]  handle_irq_for_port+0x8e/0x180
[    3.687858]  ? _raw_spin_unlock_irqrestore+0x11/0x60
[    3.687861]  __evtchn_fifo_handle_events+0x221/0x330
[    3.687866]  evtchn_fifo_handle_events+0xe/0x20
[    3.687869]  __xen_evtchn_do_upcall+0x72/0xd0
[    3.687873]  xen_hvm_evtchn_do_upcall+0xe/0x20
[    3.687876]  __sysvec_xen_hvm_callback+0x53/0x70
[    3.687880]  sysvec_xen_hvm_callback+0x8d/0xd0
[    3.687884]  </IRQ>
[    3.687885]  <TASK>
[    3.687886]  asm_sysvec_xen_hvm_callback+0x1b/0x20
[    3.687891] RIP: 0010:pv_native_safe_halt+0xb/0x10
[    3.687896] Code: 0b 66 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 00 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 eb 07 0f 00 2d 49 cc 33 00 fb f4 <c3> cc cc cc cc 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 55
[    3.687898] RSP: 0000:ffffad85c0147e08 EFLAGS: 00000246
[    3.687901] RAX: ffffffffa00d39a0 RBX: 0000000000000002 RCX: 0000000000000000
[    3.687902] RDX: 0000000000000002 RSI: ffffffffa14d28e0 RDI: ffff920446abda00
[    3.687904] RBP: ffffad85c0147e18 R08: 0000000000000000 R09: 0000000000000000
[    3.687905] R10: 0000000000000000 R11: 0000000000000000 R12: 0000000000000002
[    3.687906] R13: 0000000000000002 R14: 0000000000000002 R15: ffffffffa14d29c8
[    3.687909]  ? __pfx_intel_idle_hlt+0x10/0x10
[    3.687913]  ? intel_idle_hlt+0xc/0x40
[    3.687916]  cpuidle_enter_state+0xa0/0x730
[    3.687920]  cpuidle_enter+0x2e/0x50
[    3.687924]  call_cpuidle+0x23/0x60
[    3.687928]  do_idle+0x207/0x260
[    3.687932]  cpu_startup_entry+0x1d/0x20
[    3.687934]  start_secondary+0x129/0x160
[    3.687939]  secondary_startup_64_no_verify+0x17e/0x18b
[    3.687945]  </TASK>
[    3.687946] ================================================================================
[    4.624607] bridge: filtering via arp/ip/ip6tables is no longer available by default. Update your scripts to load br_netfilter if you need this.
[    4.629153] Bridge firewalling registered
[    4.745355] Initializing XFRM netlink socket
[    4.794107] loop8: detected capacity change from 0 to 8
[    7.104544] rfkill: input handler disabled
[   26.445163] ================================================================================
[   26.445171] UBSAN: array-index-out-of-bounds in drivers/net/xen-netfront.c:807:4
[   26.445175] index 109 is out of range for type 'xen_netif_tx_sring_entry [1]'
[   26.445178] CPU: 8 PID: 1729 Comm: sshd Not tainted 6.5.0-rc2-1-generation1 #3
[   26.445180] Hardware name: Intel Corporation W2600CR/W2600CR, BIOS SE5C600.86B.02.06.0007.082420181029 01/13/2022
[   26.445181] Call Trace:
[   26.445185]  <TASK>
[   26.445185]  dump_stack_lvl+0x48/0x70
[   26.445185]  dump_stack+0x10/0x20
[   26.445200]  __ubsan_handle_out_of_bounds+0xc6/0x110
[   26.445206]  xennet_start_xmit+0x932/0x990
[   26.445211]  dev_hard_start_xmit+0x68/0x1e0
[   26.445216]  sch_direct_xmit+0x10b/0x350
[   26.445220]  __dev_queue_xmit+0x512/0xda0
[   26.445224]  ip_finish_output2+0x261/0x540
[   26.445225]  __ip_finish_output+0xb6/0x180
[   26.445225]  ip_finish_output+0x29/0x100
[   26.445234]  ip_output+0x73/0x120
[   26.445234]  ? __pfx_ip_finish_output+0x10/0x10
[   26.445238]  ip_local_out+0x61/0x70
[   26.445238]  __ip_queue_xmit+0x18d/0x470
[   26.445238]  ip_queue_xmit+0x15/0x30
[   26.445238]  __tcp_transmit_skb+0xb39/0xcc0
[   26.445238]  tcp_write_xmit+0x595/0x1570
[   26.445238]  ? _copy_from_iter+0x80/0x4a0
[   26.445256]  __tcp_push_pending_frames+0x37/0x110
[   26.445259]  tcp_push+0x123/0x190
[   26.445260]  tcp_sendmsg_locked+0xafe/0xed0
[   26.445264]  tcp_sendmsg+0x2c/0x50
[   26.445268]  inet_sendmsg+0x42/0x80
[   26.445268]  sock_write_iter+0x160/0x180
[   26.445274]  vfs_write+0x397/0x440
[   26.445274]  ksys_write+0xc9/0x100
[   26.445274]  __x64_sys_write+0x19/0x30
[   26.445274]  do_syscall_64+0x5c/0x90
[   26.445287]  ? syscall_exit_to_user_mode+0x1b/0x50
[   26.445290]  ? do_syscall_64+0x68/0x90
[   26.445290]  ? do_syscall_64+0x68/0x90
[   26.445294]  ? do_syscall_64+0x68/0x90
[   26.445294]  ? syscall_exit_to_user_mode+0x1b/0x50
[   26.445298]  ? do_syscall_64+0x68/0x90
[   26.445300]  ? exc_page_fault+0x94/0x1b0
[   26.445302]  entry_SYSCALL_64_after_hwframe+0x6e/0xd8
[   26.445306] RIP: 0033:0x7f26c4c3d473
[   26.445318] Code: 8b 15 21 2a 0e 00 f7 d8 64 89 02 48 c7 c0 ff ff ff ff eb b7 0f 1f 00 64 8b 04 25 18 00 00 00 85 c0 75 14 b8 01 00 00 00 0f 05 <48> 3d 00 f0 ff ff 77 55 c3 0f 1f 40 00 48 83 ec 28 48 89 54 24 18
[   26.445321] RSP: 002b:00007ffdee7b5528 EFLAGS: 00000246 ORIG_RAX: 0000000000000001
[   26.445321] RAX: ffffffffffffffda RBX: 0000000000000700 RCX: 00007f26c4c3d473
[   26.445321] RDX: 0000000000000700 RSI: 000055567032e230 RDI: 0000000000000004
[   26.445321] RBP: 0000555670313d70 R08: fffffffffffffff0 R09: 0000000000000000
[   26.445321] R10: 0000000000000000 R11: 0000000000000246 R12: 000055566fcb2768
[   26.445321] R13: 0000000000000000 R14: 0000000000000004 R15: 000055566fc67a80
[   26.445332]  </TASK>
[   26.445333] ================================================================================
Comment 1 sander44 2023-07-21 15:26:53 UTC
Created attachment 304680 [details]
6.5.0-rc2 config kernel

6.5.0-rc2 config kernel
Comment 2 sander44 2023-07-21 15:53:48 UTC
Created attachment 304681 [details]
dmesg-6.5.0-rc2-1-generation1.txt

dmesg-6.5.0-rc2-1-generation1.txt
Comment 3 Bagas Sanjaya 2023-07-22 00:05:47 UTC
(In reply to sander44 from comment #0)
> Hi Kernel Team,
> 
> I rebuild today latest version from mainline repo.
> And i notice issue regarding xen-netfront.c.
> 
> Error:
> [    3.477400]
> =============================================================================
> ===
> [    3.477633] UBSAN: array-index-out-of-bounds in
> drivers/net/xen-netfront.c:1291:3
> [    3.477858] index 1 is out of range for type 'xen_netif_rx_sring_entry
> [1]'
> [    3.478085] CPU: 0 PID: 700 Comm: NetworkManager Not tainted
> 6.5.0-rc2-1-generation1 #3
> [    3.478088] Hardware name: Intel Corporation W2600CR/W2600CR, BIOS
> SE5C600.86B.02.06.0007.082420181029 01/13/2022
> [    3.478090] Call Trace:
> [    3.478092]  <IRQ>
> [    3.478097]  dump_stack_lvl+0x48/0x70
> [    3.478105]  dump_stack+0x10/0x20
> [    3.478107]  __ubsan_handle_out_of_bounds+0xc6/0x110
> [    3.478114]  xennet_poll+0xa94/0xac0
> [    3.478118]  ? generic_smp_call_function_single_interrupt+0x13/0x20
> [    3.478125]  __napi_poll+0x33/0x200
> [    3.478131]  net_rx_action+0x181/0x2e0
> [    3.478135]  __do_softirq+0xd9/0x346
> [    3.478139]  do_softirq.part.0+0x41/0x80
> [    3.478144]  </IRQ>
> [    3.478145]  <TASK>
> [    3.478146]  __local_bh_enable_ip+0x72/0x80
> [    3.478149]  _raw_spin_unlock_bh+0x1d/0x30
> [    3.478151]  xennet_open+0x75/0x160
> [    3.478154]  __dev_open+0x105/0x1d0
> [    3.478156]  __dev_change_flags+0x1b5/0x230
> [    3.478158]  dev_change_flags+0x27/0x80
> [    3.478160]  do_setlink+0x3d2/0x12b0
> [    3.478164]  ? __nla_validate_parse+0x5b/0xdb0
> [    3.478169]  __rtnl_newlink+0x6f6/0xb10
> [    3.478173]  ? rtnl_newlink+0x2f/0x80
> [    3.478177]  rtnl_newlink+0x48/0x80
> [    3.478180]  rtnetlink_rcv_msg+0x170/0x430
> [    3.478183]  ? fib6_clean_node+0xad/0x190
> [    3.478188]  ? __pfx_rtnetlink_rcv_msg+0x10/0x10
> [    3.478191]  netlink_rcv_skb+0x5d/0x110
> [    3.478195]  rtnetlink_rcv+0x15/0x30
> [    3.478198]  netlink_unicast+0x247/0x390
> [    3.478200]  netlink_sendmsg+0x25e/0x4e0
> [    3.478202]  sock_sendmsg+0xaf/0xc0
> [    3.478204]  ____sys_sendmsg+0x2a9/0x350
> [    3.478206]  ___sys_sendmsg+0x9a/0xf0
> [    3.478212]  ? _copy_from_iter+0x80/0x4a0
> [    3.478217]  __sys_sendmsg+0x89/0xf0
> [    3.478220]  __x64_sys_sendmsg+0x1d/0x30
> [    3.478222]  do_syscall_64+0x5c/0x90
> [    3.478226]  ? do_syscall_64+0x68/0x90
> [    3.478228]  ? ksys_write+0xe6/0x100
> [    3.478232]  ? exit_to_user_mode_prepare+0x49/0x220
> [    3.478236]  ? syscall_exit_to_user_mode+0x1b/0x50
> [    3.478240]  ? do_syscall_64+0x68/0x90
> [    3.478242]  ? do_syscall_64+0x68/0x90
> [    3.478243]  ? irqentry_exit_to_user_mode+0x9/0x30
> [    3.478246]  ? irqentry_exit+0x43/0x50
> [    3.478248]  ? sysvec_xen_hvm_callback+0x4b/0xd0
> [    3.478250]  entry_SYSCALL_64_after_hwframe+0x6e/0xd8
> [    3.478253] RIP: 0033:0x7f973c244e4d
> [    3.478268] Code: 28 89 54 24 1c 48 89 74 24 10 89 7c 24 08 e8 ca ee ff
> ff 8b 54 24 1c 48 8b 74 24 10 41 89 c0 8b 7c 24 08 b8 2e 00 00 00 0f 05 <48>
> 3d 00 f0 ff ff 77 33 44 89 c7 48 89 44 24 08 e8 fe ee ff ff 48
> [    3.478270] RSP: 002b:00007fff4777f470 EFLAGS: 00000293 ORIG_RAX:
> 000000000000002e
> [    3.478273] RAX: ffffffffffffffda RBX: 00005583087c6480 RCX:
> 00007f973c244e4d
> [    3.478274] RDX: 0000000000000000 RSI: 00007fff4777f4c0 RDI:
> 000000000000000c
> [    3.478276] RBP: 00007fff4777f4c0 R08: 0000000000000000 R09:
> 0000000000000000
> [    3.478277] R10: 0000000000000000 R11: 0000000000000293 R12:
> 00005583087c6480
> [    3.478279] R13: 00007fff4777f668 R14: 00007fff4777f65c R15:
> 0000000000000000
> [    3.478283]  </TASK>
> [    3.478284]
> =============================================================================
> ===
> [    3.685513]
> =============================================================================
> ===
> [    3.685751] UBSAN: array-index-out-of-bounds in
> drivers/net/xen-netfront.c:485:7
> [    3.686111] index 1 is out of range for type 'xen_netif_tx_sring_entry
> [1]'
> [    3.686379] CPU: 1 PID: 697 Comm: avahi-daemon Not tainted
> 6.5.0-rc2-1-generation1 #3
> [    3.686381] Hardware name: Intel Corporation W2600CR/W2600CR, BIOS
> SE5C600.86B.02.06.0007.082420181029 01/13/2022
> [    3.686385] Call Trace:
> [    3.686388]  <TASK>
> [    3.686391]  dump_stack_lvl+0x48/0x70
> [    3.686399]  dump_stack+0x10/0x20
> [    3.686399]  __ubsan_handle_out_of_bounds+0xc6/0x110
> [    3.686403]  xennet_tx_setup_grant+0x1f7/0x230
> [    3.686403]  ? __pfx_xennet_tx_setup_grant+0x10/0x10
> [    3.686403]  gnttab_foreach_grant_in_range+0x5c/0x100
> [    3.686415]  xennet_start_xmit+0x428/0x990
> [    3.686415]  ? kmem_cache_alloc_node+0x1b1/0x3b0
> [    3.686415]  dev_hard_start_xmit+0x68/0x1e0
> [    3.686415]  sch_direct_xmit+0x10b/0x350
> [    3.686415]  __dev_queue_xmit+0x512/0xda0
> [    3.686439]  ? ___neigh_create+0x6cb/0x970
> [    3.686439]  neigh_resolve_output+0x118/0x1e0
> [    3.686446]  ip_finish_output2+0x181/0x540
> [    3.686450]  ? netif_rx_internal+0x46/0x140
> [    3.686456]  __ip_finish_output+0xb6/0x180
> [    3.686456]  ? dev_loopback_xmit+0x86/0x110
> [    3.686456]  ip_finish_output+0x29/0x100
> [    3.686456]  ip_mc_output+0x95/0x2e0
> [    3.686456]  ? __pfx_ip_finish_output+0x10/0x10
> [    3.686456]  ip_send_skb+0x9f/0xb0
> [    3.686456]  udp_send_skb+0x158/0x380
> [    3.686475]  udp_sendmsg+0xb84/0xf20
> [    3.686475]  ? do_sys_poll+0x3a1/0x5f0
> [    3.686483]  ? __pfx_ip_generic_getfrag+0x10/0x10
> [    3.686483]  inet_sendmsg+0x76/0x80
> [    3.686483]  ? inet_sendmsg+0x76/0x80
> [    3.686483]  sock_sendmsg+0xa8/0xc0
> [    3.686483]  ? _copy_from_user+0x30/0xa0
> [    3.686483]  ____sys_sendmsg+0x2a9/0x350
> [    3.686483]  ___sys_sendmsg+0x9a/0xf0
> [    3.686483]  __sys_sendmsg+0x89/0xf0
> [    3.686483]  __x64_sys_sendmsg+0x1d/0x30
> [    3.686483]  do_syscall_64+0x5c/0x90
> [    3.686483]  ? exit_to_user_mode_prepare+0x49/0x220
> [    3.686483]  ? syscall_exit_to_user_mode+0x1b/0x50
> [    3.686483]  ? do_syscall_64+0x68/0x90
> [    3.686483]  ? syscall_exit_to_user_mode+0x1b/0x50
> [    3.686483]  ? do_syscall_64+0x68/0x90
> [    3.686483]  entry_SYSCALL_64_after_hwframe+0x6e/0xd8
> [    3.686483] RIP: 0033:0x7ff365942e13
> [    3.686483] Code: 8b 15 b9 a1 00 00 f7 d8 64 89 02 48 c7 c0 ff ff ff ff
> eb b8 0f 1f 00 64 8b 04 25 18 00 00 00 85 c0 75 14 b8 2e 00 00 00 0f 05 <48>
> 3d 00 f0 ff ff 77 55 c3 0f 1f 40 00 48 83 ec 28 89 54 24 1c 48
> [    3.686483] RSP: 002b:00007ffc7bf1ca78 EFLAGS: 00000246 ORIG_RAX:
> 000000000000002e
> [    3.686483] RAX: ffffffffffffffda RBX: 00005596bd24c900 RCX:
> 00007ff365942e13
> [    3.686483] RDX: 0000000000000000 RSI: 00007ffc7bf1cb30 RDI:
> 000000000000000c
> [    3.686483] RBP: 000000000000000c R08: 0000000000000004 R09:
> 0000000000000019
> [    3.686483] R10: 00007ff365a1ca94 R11: 0000000000000246 R12:
> 00007ffc7bf1cb30
> [    3.686483] R13: 0000000000000002 R14: 00005596bd235f9c R15:
> 0000000000000000
> [    3.686483]  </TASK>
> [    3.686483]
> =============================================================================
> ===
> [    3.686858]
> =============================================================================
> ===
> [    3.687190] UBSAN: array-index-out-of-bounds in
> drivers/net/xen-netfront.c:413:4
> [    3.687501] index 1 is out of range for type 'xen_netif_tx_sring_entry
> [1]'
> [    3.687800] CPU: 18 PID: 0 Comm: swapper/18 Not tainted
> 6.5.0-rc2-1-generation1 #3
> [    3.687804] Hardware name: Intel Corporation W2600CR/W2600CR, BIOS
> SE5C600.86B.02.06.0007.082420181029 01/13/2022
> [    3.687806] Call Trace:
> [    3.687808]  <IRQ>
> [    3.687812]  dump_stack_lvl+0x48/0x70
> [    3.687819]  dump_stack+0x10/0x20
> [    3.687821]  __ubsan_handle_out_of_bounds+0xc6/0x110
> [    3.687827]  xennet_tx_buf_gc+0x34a/0x440
> [    3.687831]  xennet_handle_tx.constprop.0+0x49/0x90
> [    3.687834]  xennet_tx_interrupt+0x32/0x70
> [    3.687837]  __handle_irq_event_percpu+0x4f/0x1b0
> [    3.687842]  handle_irq_event+0x39/0x80
> [    3.687846]  handle_edge_irq+0x8c/0x230
> [    3.687849]  handle_irq_desc+0x40/0x60
> [    3.687851]  generic_handle_irq+0x1f/0x30
> [    3.687854]  handle_irq_for_port+0x8e/0x180
> [    3.687858]  ? _raw_spin_unlock_irqrestore+0x11/0x60
> [    3.687861]  __evtchn_fifo_handle_events+0x221/0x330
> [    3.687866]  evtchn_fifo_handle_events+0xe/0x20
> [    3.687869]  __xen_evtchn_do_upcall+0x72/0xd0
> [    3.687873]  xen_hvm_evtchn_do_upcall+0xe/0x20
> [    3.687876]  __sysvec_xen_hvm_callback+0x53/0x70
> [    3.687880]  sysvec_xen_hvm_callback+0x8d/0xd0
> [    3.687884]  </IRQ>
> [    3.687885]  <TASK>
> [    3.687886]  asm_sysvec_xen_hvm_callback+0x1b/0x20
> [    3.687891] RIP: 0010:pv_native_safe_halt+0xb/0x10
> [    3.687896] Code: 0b 66 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 00 90 90 90
> 90 90 90 90 90 90 90 90 90 90 90 90 90 eb 07 0f 00 2d 49 cc 33 00 fb f4 <c3>
> cc cc cc cc 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 55
> [    3.687898] RSP: 0000:ffffad85c0147e08 EFLAGS: 00000246
> [    3.687901] RAX: ffffffffa00d39a0 RBX: 0000000000000002 RCX:
> 0000000000000000
> [    3.687902] RDX: 0000000000000002 RSI: ffffffffa14d28e0 RDI:
> ffff920446abda00
> [    3.687904] RBP: ffffad85c0147e18 R08: 0000000000000000 R09:
> 0000000000000000
> [    3.687905] R10: 0000000000000000 R11: 0000000000000000 R12:
> 0000000000000002
> [    3.687906] R13: 0000000000000002 R14: 0000000000000002 R15:
> ffffffffa14d29c8
> [    3.687909]  ? __pfx_intel_idle_hlt+0x10/0x10
> [    3.687913]  ? intel_idle_hlt+0xc/0x40
> [    3.687916]  cpuidle_enter_state+0xa0/0x730
> [    3.687920]  cpuidle_enter+0x2e/0x50
> [    3.687924]  call_cpuidle+0x23/0x60
> [    3.687928]  do_idle+0x207/0x260
> [    3.687932]  cpu_startup_entry+0x1d/0x20
> [    3.687934]  start_secondary+0x129/0x160
> [    3.687939]  secondary_startup_64_no_verify+0x17e/0x18b
> [    3.687945]  </TASK>
> [    3.687946]
> =============================================================================
> ===
> [    4.624607] bridge: filtering via arp/ip/ip6tables is no longer available
> by default. Update your scripts to load br_netfilter if you need this.
> [    4.629153] Bridge firewalling registered
> [    4.745355] Initializing XFRM netlink socket
> [    4.794107] loop8: detected capacity change from 0 to 8
> [    7.104544] rfkill: input handler disabled
> [   26.445163]
> =============================================================================
> ===
> [   26.445171] UBSAN: array-index-out-of-bounds in
> drivers/net/xen-netfront.c:807:4
> [   26.445175] index 109 is out of range for type 'xen_netif_tx_sring_entry
> [1]'
> [   26.445178] CPU: 8 PID: 1729 Comm: sshd Not tainted
> 6.5.0-rc2-1-generation1 #3
> [   26.445180] Hardware name: Intel Corporation W2600CR/W2600CR, BIOS
> SE5C600.86B.02.06.0007.082420181029 01/13/2022
> [   26.445181] Call Trace:
> [   26.445185]  <TASK>
> [   26.445185]  dump_stack_lvl+0x48/0x70
> [   26.445185]  dump_stack+0x10/0x20
> [   26.445200]  __ubsan_handle_out_of_bounds+0xc6/0x110
> [   26.445206]  xennet_start_xmit+0x932/0x990
> [   26.445211]  dev_hard_start_xmit+0x68/0x1e0
> [   26.445216]  sch_direct_xmit+0x10b/0x350
> [   26.445220]  __dev_queue_xmit+0x512/0xda0
> [   26.445224]  ip_finish_output2+0x261/0x540
> [   26.445225]  __ip_finish_output+0xb6/0x180
> [   26.445225]  ip_finish_output+0x29/0x100
> [   26.445234]  ip_output+0x73/0x120
> [   26.445234]  ? __pfx_ip_finish_output+0x10/0x10
> [   26.445238]  ip_local_out+0x61/0x70
> [   26.445238]  __ip_queue_xmit+0x18d/0x470
> [   26.445238]  ip_queue_xmit+0x15/0x30
> [   26.445238]  __tcp_transmit_skb+0xb39/0xcc0
> [   26.445238]  tcp_write_xmit+0x595/0x1570
> [   26.445238]  ? _copy_from_iter+0x80/0x4a0
> [   26.445256]  __tcp_push_pending_frames+0x37/0x110
> [   26.445259]  tcp_push+0x123/0x190
> [   26.445260]  tcp_sendmsg_locked+0xafe/0xed0
> [   26.445264]  tcp_sendmsg+0x2c/0x50
> [   26.445268]  inet_sendmsg+0x42/0x80
> [   26.445268]  sock_write_iter+0x160/0x180
> [   26.445274]  vfs_write+0x397/0x440
> [   26.445274]  ksys_write+0xc9/0x100
> [   26.445274]  __x64_sys_write+0x19/0x30
> [   26.445274]  do_syscall_64+0x5c/0x90
> [   26.445287]  ? syscall_exit_to_user_mode+0x1b/0x50
> [   26.445290]  ? do_syscall_64+0x68/0x90
> [   26.445290]  ? do_syscall_64+0x68/0x90
> [   26.445294]  ? do_syscall_64+0x68/0x90
> [   26.445294]  ? syscall_exit_to_user_mode+0x1b/0x50
> [   26.445298]  ? do_syscall_64+0x68/0x90
> [   26.445300]  ? exc_page_fault+0x94/0x1b0
> [   26.445302]  entry_SYSCALL_64_after_hwframe+0x6e/0xd8
> [   26.445306] RIP: 0033:0x7f26c4c3d473
> [   26.445318] Code: 8b 15 21 2a 0e 00 f7 d8 64 89 02 48 c7 c0 ff ff ff ff
> eb b7 0f 1f 00 64 8b 04 25 18 00 00 00 85 c0 75 14 b8 01 00 00 00 0f 05 <48>
> 3d 00 f0 ff ff 77 55 c3 0f 1f 40 00 48 83 ec 28 48 89 54 24 18
> [   26.445321] RSP: 002b:00007ffdee7b5528 EFLAGS: 00000246 ORIG_RAX:
> 0000000000000001
> [   26.445321] RAX: ffffffffffffffda RBX: 0000000000000700 RCX:
> 00007f26c4c3d473
> [   26.445321] RDX: 0000000000000700 RSI: 000055567032e230 RDI:
> 0000000000000004
> [   26.445321] RBP: 0000555670313d70 R08: fffffffffffffff0 R09:
> 0000000000000000
> [   26.445321] R10: 0000000000000000 R11: 0000000000000246 R12:
> 000055566fcb2768
> [   26.445321] R13: 0000000000000000 R14: 0000000000000004 R15:
> 000055566fc67a80
> [   26.445332]  </TASK>
> [   26.445333]
> =============================================================================
> ===

Do you have this issue on v6.4 (I mean v6.4 mainline, not v6.4.y stable)?
Comment 4 sander44 2023-07-24 08:56:04 UTC
Hi Bagas Sanjaya,

I tested today with v6.4 from mainline and i this version this is not happened.
Kernel version: v6.4 is clean.
Comment 5 Christian Kujau 2023-10-14 16:37:04 UTC
Upgraded this Ubuntu VM (Xen/PVH DomU) from 6.2.0-34-generic to 6.5.0-9-generic and this happens reliably on every boot. No ill effects though, only this UBSAN splat:

xen_netfront: backend supports XDP headroom
================================================================================
UBSAN: array-index-out-of-bounds in /build/linux-D15vQj/linux-6.5.0/drivers/net/xen-netfront.c:332:9
index 1 is out of range for type 'xen_netif_rx_sring_entry [1]'
CPU: 1 PID: 69 Comm: xenwatch Not tainted 6.5.0-9-generic #9-Ubuntu
Call Trace:
 <TASK>
 dump_stack_lvl+0x48/0x70
 dump_stack+0x10/0x20
 __ubsan_handle_out_of_bounds+0xc6/0x110
 xennet_alloc_rx_buffers+0x2e8/0x300
 xennet_connect+0x15d/0x210
 netback_changed+0xca/0xe0
 xenbus_otherend_changed+0xa0/0x170
 ? __pfx_xenwatch_thread+0x10/0x10
 backend_changed+0x13/0x30
 xenwatch_thread+0x93/0x1b0
 ? __pfx_autoremove_wake_function+0x10/0x10
 kthread+0xf2/0x120
 ? __pfx_kthread+0x10/0x10
 ret_from_fork+0x47/0x70
 ? __pfx_kthread+0x10/0x10
 ret_from_fork_asm+0x1b/0x30
 </TASK>
================================================================================
blkfront: xvda: flush diskcache: enabled; persistent grants: enabled; indirect descriptors: enabled; bounce buffer: enabled
Freeing initrd memory: 35704K
================================================================================
UBSAN: array-index-out-of-bounds in /build/linux-D15vQj/linux-6.5.0/drivers/block/xen-blkfront.c:539:14
index 1 is out of range for type 'blkif_sring_entry [1]'
CPU: 1 PID: 69 Comm: xenwatch Not tainted 6.5.0-9-generic #9-Ubuntu
Call Trace:
 <TASK>
 dump_stack_lvl+0x48/0x70
 dump_stack+0x10/0x20
 __ubsan_handle_out_of_bounds+0xc6/0x110
 blkif_queue_rw_req+0x679/0x690
 ? blk_mq_get_tag+0x26e/0x2f0
 blkif_queue_rq+0xc3/0x350
 __blk_mq_issue_directly+0x4d/0xc0
 blk_mq_try_issue_directly+0x97/0xf0
 blk_mq_submit_bio+0x530/0x570
 __submit_bio+0xb3/0x1c0
 submit_bio_noacct_nocheck+0x13c/0x1f0
 submit_bio_noacct+0x17f/0x5e0
 submit_bio+0x4d/0x80
 submit_bh_wbc+0x124/0x150
 block_read_full_folio+0x33a/0x450
 ? __pfx_blkdev_get_block+0x10/0x10
 ? __pfx_blkdev_read_folio+0x10/0x10
 blkdev_read_folio+0x18/0x30
 filemap_read_folio+0x45/0xf0
 ? __pfx_blkdev_read_folio+0x10/0x10
 do_read_cache_folio+0x80/0x1a0
 read_cache_folio+0x12/0x30
 read_part_sector+0x3b/0xd0
 parse_solaris_x86+0x50/0x5d0
 ? vsnprintf+0x3fa/0x570
 ? snprintf+0x51/0x80
 msdos_partition+0x5df/0x7d0
 ? ldm_partition+0x44/0x370
 ? __pfx_msdos_partition+0x10/0x10
 check_partition+0x13a/0x370
 bdev_disk_changed+0x1c6/0x440
 ? _raw_spin_unlock+0xe/0x40
 blkdev_get_whole+0x85/0xa0
 blkdev_get_by_dev.part.0+0xb2/0x350
 ? bd_prepare_to_claim+0x11b/0x130
 blkdev_get_by_dev+0x63/0x80
 disk_scan_partitions+0x6c/0x100
 device_add_disk+0x3de/0x3e0
 blkfront_connect+0x4b7/0x580
 blkback_changed+0x5d/0x160
 xenbus_otherend_changed+0xa0/0x170
 ? __pfx_xenwatch_thread+0x10/0x10
 backend_changed+0x13/0x30
 xenwatch_thread+0x93/0x1b0
 ? __pfx_autoremove_wake_function+0x10/0x10
 kthread+0xf2/0x120
 ? __pfx_kthread+0x10/0x10
 ret_from_fork+0x47/0x70
 ? __pfx_kthread+0x10/0x10
 ret_from_fork_asm+0x1b/0x30
 </TASK>
================================================================================
================================================================================
UBSAN: array-index-out-of-bounds in /build/linux-D15vQj/linux-6.5.0/drivers/block/xen-blkfront.c:1544:3
index 1 is out of range for type 'blkif_sring_entry [1]'
CPU: 3 PID: 54 Comm: xen-balloon Not tainted 6.5.0-9-generic #9-Ubuntu
Call Trace:
 <IRQ>
 dump_stack_lvl+0x48/0x70
 dump_stack+0x10/0x20
 __ubsan_handle_out_of_bounds+0xc6/0x110
 blkif_interrupt+0x84f/0x940
 __handle_irq_event_percpu+0x4f/0x1b0
 handle_irq_event+0x39/0x80
 handle_edge_irq+0x8c/0x250
 handle_irq_desc+0x40/0x60
 generic_handle_irq+0x1f/0x30
 handle_irq_for_port+0x8e/0x180
 __evtchn_fifo_handle_events+0x221/0x330
 evtchn_fifo_handle_events+0xe/0x20
 __xen_evtchn_do_upcall+0x72/0xd0
 xen_hvm_evtchn_do_upcall+0xe/0x20
 __sysvec_xen_hvm_callback+0x53/0x70
 sysvec_xen_hvm_callback+0x8d/0xd0
 </IRQ>
 <TASK>
 asm_sysvec_xen_hvm_callback+0x1b/0x20
RIP: 0010:xen_hypercall_memory_op+0x5/0x20
Code: cc cc cc cc cc b8 0b 00 00 00 0f 01 c1 c3 cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc b8 0c 00 00 00 <0f> 01 c1 c3 cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc cc
RSP: 0000:ffffb2e400223dd0 EFLAGS: 00000206
RAX: 000000000000000c RBX: ffffb2e400223e20 RCX: 0000000000000000
RDX: 0000000000000001 RSI: ffffb2e400223dd8 RDI: 0000000000001441
RBP: ffffb2e400223e00 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000000 R12: ffffb2e400223e28
R13: 0000000000000200 R14: dead000000000100 R15: 0000000000000200
 ? xenmem_reservation_decrease+0x5d/0x90
 decrease_reservation+0x240/0x330
 balloon_thread+0x319/0x500
 ? __pfx_autoremove_wake_function+0x10/0x10
 ? __pfx_balloon_thread+0x10/0x10
 kthread+0xf2/0x120
 ? __pfx_kthread+0x10/0x10
 ret_from_fork+0x47/0x70
 ? __pfx_kthread+0x10/0x10
Segment Routing with IPv6
 ret_from_fork_asm+0x1b/0x30
 </TASK>
================================================================================
Comment 6 Christian Kujau 2023-10-14 16:38:47 UTC
Created attachment 305218 [details]
Ubuntu Xen/PVH domU dmesg
Comment 7 Arthur Borsboom 2023-11-29 11:40:09 UTC
Experiencing the same UBSAN warnings.

Xen 4.17.3
kernel 6.5.0-13 (Ubuntu 23.10)

kernel log attached
Comment 8 Arthur Borsboom 2023-11-29 11:41:10 UTC
Created attachment 305509 [details]
Kernel log
Comment 9 Chris Mounce 2024-03-31 03:26:49 UTC
FYI, it looks like me and another person have run into this exact same issue on certain EC2 instance types (t2.*): https://bugs.launchpad.net/ubuntu/+source/linux-aws/+bug/2058480


I'm running 6.5.0-1016-aws on Ubuntu 22.04 (jammy, LTS). Commenting on this bug report as well because I'm getting the exact same error message in the kernel logs:


UBSAN: array-index-out-of-bounds in /build/linux-aws-6.5-I1xSUm/linux-aws-6.5-6.5.0/drivers/net/xen-netfront.c:349:9
index 1 is out of range for type 'xen_netif_rx_sring_entry [1]'
Comment 10 sander44 2024-06-14 08:56:32 UTC
Any updates for this?

Is fixed in upstream for 6.10?