public inbox for stable@vger.kernel.org
 help / color / mirror / Atom feed
* [linux-6.6.y bugreport] riscv: kprobe crash as some patchs lost
@ 2025-04-22  2:58 Kai Zhang
  2025-04-22  8:46 ` Greg Kroah-Hartman
  0 siblings, 1 reply; 11+ messages in thread
From: Kai Zhang @ 2025-04-22  2:58 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Paul Walmsley, Palmer Dabbelt, Albert Ou; +Cc: stable

In most recent linux-6.6.y tree, 
`arch/riscv/kernel/probes/kprobes.c::arch_prepare_ss_slot` still has the 
obsolete code:

     u32 insn = __BUG_INSN_32;
     unsigned long offset = GET_INSN_LENGTH(p->opcode);
     p->ainsn.api.restore = (unsigned long)p->addr + offset;
     patch_text_nosync(p->ainsn.api.insn, &p->opcode, 1);
     patch_text_nosync((void *)p->ainsn.api.insn + offset, &insn, 1);

The last two 1s are wrong size of written instructions , which would 
lead to kernel crash, like `insmod kprobe_example.ko` gives:

[  509.812815][ T2734] kprobe_init: Planted kprobe at 00000000c5c46130
[  509.837606][    C5] handler_pre: <kernel_clone> p->addr = 
0x00000000c5c46130, pc = 0xffffffff80032ee2, status = 0x200000120
[  509.839315][    C5] Oops - illegal instruction [#1]


I've tried two patchs from torvalds tree and it didn't crash again:

51781ce8f448 riscv: Pass patch_text() the length in bytes (rebased)
13134cc94914 riscv: kprobes: Fix incorrect address calculation

Regards,
laokz



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

end of thread, other threads:[~2025-04-28 12:10 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-04-22  2:58 [linux-6.6.y bugreport] riscv: kprobe crash as some patchs lost Kai Zhang
2025-04-22  8:46 ` Greg Kroah-Hartman
2025-04-25  8:03   ` Kai Zhang
2025-04-25  8:07     ` Greg Kroah-Hartman
2025-04-25 12:09       ` Kai Zhang
2025-04-25 12:49         ` Nam Cao
2025-04-25 12:59           ` Nam Cao
2025-04-25 15:29             ` Kai Zhang
2025-04-28  7:22               ` Nam Cao
2025-04-28 12:10                 ` Kai Zhang
2025-04-25 14:53           ` Kai Zhang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox