Acknowledged
Created: Jul 16, 2024
Updated: Sep 12, 2024
Found In Version: 10.24.33.1
Severity: Standard
Applicable for: Wind River Linux LTS 24
Component/s: Kernel
setup.sh --machines intel-x86-64 --templates feature/docker feature/bcc feature/bpf feature/bpftrace --distros wrlinux --dl-layers=1 --accept-eula=yes
source environment-setup-x86_64-wrlinuxsdk-linux
source oe-init-build-env build
bitbake wrlinux-image-std
build the following code as the kernel module named as kprobe_exam. For how to build out-of-tree please refer to https://docs.yoctoproject.org/kernel-dev/common.html#working-with-out-of-tree-modules
/* kprobe-exam_1.c for debug ip_rcv */
#include<linux/module.h>
#include<linux/version.h>
#include<linux/kernel.h>
#include<linux/init.h>
#include<linux/kprobes.h>
static unsigned long (*kallsyms_lookup_name_sym)(const char *name);
static int dummy_kprobe_handler(struct kprobe *p, struct pt_regs *regs)
{
return 0;
}
static unsigned long do_get_kallsyms(void)
{
struct kprobe probe;
int ret;
unsigned long addr;
memset(&probe, 0, sizeof(probe));
probe.pre_handler = dummy_kprobe_handler;
probe.symbol_name = "kallsyms_lookup_name";
ret = register_kprobe(&probe);
if (ret)
return 0;
addr = (unsigned long)probe.addr;
#ifdef CONFIG_ARM
#ifdef CONFIG_THUMB2_KERNEL
if (addr)
addr |= 1; /* set bit 0 in address for thumb mode */
#endif
#endif
unregister_kprobe(&probe);
return addr;
}
unsigned long wrapper_kallsyms_lookup_name(const char *name)
{
if (!kallsyms_lookup_name_sym) {
kallsyms_lookup_name_sym = (void *)do_get_kallsyms();
}
if (kallsyms_lookup_name_sym)
return kallsyms_lookup_name_sym(name);
else {
printk_once(KERN_WARNING "requires kallsyms_lookup_name\n");
return 0;
}
}
static unsigned int counter = 0;
int Pre_Handler(struct kprobe *p, struct pt_regs *regs){
printk("Pre_Handler: counter=%u\n",counter++);
return 0;
}
void Post_Handler(struct kprobe *p, struct pt_regs *regs, unsigned long flags){
printk("Post_Handler: counter=%u\n",counter++);
}
static struct kprobe kp;
int myinit(void)
{
printk("module inserted\n");
kp.pre_handler = Pre_Handler;
kp.post_handler = Post_Handler;
kp.addr = (kprobe_opcode_t *) wrapper_kallsyms_lookup_name("ip_rcv");
register_kprobe(&kp);
return 0;
}
void myexit(void)
{
unregister_kprobe(&kp);
printk("module removed\n");
}
module_init(myinit);
module_exit(myexit);
MODULE_AUTHOR("Manoj");
MODULE_DESCRIPTION("KPROBE MODULE");
MODULE_LICENSE("GPL");
root@intel-x86-64: # modprobe kprobe_exam
Segmentation fault modprobe kprobe_exam
root@intel-x86-64: # dmesg |grep -i -w -E -B10 -A50 'Call Trace|BUG:|WARNING:' ||return 0
[ 915.434319] RSP: 0018:ffffc90001f2ba90 EFLAGS: 00010002
[ 915.434324] RAX: 0000000000000031 RBX: ffffc90001f2bab8 RCX: 0000000000000000
[ 915.434327] RDX: 0000000000000000 RSI: ffffffff85b50e60 RDI: ffffffff85b50e60
[ 915.434329] RBP: ffffc90001f2baa8 R08: 0000000000000003 R09: ffffffff88284e40
[ 915.434331] R10: 0000000000000001 R11: ffffffff88284e40 R12: 0000000000000003
[ 915.434333] R13: 0000000000000000 R14: 0000000000000000 R15: 0000000000000000
[ 915.434335] FS: 00007f0e84053600(0000) GS:ffff88849ec00000(0000) knlGS:0000000000000000
[ 915.434337] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[ 915.434340] CR2: 00007f0e841ce445 CR3: 00000001285e2001 CR4: 0000000000f70ee0
[ 915.434342] PKRU: 55555554
[ 915.434344] Call Trace:
[ 915.434345] <TASK>
[ 915.434348] ? show_regs+0x69/0x80
[ 915.434354] ? die+0x3b/0x90
[ 915.434359] ? do_trap+0xc8/0xe0
[ 915.434364] ? do_error_trap+0x7a/0x110
[ 915.434383] ? exc_control_protection+0x176/0x180
[ 915.434387] ? exc_invalid_op+0x56/0x70
[ 915.434392] ? exc_control_protection+0x176/0x180
[ 915.434396] ? asm_exc_invalid_op+0x1f/0x30
[ 915.434405] ? __wake_up_klogd.part.0+0x50/0x80
[ 915.434411] ? __wake_up_klogd.part.0+0x50/0x80
[ 915.434416] ? exc_control_protection+0x176/0x180
[ 915.434421] asm_exc_control_protection+0x2b/0x60
[ 915.434427] RIP: 0010:init_module+0x0/0xa0 [kprobe_exam]
[ 915.434435] Code: 71 b8 c0 c6 05 18 1e 00 00 01 e8 3b 17 5e c5 31 c0 eb e3 0f 1f 80 00 00 00 00 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 <66> 0f 1f 00 0f 1f 44 00 00 55 48 c7 c7 4d 70 b8 c0 48 c7 05 a4 23
[ 915.434437] RSP: 0018:ffffc90001f2bb68 EFLAGS: 00010202
[ 915.434440] RAX: 0000000000000001 RBX: 0000000000000000 RCX: 0000000000000000
[ 915.434442] RDX: 0000000000000000 RSI: 0000000000000000 RDI: ffffc90001f2bb50
[ 915.434444] RBP: ffffc90001f2bbd8 R08: 0000000000000002 R09: 0000000000000006
[ 915.434446] R10: ffffc90001f2b8b6 R11: 0000000000000001 R12: ffffffffc056f240
[ 915.434448] R13: ffffc90001f2bcf0 R14: ffffc90001f2bb70 R15: 0000000007db0da0
[ 915.434451] ? __pfx_init_module+0x10/0x10 [kprobe_exam]
[ 915.434463] ? do_one_initcall+0x7e/0x2b0
[ 915.434471] do_init_module+0x68/0x240
[ 915.434477] load_module+0x1ebd/0x1fd0
[ 915.434480] ? nfs_file_read+0x54/0xb0
[ 915.434495] init_module_from_file+0x97/0xd0
[ 915.434499] ? init_module_from_file+0x97/0xd0
[ 915.434506] idempotent_init_module+0x140/0x2e0
[ 915.434514] __x64_sys_finit_module+0x5c/0x90
[ 915.434518] x64_sys_call+0x429/0x1c90
[ 915.434523] do_syscall_64+0x41/0x90
[ 915.434528] entry_SYSCALL_64_after_hwframe+0x78/0xe2
[ 915.434533] RIP: 0033:0x7f0e841561cd
[ 915.434537] Code: ff 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 1b 2c 0d 00 f7 d8 64 89 01 48
[ 915.434539] RSP: 002b:00007fffe871f958 EFLAGS: 00000246 ORIG_RAX: 0000000000000139
[ 915.434543] RAX: ffffffffffffffda RBX: 0000564e2b2a6990 RCX: 00007f0e841561cd
[ 915.434545] RDX: 0000000000000000 RSI: 0000564e2b29a979 RDI: 0000000000000003
[ 915.434547] RBP: 0000000000000000 R08: 00007f0e84229b20 R09: 0000564e2b2a6990
[ 915.434549] R10: 0000000000000050 R11: 0000000000000246 R12: 0000564e2b29a979
[ 915.434551] R13: 0000000000040000 R14: 0000000000000000 R15: 0000000000000000
[ 915.434557] </TASK>
[ 915.434559] Modules linked in: kprobe_exam(O+) rfcomm 8021q algif_hash algif_skcipher af_alg bnep snd_hda_codec_hdmi iwlmvm x86_pkg_temp_thermal intel_powerclamp coretemp mac80211 kvm_intel crct10dif_pclmul snd_hda_intel crct10dif_common sha512_ssse3 snd_intel_dspcfg processor_thermal_device_pci_legacy sha256_ssse3 processor_thermal_device sha1_ssse3 snd_hda_codec processor_thermal_rfim btusb spi_nor intel_rapl_msr wmi_bmof iwlwifi aesni_intel snd_hda_core processor_thermal_mbox i915 snd_pcm wdat_wdt btrtl crypto_simd processor_thermal_rapl cryptd watchdog drm_buddy spi_intel_pci snd_timer i2c_i801 btintel ttm cfg80211 btbcm intel_rapl_common i2c_smbus spi_intel idma64 video int340x_thermal_zone drm_display_helper intel_soc_dts_iosf thunderbolt igen6_edac thermal wmi battery fan int3400_thermal backlight acpi_thermal_rel ac acpi_pad input_leds led_class sch_fq_codel tipc ip6_udp_tunnel udp_tunnel openvswitch nsh nf_conncount nf_nat kvm irqbypass fuse configfs nfnetlink dmi_sysfs [last unloaded: kprobe_example]
[ 915.434650] ---[ end trace 0000000000000000 ]---
[ 915.445914] pstore: backend (efi_pstore) writing error (-5)
[ 915.445916] RIP: 0010:exc_control_protection+0x176/0x180
[ 915.445918] Code: 89 e6 c6 05 0a 7b 3c 02 01 48 c7 c2 20 cc 20 87 81 e6 ff 7f 00 00 83 fe 05 77 ca eb bc 48 c7 43 50 00 00 00 00 e9 35 ff ff ff <0f> 0b 0f 1f 84 00 00 00 00 00 90 90 90 90 90 90 90 90 90 90 90 90
[ 915.445919] RSP: 0018:ffffc90001f2ba90 EFLAGS: 00010002
[ 915.445921] RAX: 0000000000000031 RBX: ffffc90001f2bab8 RCX: 0000000000000000
[ 915.445922] RDX: 0000000000000000 RSI: ffffffff85b50e60 RDI: ffffffff85b50e60
--
[ 953.928023] RSP: 0018:ffffc90002397a70 EFLAGS: 00010002
[ 953.928025] RAX: 000000000000002c RBX: ffffc90002397a98 RCX: 0000000000000000
[ 953.928026] RDX: 0000000000000000 RSI: ffffffff85b50e60 RDI: ffffffff85b50e60
[ 953.928027] RBP: ffffc90002397a88 R08: 0000000000000003 R09: ffffffff88284e40
[ 953.928028] R10: 0000000000000001 R11: ffffffff88284e40 R12: 0000000000000003
[ 953.928029] R13: 0000000000000000 R14: 0000000000000000 R15: 0000000000000000
[ 953.928030] FS: 00007f662da53600(0000) GS:ffff88849e400000(0000) knlGS:0000000000000000
[ 953.928031] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[ 953.928032] CR2: 00007f662dbce445 CR3: 000000010e26e006 CR4: 0000000000f70ee0
[ 953.928033] PKRU: 55555554
[ 953.928034] Call Trace:
[ 953.928034] <TASK>
[ 953.928035] ? show_regs+0x69/0x80
[ 953.928039] ? die+0x3b/0x90
[ 953.928041] ? do_trap+0xc8/0xe0
[ 953.928043] ? do_error_trap+0x7a/0x110
[ 953.928045] ? exc_control_protection+0x176/0x180
[ 953.928047] ? exc_invalid_op+0x56/0x70
[ 953.928049] ? exc_control_protection+0x176/0x180
[ 953.928051] ? asm_exc_invalid_op+0x1f/0x30
[ 953.928055] ? __wake_up_klogd.part.0+0x50/0x80
[ 953.928058] ? __wake_up_klogd.part.0+0x50/0x80
[ 953.928061] ? exc_control_protection+0x176/0x180
[ 953.928063] asm_exc_control_protection+0x2b/0x60
[ 953.928065] RIP: 0010:kallsyms_lookup_name+0x4/0xb0
[ 953.928068] Code: 79 0a 48 f7 d0 48 03 05 6a e2 b8 01 5d c3 cc cc cc cc 0f 1f 40 00 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 66 0f 1f 00 <0f> 1f 44 00 00 55 48 89 e5 53 48 83 ec 10 65 48 8b 04 25 28 00 00
[ 953.928069] RSP: 0018:ffffc90002397b40 EFLAGS: 00010282
[ 953.928070] RAX: ffffffff85bc4b04 RBX: 0000000000000000 RCX: 0000000000000000
[ 953.928071] RDX: ffffc90002397aa0 RSI: ffffffff86ec7faa RDI: ffffffffc0b910a1
[ 953.928072] RBP: ffffc90002397b50 R08: 0000000000000000 R09: 0000000000000000
[ 953.928072] R10: 0000000000000000 R11: 0000000000007cc2 R12: ffffffffc0b8b220
[ 953.928073] R13: ffffc90002397cf0 R14: ffffc90002397b70 R15: 000000000f83e348
[ 953.928075] ? __pfx_init_module+0x10/0x10 [kprobe_exam_1]
[ 953.928079] ? kallsyms_lookup_name+0x4/0xb0
[ 953.928082] ? __wait_for_common+0x1aa/0x1e0
[ 953.928086] ? wrapper_kallsyms_lookup_name+0x1f/0x70 [kprobe_exam_1]
[ 953.928090] myinit+0x3b/0xde0 [kprobe_exam_1]
[ 953.928093] do_one_initcall+0x7e/0x2b0
[ 953.928097] do_init_module+0x68/0x240
[ 953.928099] load_module+0x1ebd/0x1fd0
[ 953.928101] ? nfs_file_read+0x54/0xb0
[ 953.928108] init_module_from_file+0x97/0xd0
[ 953.928110] ? init_module_from_file+0x97/0xd0
[ 953.928113] idempotent_init_module+0x140/0x2e0
[ 953.928116] __x64_sys_finit_module+0x5c/0x90
[ 953.928118] x64_sys_call+0x429/0x1c90
[ 953.928120] do_syscall_64+0x41/0x90
[ 953.928122] entry_SYSCALL_64_after_hwframe+0x78/0xe2
[ 953.928125] RIP: 0033:0x7f662db561cd
[ 953.928126] Code: ff 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 1b 2c 0d 00 f7 d8 64 89 01 48
[ 953.928127] RSP: 002b:00007ffd9092e2c8 EFLAGS: 00000246 ORIG_RAX: 0000000000000139
[ 953.928129] RAX: ffffffffffffffda RBX: 000055cf6af79990 RCX: 00007f662db561cd
[ 953.928130] RDX: 0000000000000000 RSI: 000055cf6af6d979 RDI: 0000000000000003
[ 953.928131] RBP: 0000000000000000 R08: 00007f662dc29b20 R09: 000055cf6af79990
[ 953.928131] R10: 0000000000000050 R11: 0000000000000246 R12: 000055cf6af6d979
[ 953.928132] R13: 0000000000040000 R14: 0000000000000000 R15: 0000000000000000
[ 953.928135] </TASK>
[ 953.928135] Modules linked in: kprobe_exam_1(O+) kprobe_exam(O+) rfcomm 8021q algif_hash algif_skcipher af_alg bnep snd_hda_codec_hdmi iwlmvm x86_pkg_temp_thermal intel_powerclamp coretemp mac80211 kvm_intel crct10dif_pclmul snd_hda_intel crct10dif_common sha512_ssse3 snd_intel_dspcfg processor_thermal_device_pci_legacy sha256_ssse3 processor_thermal_device sha1_ssse3 snd_hda_codec processor_thermal_rfim btusb spi_nor intel_rapl_msr wmi_bmof iwlwifi aesni_intel snd_hda_core processor_thermal_mbox i915 snd_pcm wdat_wdt btrtl crypto_simd processor_thermal_rapl cryptd watchdog drm_buddy spi_intel_pci snd_timer i2c_i801 btintel ttm cfg80211 btbcm intel_rapl_common i2c_smbus spi_intel idma64 video int340x_thermal_zone drm_display_helper intel_soc_dts_iosf thunderbolt igen6_edac thermal wmi battery fan int3400_thermal backlight acpi_thermal_rel ac acpi_pad input_leds led_class sch_fq_codel tipc ip6_udp_tunnel udp_tunnel openvswitch nsh nf_conncount nf_nat kvm irqbypass fuse configfs nfnetlink dmi_sysfs
[ 953.928178] [last unloaded: kprobe_example]
[ 953.928180] ---[ end trace 0000000000000000 ]---
[ 953.938558] RIP: 0010:exc_control_protection+0x176/0x180
This is due to upstream enabling Intel feature IBT by default. https://www.phoronix.com/news/Linux-IBT-By-Default-Tip
Adding ibt=off to kernel parameters would relieve this issue.
It seems that IBT is still on the way to be stable on mainline, e.g. https://lore.kernel.org/all/20240723063258.2240610-4-zhengyejian@huaweicloud.com/
We don't add anything WR specific into this area. And this is a security-vs-debug issue, i.e. normally these two options shouldn't be enabled at the same time. Let's wait until it gets stable upstream and then it'll probably be back-ported automatically.
/lpg-build/cdc/fast_prod/WRL10_24/WRL10_24_GIT/wrlinux-10/setup.sh --machines intel-x86-64 --templates feature/docker feature/bcc feature/bpf feature/bpftrace --distros wrlinux --dl-layers=1 --accept-eula=yes
source environment-setup-x86_64-wrlinuxsdk-linux
source oe-init-build-env build
echo 'BB_NUMBER_THREADS ?= "24"' >> conf/local.conf
echo 'PARALLEL_MAKE ?= "-j 24"' >> conf/local.conf
bitbake-layers add-layer /lpg-build/cdc/WASSP_LINUX_1024/testcases/wrlinux/wr-testing/kts-dev
cd /lpg-build/cdc/WASSP_LINUX_1024/testcases/wrlinux/wr-testing/kts-dev/tools && ./gen_kernel_plan.py -s wr-kts -b intel-x86-64 -k standard -a x86-64 -p $BUILDDIR ; cd - && cp standard_wr-kts.ini test_plan.list
echo 'IMAGE_FSTYPES += "tar.bz2"' >> conf/local.conf
echo 'IMAGE_FSTYPES:remove = " live hddimg iso"' >> conf/local.conf
echo 'require templates/feature/wr-kts/template.conf' >> conf/local.conf
bitbake wrlinux-image-std