Re: [bpf-next v2 2/2] selftests/bpf: Add tests for bpf_copy_from_user_task_str

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




Hello,

kernel test robot noticed "WARNING:possible_recursive_locking_detected" on:

commit: 974e24f3e253a8e69418b73e486f74c6fa40e449 ("[bpf-next v2 2/2] selftests/bpf: Add tests for bpf_copy_from_user_task_str")
url: https://github.com/intel-lab-lkp/linux/commits/Jordan-Rome/selftests-bpf-Add-tests-for-bpf_copy_from_user_task_str/20250107-100850
base: https://git.kernel.org/cgit/linux/kernel/git/bpf/bpf-next.git master
patch link: https://lore.kernel.org/all/20250107020632.170883-2-linux@xxxxxxxxxxxxxx/
patch subject: [bpf-next v2 2/2] selftests/bpf: Add tests for bpf_copy_from_user_task_str

in testcase: kernel-selftests-bpf
version: 
with following parameters:

	group: bpf



config: x86_64-rhel-9.4-bpf
compiler: gcc-12
test machine: 8 threads 1 sockets Intel(R) Core(TM) i7-7700 CPU @ 3.60GHz (Kaby Lake) with 32G memory

(please refer to attached dmesg/kmsg for entire log/backtrace)


If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <oliver.sang@xxxxxxxxx>
| Closes: https://lore.kernel.org/oe-lkp/202501161219.c031baa7-lkp@xxxxxxxxx


[ 1645.762718][T49812] WARNING: possible recursive locking detected
[ 1645.768742][T49812] 6.13.0-rc3-00084-g974e24f3e253 #1 Tainted: G           OE
[ 1645.776333][T49812] --------------------------------------------
[ 1645.782356][T49812] test_progs/49812 is trying to acquire lock:
[1645.788292][T49812] ffff88815d74c620 (&mm->mmap_lock){++++}-{4:4}, at: __might_fault (mm/memory.c:6852 mm/memory.c:6845) 
[ 1645.796945][T49812]
[ 1645.796945][T49812] but task is already holding lock:
[1645.804188][T49812] ffff88815d74c620 (&mm->mmap_lock){++++}-{4:4}, at: copy_str_from_process_vm (include/linux/mmap_lock.h:153 mm/memory.c:6686 mm/memory.c:6810) 
[ 1645.813879][T49812]
[ 1645.813879][T49812] other info that might help us debug this:
[ 1645.821816][T49812]  Possible unsafe locking scenario:
[ 1645.821816][T49812]
[ 1645.829146][T49812]        CPU0
[ 1645.832298][T49812]        ----
[ 1645.835450][T49812]   lock(&mm->mmap_lock);
[ 1645.839652][T49812]   lock(&mm->mmap_lock);
[ 1645.843865][T49812]
[ 1645.843865][T49812]  *** DEADLOCK ***
[ 1645.843865][T49812]
[ 1645.851888][T49812]  May be due to missing lock nesting notation
[ 1645.851888][T49812]
[ 1645.860086][T49812] 3 locks held by test_progs/49812:
[1645.865153][T49812] #0: ffff88835c5ab698 (&p->lock){+.+.}-{4:4}, at: bpf_seq_read (kernel/bpf/bpf_iter.c:105) 
[1645.873715][T49812] #1: ffffffff84ca6ec0 (rcu_read_lock_trace){....}-{0:0}, at: bpf_iter_run_prog (include/linux/rcupdate.h:337 include/linux/rcupdate_trace.h:58 kernel/bpf/bpf_iter.c:700) 
[1645.883680][T49812] #2: ffff88815d74c620 (&mm->mmap_lock){++++}-{4:4}, at: copy_str_from_process_vm (include/linux/mmap_lock.h:153 mm/memory.c:6686 mm/memory.c:6810) 
[ 1645.893817][T49812]
[ 1645.893817][T49812] stack backtrace:
[ 1645.899581][T49812] CPU: 3 UID: 0 PID: 49812 Comm: test_progs Tainted: G           OE      6.13.0-rc3-00084-g974e24f3e253 #1
[ 1645.910828][T49812] Tainted: [O]=OOT_MODULE, [E]=UNSIGNED_MODULE
[ 1645.916848][T49812] Hardware name: Dell Inc. OptiPlex 7050/062KRH, BIOS 1.2.0 12/22/2016
[ 1645.924972][T49812] Call Trace:
[ 1645.928128][T49812]  <TASK>
[1645.930938][T49812] dump_stack_lvl (lib/dump_stack.c:124) 
[1645.935320][T49812] print_deadlock_bug (kernel/locking/lockdep.c:3040) 
[1645.940224][T49812] validate_chain (kernel/locking/lockdep.c:3894) 
[1645.944784][T49812] ? __pfx_validate_chain (kernel/locking/lockdep.c:3860) 
[1645.949860][T49812] ? mark_lock (kernel/locking/lockdep.c:4727) 
[1645.954062][T49812] __lock_acquire (kernel/locking/lockdep.c:5226) 
[1645.958640][T49812] lock_acquire (kernel/locking/lockdep.c:467 kernel/locking/lockdep.c:5851 kernel/locking/lockdep.c:5814) 
[1645.963015][T49812] ? __might_fault (mm/memory.c:6852 mm/memory.c:6845) 
[1645.967479][T49812] ? __pfx_lock_acquire (kernel/locking/lockdep.c:5817) 
[1645.972377][T49812] ? __rcu_read_unlock (kernel/rcu/tree_plugin.h:440 (discriminator 2)) 
[1645.977187][T49812] ? mtree_load (lib/maple_tree.c:6337) 
[1645.981563][T49812] ? lock_is_held_type (kernel/locking/lockdep.c:5590 kernel/locking/lockdep.c:5921) 
[1645.986460][T49812] ? __might_fault (mm/memory.c:6852 mm/memory.c:6845) 
[1645.990923][T49812] __might_fault (mm/memory.c:6852 mm/memory.c:6845) 
[1645.995212][T49812] ? __might_fault (mm/memory.c:6852 mm/memory.c:6845) 
[1645.999699][T49812] strncpy_from_user (lib/strncpy_from_user.c:120) 
[1646.004425][T49812] copy_str_from_process_vm (include/linux/page-flags.h:242 include/linux/highmem.h:661 mm/memory.c:6722 mm/memory.c:6810) 
[1646.009845][T49812] ? __pfx_copy_str_from_process_vm (mm/memory.c:6802) 
[1646.015789][T49812] bpf_copy_from_user_task_str (kernel/bpf/helpers.c:3104) 
[1646.021297][T49812] bpf_prog_f57787fdd126684b_dump_task_sleepable+0x278/0x4d0 
[1646.028546][T49812] ? __might_fault (mm/memory.c:6852 mm/memory.c:6845) 
[1646.033011][T49812] bpf_iter_run_prog (include/linux/bpf.h:1290 include/linux/filter.h:701 include/linux/filter.h:708 kernel/bpf/bpf_iter.c:704) 
[1646.037821][T49812] ? __pfx_bpf_iter_run_prog (kernel/bpf/bpf_iter.c:695) 
[1646.043151][T49812] ? __pfx___lock_release+0x10/0x10 
[1646.048837][T49812] task_seq_show (kernel/bpf/task_iter.c:193) 
[1646.053124][T49812] ? __pfx_task_seq_show (kernel/bpf/task_iter.c:193) 
[1646.058111][T49812] bpf_seq_read (kernel/bpf/bpf_iter.c:138) 
[1646.062399][T49812] ? rw_verify_area (include/linux/fsnotify_backend.h:501 include/linux/fsnotify.h:24 include/linux/fsnotify.h:127 include/linux/fsnotify.h:153 fs/read_write.c:470) 
[1646.067035][T49812] vfs_read (fs/read_write.c:563) 
[1646.071062][T49812] ? __pfx___lock_release+0x10/0x10 
[1646.076740][T49812] ? __pfx_vfs_read (fs/read_write.c:546) 
[1646.081290][T49812] ? __pfx___lock_release+0x10/0x10 
[1646.086968][T49812] ? __mutex_unlock_slowpath (arch/x86/include/asm/atomic64_64.h:101 include/linux/atomic/atomic-arch-fallback.h:4329 include/linux/atomic/atomic-long.h:1506 include/linux/atomic/atomic-instrumented.h:4481 kernel/locking/mutex.c:913) 
[1646.092472][T49812] ? __fget_files (include/linux/rcupdate.h:347 include/linux/rcupdate.h:880 fs/file.c:1050) 
[1646.097022][T49812] ? __rcu_read_unlock (kernel/rcu/tree_plugin.h:440 (discriminator 2)) 
[1646.101831][T49812] ? __fget_files (fs/file.c:1053) 
[1646.106383][T49812] ksys_read (fs/read_write.c:709) 
[1646.110410][T49812] ? __pfx_ksys_read (fs/read_write.c:698) 
[1646.115042][T49812] ? fput (arch/x86/include/asm/atomic64_64.h:79 include/linux/atomic/atomic-arch-fallback.h:2913 include/linux/atomic/atomic-arch-fallback.h:3364 include/linux/atomic/atomic-long.h:698 include/linux/atomic/atomic-instrumented.h:3767 include/linux/file_ref.h:157 fs/file_table.c:501) 
[1646.118809][T49812] ? ksys_read (fs/read_write.c:698) 
[1646.123007][T49812] ? mark_held_locks (kernel/locking/lockdep.c:4309) 
[1646.127662][T49812] do_syscall_64 (arch/x86/entry/common.c:52 arch/x86/entry/common.c:83) 
[1646.132033][T49812] ? lockdep_hardirqs_on_prepare (kernel/locking/lockdep.c:4347 kernel/locking/lockdep.c:4406) 
[1646.137887][T49812] ? syscall_exit_to_user_mode (arch/x86/include/asm/jump_label.h:36 include/linux/context_tracking_state.h:108 include/linux/context_tracking.h:41 include/linux/entry-common.h:364 kernel/entry/common.c:220) 
[1646.143481][T49812] ? do_syscall_64 (arch/x86/entry/common.c:102) 
[1646.148026][T49812] ? __pfx_vfs_read (fs/read_write.c:546) 
[1646.152574][T49812] ? fput (arch/x86/include/asm/atomic64_64.h:79 include/linux/atomic/atomic-arch-fallback.h:2913 include/linux/atomic/atomic-arch-fallback.h:3364 include/linux/atomic/atomic-long.h:698 include/linux/atomic/atomic-instrumented.h:3767 include/linux/file_ref.h:157 fs/file_table.c:501) 
[1646.156339][T49812] ? __fget_files (include/linux/rcupdate.h:347 include/linux/rcupdate.h:880 fs/file.c:1050) 
[1646.160891][T49812] ? __rcu_read_unlock (kernel/rcu/tree_plugin.h:440 (discriminator 2)) 
[1646.165712][T49812] ? __fget_files (fs/file.c:1053) 
[1646.170267][T49812] ? fput (arch/x86/include/asm/atomic64_64.h:79 include/linux/atomic/atomic-arch-fallback.h:2913 include/linux/atomic/atomic-arch-fallback.h:3364 include/linux/atomic/atomic-long.h:698 include/linux/atomic/atomic-instrumented.h:3767 include/linux/file_ref.h:157 fs/file_table.c:501) 
[1646.174039][T49812] ? ksys_read (fs/read_write.c:698) 
[1646.178243][T49812] ? __pfx_ksys_read (fs/read_write.c:698) 
[1646.182887][T49812] ? mark_held_locks (kernel/locking/lockdep.c:4309) 
[1646.187531][T49812] ? lockdep_hardirqs_on_prepare (kernel/locking/lockdep.c:4347 kernel/locking/lockdep.c:4406) 
[1646.193388][T49812] ? syscall_exit_to_user_mode (arch/x86/include/asm/jump_label.h:36 include/linux/context_tracking_state.h:108 include/linux/context_tracking.h:41 include/linux/entry-common.h:364 kernel/entry/common.c:220) 
[1646.198982][T49812] ? do_syscall_64 (arch/x86/entry/common.c:102) 
[1646.203529][T49812] ? syscall_exit_to_user_mode (arch/x86/include/asm/jump_label.h:36 include/linux/context_tracking_state.h:108 include/linux/context_tracking.h:41 include/linux/entry-common.h:364 kernel/entry/common.c:220) 
[1646.209122][T49812] ? do_syscall_64 (arch/x86/entry/common.c:102) 
[1646.213695][T49812] ? __fget_files (fs/file.c:1053) 
[1646.218244][T49812] ? __fget_files (include/linux/rcupdate.h:347 include/linux/rcupdate.h:880 fs/file.c:1050) 
[1646.222794][T49812] ? __rcu_read_unlock (kernel/rcu/tree_plugin.h:440 (discriminator 2)) 
[1646.227602][T49812] ? __fget_files (fs/file.c:1053) 
[1646.232151][T49812] ? fput (arch/x86/include/asm/atomic64_64.h:79 include/linux/atomic/atomic-arch-fallback.h:2913 include/linux/atomic/atomic-arch-fallback.h:3364 include/linux/atomic/atomic-long.h:698 include/linux/atomic/atomic-instrumented.h:3767 include/linux/file_ref.h:157 fs/file_table.c:501) 
[1646.235917][T49812] ? ksys_read (fs/read_write.c:698) 
[1646.240118][T49812] ? __pfx_ksys_read (fs/read_write.c:698) 
[1646.244752][T49812] ? mark_held_locks (kernel/locking/lockdep.c:4309) 
[1646.249391][T49812] ? lockdep_hardirqs_on_prepare (kernel/locking/lockdep.c:4347 kernel/locking/lockdep.c:4406) 
[1646.255245][T49812] ? syscall_exit_to_user_mode (arch/x86/include/asm/jump_label.h:36 include/linux/context_tracking_state.h:108 include/linux/context_tracking.h:41 include/linux/entry-common.h:364 kernel/entry/common.c:220) 
[1646.260837][T49812] ? do_syscall_64 (arch/x86/entry/common.c:102) 
[1646.265383][T49812] ? do_syscall_64 (arch/x86/entry/common.c:102) 
[1646.269930][T49812] entry_SYSCALL_64_after_hwframe (arch/x86/entry/entry_64.S:130) 
[ 1646.275697][T49812] RIP: 0033:0x7fdb112fe25c
[ 1646.279982][T49812] Code: ec 28 48 89 54 24 18 48 89 74 24 10 89 7c 24 08 e8 d9 d5 f8 ff 48 8b 54 24 18 48 8b 74 24 10 41 89 c0 8b 7c 24 08 31 c0 0f 05 <48> 3d 00 f0 ff ff 77 34 44 89 c7 48 89 44 24 08 e8 2f d6 f8 ff 48
All code
========
   0:	ec                   	in     (%dx),%al
   1:	28 48 89             	sub    %cl,-0x77(%rax)
   4:	54                   	push   %rsp
   5:	24 18                	and    $0x18,%al
   7:	48 89 74 24 10       	mov    %rsi,0x10(%rsp)
   c:	89 7c 24 08          	mov    %edi,0x8(%rsp)
  10:	e8 d9 d5 f8 ff       	call   0xfffffffffff8d5ee
  15:	48 8b 54 24 18       	mov    0x18(%rsp),%rdx
  1a:	48 8b 74 24 10       	mov    0x10(%rsp),%rsi
  1f:	41 89 c0             	mov    %eax,%r8d
  22:	8b 7c 24 08          	mov    0x8(%rsp),%edi
  26:	31 c0                	xor    %eax,%eax
  28:	0f 05                	syscall
  2a:*	48 3d 00 f0 ff ff    	cmp    $0xfffffffffffff000,%rax		<-- trapping instruction
  30:	77 34                	ja     0x66
  32:	44 89 c7             	mov    %r8d,%edi
  35:	48 89 44 24 08       	mov    %rax,0x8(%rsp)
  3a:	e8 2f d6 f8 ff       	call   0xfffffffffff8d66e
  3f:	48                   	rex.W

Code starting with the faulting instruction
===========================================
   0:	48 3d 00 f0 ff ff    	cmp    $0xfffffffffffff000,%rax
   6:	77 34                	ja     0x3c
   8:	44 89 c7             	mov    %r8d,%edi
   b:	48 89 44 24 08       	mov    %rax,0x8(%rsp)
  10:	e8 2f d6 f8 ff       	call   0xfffffffffff8d644
  15:	48                   	rex.W


The kernel config and materials to reproduce are available at:
https://download.01.org/0day-ci/archive/20250116/202501161219.c031baa7-lkp@xxxxxxxxx



-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki





[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux