linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* UBSAN shitf-out-of-bounds regression in NFS in 5.18-rc1
@ 2022-04-04  3:52 Steve French
  2022-04-04 13:32 ` Trond Myklebust
  0 siblings, 1 reply; 2+ messages in thread
From: Steve French @ 2022-04-04  3:52 UTC (permalink / raw)
  To: linux-fsdevel, linux-nfs, LKML

Noticed this shift-out-of-bounds error in NFS, and also similar
messages logged in a few other drivers when running 5.18-rc1.  It
seems to have regressed in the last ten days because I didn't see it
in the same setup when running an earlier version of the rc (about 10
days ago).  Any ideas?

[Sun Apr 3 22:16:57 2022] UBSAN: shift-out-of-bounds in
lib/percpu-refcount.c:140:63
[Sun Apr 3 22:16:57 2022] left shift of negative value -9223372036854775807
[Sun Apr 3 22:16:57 2022] CPU: 7 PID: 10230 Comm: aio-free-ring-w Not
tainted 5.18.0-rc1 #1
[Sun Apr 3 22:16:57 2022] Hardware name: Red Hat KVM, BIOS 0.5.1 01/01/2011
[Sun Apr 3 22:16:57 2022] Call Trace:
[Sun Apr 3 22:16:57 2022] <TASK>
[Sun Apr 3 22:16:57 2022] dump_stack_lvl+0x55/0x6d
[Sun Apr 3 22:16:57 2022] ubsan_epilogue+0x5/0x40
[Sun Apr 3 22:16:57 2022] __ubsan_handle_shift_out_of_bounds+0xfa/0x140
[Sun Apr 3 22:16:57 2022] ? lock_acquire+0x275/0x320
[Sun Apr 3 22:16:57 2022] ? _raw_spin_unlock_irqrestore+0x40/0x60
[Sun Apr 3 22:16:57 2022] ? percpu_ref_exit+0x87/0x90
[Sun Apr 3 22:16:57 2022] percpu_ref_exit+0x87/0x90
[Sun Apr 3 22:16:57 2022] ioctx_alloc+0x500/0x8f0
[Sun Apr 3 22:16:57 2022] __x64_sys_io_setup+0x58/0x240
[Sun Apr 3 22:16:57 2022] do_syscall_64+0x3a/0x80
[Sun Apr 3 22:16:57 2022] entry_SYSCALL_64_after_hwframe+0x44/0xae
[Sun Apr 3 22:16:57 2022] RIP: 0033:0x7f0c32c52d6d
[Sun Apr 3 22:16:57 2022] Code: 00 c3 66 2e 0f 1f 84 00 00 00 00 00 90
f3 0f 1e fa 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c
8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 8b 0d eb 80 0c 00 f7
d8 64 89 01 48
[Sun Apr 3 22:16:57 2022] RSP: 002b:00007fffff3fedc8 EFLAGS: 00000202
ORIG_RAX: 00000000000000ce
[Sun Apr 3 22:16:57 2022] RAX: ffffffffffffffda RBX: 0000000000002710
RCX: 00007f0c32c52d6d
[Sun Apr 3 22:16:57 2022] RDX: 00007f0c32c52f47 RSI: 00007fffff3fee08
RDI: 0000000000002710
[Sun Apr 3 22:16:57 2022] RBP: 00007f0c32b586c0 R08: 0000000000000000
R09: 00007fffff3fef08
[Sun Apr 3 22:16:57 2022] R10: 0000000000000000 R11: 0000000000000202
R12: 000000000000000c
[Sun Apr 3 22:16:57 2022] R13: 00007fffff3fee08 R14: 0000000000000000
R15: 0000000000000000
[Sun Apr  3 22:16:57 2022]  </TASK>
[Sun Apr  3 22:16:57 2022]
================================================================================
[Sun Apr  3 22:16:57 2022]
================================================================================
[Sun Apr  3 22:16:57 2022] UBSAN: shift-out-of-bounds in
./include/linux/nfs_fs.h:606:9
[Sun Apr  3 22:16:57 2022] left shift of 1 by 63 places cannot be
represented in type 'long long int'
[Sun Apr  3 22:16:57 2022] CPU: 5 PID: 32260 Comm: kworker/u16:3 Not
tainted 5.18.0-rc1 #1
[Sun Apr  3 22:16:57 2022] Hardware name: Red Hat KVM, BIOS 0.5.1 01/01/2011
[Sun Apr  3 22:16:57 2022] Workqueue: rpciod rpc_async_schedule [sunrpc]
[Sun Apr  3 22:16:57 2022] Call Trace:
[Sun Apr  3 22:16:57 2022]  <TASK>
[Sun Apr  3 22:16:57 2022]  dump_stack_lvl+0x55/0x6d
[Sun Apr  3 22:16:57 2022]  ubsan_epilogue+0x5/0x40
[Sun Apr  3 22:16:57 2022]  __ubsan_handle_shift_out_of_bounds+0xfa/0x140
[Sun Apr  3 22:16:57 2022]  ? lock_acquire+0x275/0x320
[Sun Apr  3 22:16:57 2022]  ? ww_mutex_trylock+0x2f1/0x370
[Sun Apr  3 22:16:57 2022]  ? nfs_writeback_update_inode+0x5f/0xd0 [nfs]
[Sun Apr  3 22:16:57 2022]  nfs_writeback_update_inode+0x5f/0xd0 [nfs]
[Sun Apr  3 22:16:57 2022]  ?
trace_raw_output_svcsock_new_socket+0xc0/0xc0 [sunrpc]
[Sun Apr  3 22:16:57 2022]  ?
trace_raw_output_svcsock_new_socket+0xc0/0xc0 [sunrpc]
[Sun Apr  3 22:16:57 2022]  nfs4_write_done_cb+0x61/0x1d0 [nfsv4]
[Sun Apr  3 22:16:57 2022]  ?
trace_raw_output_svcsock_new_socket+0xc0/0xc0 [sunrpc]
[Sun Apr  3 22:16:57 2022]  ?
trace_raw_output_svcsock_new_socket+0xc0/0xc0 [sunrpc]
[Sun Apr  3 22:16:57 2022]  ? nfs41_sequence_done+0x2c/0x40 [nfsv4]
[Sun Apr  3 22:16:57 2022]  nfs_writeback_done+0x37/0x210 [nfs]
[Sun Apr  3 22:16:57 2022]  ?
trace_raw_output_svcsock_new_socket+0xc0/0xc0 [sunrpc]
[Sun Apr  3 22:16:57 2022]  nfs_pgio_result+0x1d/0x60 [nfs]
[Sun Apr  3 22:16:57 2022]  rpc_exit_task+0x97/0x2b0 [sunrpc]
[Sun Apr  3 22:16:57 2022]  __rpc_execute+0xc4/0x7d0 [sunrpc]
[Sun Apr  3 22:16:57 2022]  ? lock_is_held_type+0xea/0x140
[Sun Apr  3 22:16:57 2022]  rpc_async_schedule+0x29/0x40 [sunrpc]
[Sun Apr  3 22:16:57 2022]  process_one_work+0x25b/0x5f0
[Sun Apr  3 22:16:57 2022]  worker_thread+0x30/0x360
[Sun Apr  3 22:16:57 2022]  ? process_one_work+0x5f0/0x5f0
[Sun Apr  3 22:16:57 2022]  kthread+0xe8/0x110
[Sun Apr  3 22:16:57 2022]  ? kthread_complete_and_exit+0x20/0x20
[Sun Apr  3 22:16:57 2022]  ret_from_fork+0x22/0x30
[Sun Apr  3 22:16:57 2022]  </TASK>
[Sun Apr  3 22:16:57 2022]
================================================================================


-- 
Thanks,

Steve

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: UBSAN shitf-out-of-bounds regression in NFS in 5.18-rc1
  2022-04-04  3:52 UBSAN shitf-out-of-bounds regression in NFS in 5.18-rc1 Steve French
@ 2022-04-04 13:32 ` Trond Myklebust
  0 siblings, 0 replies; 2+ messages in thread
From: Trond Myklebust @ 2022-04-04 13:32 UTC (permalink / raw)
  To: smfrench, linux-nfs, linux-fsdevel, viro, linux-kernel

Thanks Steve!

On Sun, 2022-04-03 at 22:52 -0500, Steve French wrote:
> Noticed this shift-out-of-bounds error in NFS, and also similar
> messages logged in a few other drivers when running 5.18-rc1.  It
> seems to have regressed in the last ten days because I didn't see it
> in the same setup when running an earlier version of the rc (about 10
> days ago).  Any ideas?
> 
> [Sun Apr 3 22:16:57 2022] UBSAN: shift-out-of-bounds in
> lib/percpu-refcount.c:140:63
> [Sun Apr 3 22:16:57 2022] left shift of negative value -
> 9223372036854775807
> [Sun Apr 3 22:16:57 2022] CPU: 7 PID: 10230 Comm: aio-free-ring-w Not
> tainted 5.18.0-rc1 #1
> [Sun Apr 3 22:16:57 2022] Hardware name: Red Hat KVM, BIOS 0.5.1
> 01/01/2011
> [Sun Apr 3 22:16:57 2022] Call Trace:
> [Sun Apr 3 22:16:57 2022] <TASK>
> [Sun Apr 3 22:16:57 2022] dump_stack_lvl+0x55/0x6d
> [Sun Apr 3 22:16:57 2022] ubsan_epilogue+0x5/0x40
> [Sun Apr 3 22:16:57 2022]
> __ubsan_handle_shift_out_of_bounds+0xfa/0x140
> [Sun Apr 3 22:16:57 2022] ? lock_acquire+0x275/0x320
> [Sun Apr 3 22:16:57 2022] ? _raw_spin_unlock_irqrestore+0x40/0x60
> [Sun Apr 3 22:16:57 2022] ? percpu_ref_exit+0x87/0x90
> [Sun Apr 3 22:16:57 2022] percpu_ref_exit+0x87/0x90
> [Sun Apr 3 22:16:57 2022] ioctx_alloc+0x500/0x8f0
> [Sun Apr 3 22:16:57 2022] __x64_sys_io_setup+0x58/0x240
> [Sun Apr 3 22:16:57 2022] do_syscall_64+0x3a/0x80
> [Sun Apr 3 22:16:57 2022] entry_SYSCALL_64_after_hwframe+0x44/0xae
> [Sun Apr 3 22:16:57 2022] RIP: 0033:0x7f0c32c52d6d
> [Sun Apr 3 22:16:57 2022] Code: 00 c3 66 2e 0f 1f 84 00 00 00 00 00
> 90
> f3 0f 1e fa 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c
> 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 8b 0d eb 80 0c 00
> f7
> d8 64 89 01 48
> [Sun Apr 3 22:16:57 2022] RSP: 002b:00007fffff3fedc8 EFLAGS: 00000202
> ORIG_RAX: 00000000000000ce
> [Sun Apr 3 22:16:57 2022] RAX: ffffffffffffffda RBX: 0000000000002710
> RCX: 00007f0c32c52d6d
> [Sun Apr 3 22:16:57 2022] RDX: 00007f0c32c52f47 RSI: 00007fffff3fee08
> RDI: 0000000000002710
> [Sun Apr 3 22:16:57 2022] RBP: 00007f0c32b586c0 R08: 0000000000000000
> R09: 00007fffff3fef08
> [Sun Apr 3 22:16:57 2022] R10: 0000000000000000 R11: 0000000000000202
> R12: 000000000000000c
> [Sun Apr 3 22:16:57 2022] R13: 00007fffff3fee08 R14: 0000000000000000
> R15: 0000000000000000
> [Sun Apr  3 22:16:57 2022]  </TASK>
> [Sun Apr  3 22:16:57 2022]
> =====================================================================
> ===========
> [Sun Apr  3 22:16:57 2022]
> =====================================================================
> ===========
> [Sun Apr  3 22:16:57 2022] UBSAN: shift-out-of-bounds in
> ./include/linux/nfs_fs.h:606:9
> [Sun Apr  3 22:16:57 2022] left shift of 1 by 63 places cannot be
> represented in type 'long long int'

Hmm... It looks like it is actually complaining about the definition of
OFFSET_MAX in fs.h:

#ifndef OFFSET_MAX
#define INT_LIMIT(x)    (~((x)1 << (sizeof(x)*8 - 1)))
#define OFFSET_MAX      INT_LIMIT(loff_t)
#define OFFT_OFFSET_MAX INT_LIMIT(off_t)
#endif

Since loff_t is signed, I suspect it is unhappy that the shift by 63
overflows into a negative value.
I don't know who wrote this code (it predates git) so punting to Al.

-- 
Trond Myklebust
Linux NFS client maintainer, Hammerspace
trond.myklebust@hammerspace.com



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-04-04 13:32 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-04  3:52 UBSAN shitf-out-of-bounds regression in NFS in 5.18-rc1 Steve French
2022-04-04 13:32 ` Trond Myklebust

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).