diff mbox series

[v2,2/5] context_tracking: Make context_tracking_key __ro_after_init

Message ID 20240206173911.4131670-3-vschneid@redhat.com (mailing list archive)
State New, archived
Headers show
Series jump_label: Fix __ro_after_init keys for modules & annotate some keys | expand

Commit Message

Valentin Schneider Feb. 6, 2024, 5:39 p.m. UTC
context_tracking_key is only ever enabled in __init ct_cpu_tracker_user(),
so mark it as __ro_after_init.

Signed-off-by: Valentin Schneider <vschneid@redhat.com>
Acked-by: Josh Poimboeuf <jpoimboe@kernel.org>
---
 kernel/context_tracking.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

kernel test robot Feb. 19, 2024, 6:10 a.m. UTC | #1
Hello,

kernel test robot noticed "WARNING:at_kernel/jump_label.c:#jump_label_del_module" on:

commit: b42c2f5e8e4d403b5891b566b015177c8f471858 ("[PATCH v2 2/5] context_tracking: Make context_tracking_key __ro_after_init")
url: https://github.com/intel-lab-lkp/linux/commits/Valentin-Schneider/jump_label-module-Don-t-alloc-static_key_mod-for-__ro_after_init-keys/20240207-014501
base: https://git.kernel.org/cgit/virt/kvm/kvm.git queue
patch link: https://lore.kernel.org/all/20240206173911.4131670-3-vschneid@redhat.com/
patch subject: [PATCH v2 2/5] context_tracking: Make context_tracking_key __ro_after_init

in testcase: ltp
version: ltp-x86_64-14c1f76-1_20230715
with following parameters:

	test: kernel_misc



compiler: gcc-12
test machine: 8 threads 1 sockets Intel(R) Core(TM) i7-3770K CPU @ 3.50GHz (Ivy Bridge) with 16G 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@intel.com>
| Closes: https://lore.kernel.org/oe-lkp/202402191313.3276317d-oliver.sang@intel.com


[  215.214621][ T3608] ------------[ cut here ]------------
[ 215.214849][ T3608] WARNING: CPU: 1 PID: 3608 at kernel/jump_label.c:764 jump_label_del_module (kernel/jump_label.c:764 (discriminator 1)) 
[  215.215123][ T3608] Modules linked in: rcutorture(-) torture netconsole btrfs blake2b_generic xor raid6_pq zstd_compress libcrc32c intel_rapl_msr intel_rapl_common x86_pkg_temp_thermal intel_powerclamp sd_mod t10_pi coretemp crc64_rocksoft_generic crc64_rocksoft kvm_intel crc64 sg ipmi_devintf i915 ipmi_msghandler kvm irqbypass crct10dif_pclmul crc32_pclmul crc32c_intel ghash_clmulni_intel sha512_ssse3 drm_buddy rapl intel_gtt intel_cstate drm_display_helper mxm_wmi firewire_ohci ttm ahci firewire_core libahci drm_kms_helper intel_uncore crc_itu_t libata i2c_i801 video i2c_smbus lpc_ich wmi binfmt_misc fuse drm ip_tables
[  215.216369][ T3608] CPU: 1 PID: 3608 Comm: modprobe Not tainted 6.7.0-rc7-00234-gb42c2f5e8e4d #1
[  215.216637][ T3608] Hardware name:  /DZ77BH-55K, BIOS BHZ7710H.86A.0097.2012.1228.1346 12/28/2012
[ 215.216918][ T3608] RIP: 0010:jump_label_del_module (kernel/jump_label.c:764 (discriminator 1)) 
[ 215.217162][ T3608] Code: 03 75 35 83 e6 03 48 09 f0 4c 89 fe 48 c1 ee 03 80 3c 2e 00 0f 85 cf 01 00 00 49 89 45 08 e9 bf fe ff ff 0f 0b e9 6b ff ff ff <0f> 0b e9 64 ff ff ff 0f 0b e9 e2 fe ff ff 0f 0b eb c7 0f 0b e9 19
All code
========
   0:	03 75 35             	add    0x35(%rbp),%esi
   3:	83 e6 03             	and    $0x3,%esi
   6:	48 09 f0             	or     %rsi,%rax
   9:	4c 89 fe             	mov    %r15,%rsi
   c:	48 c1 ee 03          	shr    $0x3,%rsi
  10:	80 3c 2e 00          	cmpb   $0x0,(%rsi,%rbp,1)
  14:	0f 85 cf 01 00 00    	jne    0x1e9
  1a:	49 89 45 08          	mov    %rax,0x8(%r13)
  1e:	e9 bf fe ff ff       	jmpq   0xfffffffffffffee2
  23:	0f 0b                	ud2    
  25:	e9 6b ff ff ff       	jmpq   0xffffffffffffff95
  2a:*	0f 0b                	ud2    		<-- trapping instruction
  2c:	e9 64 ff ff ff       	jmpq   0xffffffffffffff95
  31:	0f 0b                	ud2    
  33:	e9 e2 fe ff ff       	jmpq   0xffffffffffffff1a
  38:	0f 0b                	ud2    
  3a:	eb c7                	jmp    0x3
  3c:	0f 0b                	ud2    
  3e:	e9                   	.byte 0xe9
  3f:	19                   	.byte 0x19

Code starting with the faulting instruction
===========================================
   0:	0f 0b                	ud2    
   2:	e9 64 ff ff ff       	jmpq   0xffffffffffffff6b
   7:	0f 0b                	ud2    
   9:	e9 e2 fe ff ff       	jmpq   0xfffffffffffffef0
   e:	0f 0b                	ud2    
  10:	eb c7                	jmp    0xffffffffffffffd9
  12:	0f 0b                	ud2    
  14:	e9                   	.byte 0xe9
  15:	19                   	.byte 0x19
[  215.217593][ T3608] RSP: 0018:ffffc9000159fd38 EFLAGS: 00010297
[  215.217877][ T3608] RAX: 1ffffffff089982f RBX: 0000000000000000 RCX: ffffffffc14dc060
[  215.218140][ T3608] RDX: ffffffffc1c6b580 RSI: 0000000000000002 RDI: ffffffffc14dc000
[  215.218409][ T3608] RBP: dffffc0000000000 R08: ffffffffc1c6b8b8 R09: fffff520002b3fa6
[  215.218636][ T3608] R10: ffffc9000159fd37 R11: 0000000000000001 R12: ffffffff844cc178
[  215.218935][ T3608] R13: ffffffff844cc170 R14: ffffffffc14dc008 R15: ffffffff844cc178
[  215.219166][ T3608] FS:  00007f5e44068580(0000) GS:ffff888348080000(0000) knlGS:0000000000000000
[  215.219459][ T3608] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[  215.219717][ T3608] CR2: 00007fceb9a28008 CR3: 00000001a718e005 CR4: 00000000001706f0
[  215.219956][ T3608] Call Trace:
[  215.220126][ T3608]  <TASK>
[ 215.220307][ T3608] ? __warn (kernel/panic.c:677) 
[ 215.220503][ T3608] ? jump_label_del_module (kernel/jump_label.c:764 (discriminator 1)) 
[ 215.220745][ T3608] ? report_bug (lib/bug.c:180 lib/bug.c:219) 
[ 215.220961][ T3608] ? handle_bug (arch/x86/kernel/traps.c:237) 
[ 215.221126][ T3608] ? exc_invalid_op (arch/x86/kernel/traps.c:258 (discriminator 1)) 
[ 215.221288][ T3608] ? asm_exc_invalid_op (arch/x86/include/asm/idtentry.h:568) 
[ 215.221543][ T3608] ? jump_label_del_module (kernel/jump_label.c:764 (discriminator 1)) 
[ 215.221835][ T3608] ? jump_label_add_module (kernel/jump_label.c:787) 
[ 215.222061][ T3608] jump_label_module_notify (kernel/jump_label.c:32 kernel/jump_label.c:807) 
[ 215.222255][ T3608] notifier_call_chain (kernel/notifier.c:95) 
[ 215.222433][ T3608] ? mutex_unlock (arch/x86/include/asm/atomic64_64.h:109 include/linux/atomic/atomic-arch-fallback.h:4308 include/linux/atomic/atomic-long.h:1499 include/linux/atomic/atomic-instrumented.h:4446 kernel/locking/mutex.c:181 kernel/locking/mutex.c:540) 
[ 215.222603][ T3608] blocking_notifier_call_chain (kernel/notifier.c:389 kernel/notifier.c:376) 
[ 215.222845][ T3608] __do_sys_delete_module+0x32a/0x540 
[ 215.223066][ T3608] ? module_flags (kernel/module/main.c:698) 
[ 215.223239][ T3608] ? __x64_sys_close (fs/open.c:1590 fs/open.c:1572 fs/open.c:1572) 
[ 215.223526][ T3608] ? kmem_cache_free (mm/slub.c:1826 mm/slub.c:3809 mm/slub.c:3831) 
[ 215.223772][ T3608] do_syscall_64 (arch/x86/entry/common.c:52 arch/x86/entry/common.c:83) 
[ 215.224010][ T3608] entry_SYSCALL_64_after_hwframe (arch/x86/entry/entry_64.S:129) 
[  215.224246][ T3608] RIP: 0033:0x7f5e44177847
[ 215.224423][ T3608] Code: 73 01 c3 48 8b 0d b9 85 0c 00 f7 d8 64 89 01 48 83 c8 ff c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 44 00 00 b8 b0 00 00 00 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 8b 0d 89 85 0c 00 f7 d8 64 89 01 48
All code
========
   0:	73 01                	jae    0x3
   2:	c3                   	retq   
   3:	48 8b 0d b9 85 0c 00 	mov    0xc85b9(%rip),%rcx        # 0xc85c3
   a:	f7 d8                	neg    %eax
   c:	64 89 01             	mov    %eax,%fs:(%rcx)
   f:	48 83 c8 ff          	or     $0xffffffffffffffff,%rax
  13:	c3                   	retq   
  14:	66 2e 0f 1f 84 00 00 	nopw   %cs:0x0(%rax,%rax,1)
  1b:	00 00 00 
  1e:	0f 1f 44 00 00       	nopl   0x0(%rax,%rax,1)
  23:	b8 b0 00 00 00       	mov    $0xb0,%eax
  28:	0f 05                	syscall 
  2a:*	48 3d 01 f0 ff ff    	cmp    $0xfffffffffffff001,%rax		<-- trapping instruction
  30:	73 01                	jae    0x33
  32:	c3                   	retq   
  33:	48 8b 0d 89 85 0c 00 	mov    0xc8589(%rip),%rcx        # 0xc85c3
  3a:	f7 d8                	neg    %eax
  3c:	64 89 01             	mov    %eax,%fs:(%rcx)
  3f:	48                   	rex.W

Code starting with the faulting instruction
===========================================
   0:	48 3d 01 f0 ff ff    	cmp    $0xfffffffffffff001,%rax
   6:	73 01                	jae    0x9
   8:	c3                   	retq   
   9:	48 8b 0d 89 85 0c 00 	mov    0xc8589(%rip),%rcx        # 0xc8599
  10:	f7 d8                	neg    %eax
  12:	64 89 01             	mov    %eax,%fs:(%rcx)
  15:	48                   	rex.W
[  215.224940][ T3608] RSP: 002b:00007ffedaff1e88 EFLAGS: 00000206 ORIG_RAX: 00000000000000b0
[  215.225209][ T3608] RAX: ffffffffffffffda RBX: 0000562acd24d150 RCX: 00007f5e44177847
[  215.225467][ T3608] RDX: 0000000000000000 RSI: 0000000000000800 RDI: 0000562acd24d1b8
[  215.225754][ T3608] RBP: 0000000000000000 R08: 1999999999999999 R09: 0000000000000000
[  215.226033][ T3608] R10: 00007f5e441eaac0 R11: 0000000000000206 R12: 0000000000000000
[  215.226303][ T3608] R13: 0000000000000000 R14: 00007ffedaff1ec0 R15: 00007ffedaff3378
[  215.226579][ T3608]  </TASK>
[  215.226794][ T3608] ---[ end trace 0000000000000000 ]---


The kernel config and materials to reproduce are available at:
https://download.01.org/0day-ci/archive/20240219/202402191313.3276317d-oliver.sang@intel.com
diff mbox series

Patch

diff --git a/kernel/context_tracking.c b/kernel/context_tracking.c
index 6ef0b35fc28c5..cc4f3a57f848c 100644
--- a/kernel/context_tracking.c
+++ b/kernel/context_tracking.c
@@ -432,7 +432,7 @@  static __always_inline void ct_kernel_enter(bool user, int offset) { }
 #define CREATE_TRACE_POINTS
 #include <trace/events/context_tracking.h>
 
-DEFINE_STATIC_KEY_FALSE(context_tracking_key);
+DEFINE_STATIC_KEY_FALSE_RO(context_tracking_key);
 EXPORT_SYMBOL_GPL(context_tracking_key);
 
 static noinstr bool context_tracking_recursion_enter(void)