------- Comment From <email address hidden> 2023-10-17 10:23 EDT-------
--- MATTHEW R. commented ---
I encountered this issue recently while verifying a KVM feature. It's worth noting that if a kernel has UBSAN enabled (https://docs.kernel.org/dev-tools/ubsan.html) then rather than silently updating an incorrect stats counter you will also get a UBSAN array-index-out-of-bounds warning every time this occurs. In my case, I bumped into this because I was using an Ubuntu kernel which came with UBSAN enabled. Example of the warning:
[ 26.335369] ================================================================================
[ 26.335381] UBSAN: array-index-out-of-bounds in /build/linux-O6Qi7m/linux-5.15.0/net/smc/af_smc.c:2402:3
[ 26.335385] index -1 is out of range for type 'u64 [9]'
[ 26.335388] CPU: 0 PID: 274 Comm: iperf3 Tainted: G E 5.15.0-79-generic #86-Ubuntu
[ 26.335391] Hardware name: IBM 8561 T01 772 (KVM/Linux)
[ 26.335393] Call Trace:
[ 26.335397] [<00000000cd92e63a>] dump_stack_lvl+0x62/0x80
[ 26.335404] [<00000000cd92e36c>] ubsan_epilogue+0x1c/0x48
[ 26.335406] [<00000000cd52d3c4>] __ubsan_handle_out_of_bounds+0x94/0xa0
[ 26.335411] [<000003ff8033f9da>] smc_sendmsg+0x2aa/0x2d0 [smc]
[ 26.335425] [<00000000cd6a79a4>] sock_sendmsg+0x64/0x80
[ 26.335431] [<00000000cd6a7a32>] sock_write_iter+0x72/0xa0
[ 26.335433] [<00000000cd1d4000>] new_sync_write+0x100/0x190
[ 26.335438] [<00000000cd1d4bb8>] vfs_write+0x1e8/0x280
[ 26.335440] [<00000000cd1d7014>] ksys_write+0xb4/0x100
[ 26.335442] [<00000000cd932c7c>] __do_syscall+0x1bc/0x1f0
[ 26.335446] [<00000000cd940148>] system_call+0x78/0xa0
This makes the issue much more visible.
Worse, if you have panic_on_warn enabled (like I did) then this warning will subsequently trigger a kernel panic.
------- Comment From <email address hidden> 2023-10-17 10:23 EDT-------
--- MATTHEW R. commented ---
I encountered this issue recently while verifying a KVM feature. It's worth noting that if a kernel has UBSAN enabled (https:/ /docs.kernel. org/dev- tools/ubsan. html) then rather than silently updating an incorrect stats counter you will also get a UBSAN array-index- out-of- bounds warning every time this occurs. In my case, I bumped into this because I was using an Ubuntu kernel which came with UBSAN enabled. Example of the warning:
[ 26.335369] ======= ======= ======= ======= ======= ======= ======= ======= ======= ======= ======= === out-of- bounds in /build/ linux-O6Qi7m/ linux-5. 15.0/net/ smc/af_ smc.c:2402: 3 63a>] dump_stack_ lvl+0x62/ 0x80 36c>] ubsan_epilogue+ 0x1c/0x48 3c4>] __ubsan_ handle_ out_of_ bounds+ 0x94/0xa0 9da>] smc_sendmsg+ 0x2aa/0x2d0 [smc] 9a4>] sock_sendmsg+ 0x64/0x80 a32>] sock_write_ iter+0x72/ 0xa0 000>] new_sync_ write+0x100/ 0x190 bb8>] vfs_write+ 0x1e8/0x280 014>] ksys_write+ 0xb4/0x100 c7c>] __do_syscall+ 0x1bc/0x1f0 148>] system_ call+0x78/ 0xa0
[ 26.335381] UBSAN: array-index-
[ 26.335385] index -1 is out of range for type 'u64 [9]'
[ 26.335388] CPU: 0 PID: 274 Comm: iperf3 Tainted: G E 5.15.0-79-generic #86-Ubuntu
[ 26.335391] Hardware name: IBM 8561 T01 772 (KVM/Linux)
[ 26.335393] Call Trace:
[ 26.335397] [<00000000cd92e
[ 26.335404] [<00000000cd92e
[ 26.335406] [<00000000cd52d
[ 26.335411] [<000003ff8033f
[ 26.335425] [<00000000cd6a7
[ 26.335431] [<00000000cd6a7
[ 26.335433] [<00000000cd1d4
[ 26.335438] [<00000000cd1d4
[ 26.335440] [<00000000cd1d7
[ 26.335442] [<00000000cd932
[ 26.335446] [<00000000cd940
This makes the issue much more visible.
Worse, if you have panic_on_warn enabled (like I did) then this warning will subsequently trigger a kernel panic.