linux-stable/arch/riscv/kernel
Björn Töpel 1ce70a9ef9 riscv, kprobes: Stricter c.jr/c.jalr decoding
commit b2d473a601 upstream.

In the compressed instruction extension, c.jr, c.jalr, c.mv, and c.add
is encoded the following way (each instruction is 16b):

---+-+-----------+-----------+--
100 0 rs1[4:0]!=0       00000 10 : c.jr
100 1 rs1[4:0]!=0       00000 10 : c.jalr
100 0  rd[4:0]!=0 rs2[4:0]!=0 10 : c.mv
100 1  rd[4:0]!=0 rs2[4:0]!=0 10 : c.add

The following logic is used to decode c.jr and c.jalr:

  insn & 0xf007 == 0x8002 => instruction is an c.jr
  insn & 0xf007 == 0x9002 => instruction is an c.jalr

When 0xf007 is used to mask the instruction, c.mv can be incorrectly
decoded as c.jr, and c.add as c.jalr.

Correct the decoding by changing the mask from 0xf007 to 0xf07f.

Fixes: c22b0bcb1d ("riscv: Add kprobes supported")
Signed-off-by: Björn Töpel <bjorn@rivosinc.com>
Reviewed-by: Conor Dooley <conor.dooley@microchip.com>
Reviewed-by: Guo Ren <guoren@kernel.org>
Link: https://lore.kernel.org/r/20230102160748.1307289-1-bjorn@kernel.org
Cc: stable@vger.kernel.org
Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2023-01-12 12:00:47 +01:00
..
compat_vdso
probes riscv, kprobes: Stricter c.jr/c.jalr decoding 2023-01-12 12:00:47 +01:00
vdso riscv: vdso: fix section overlapping under some conditions 2022-12-08 11:30:18 +01:00
.gitignore
alternative.c
asm-offsets.c
cacheinfo.c
compat_signal.c
compat_syscall_table.c
cpu-hotplug.c
cpu.c
cpu_ops.c
cpu_ops_sbi.c
cpu_ops_spinwait.c
cpufeature.c
crash_dump.c
crash_save_regs.S
efi-header.S
efi.c
elf_kexec.c RISC-V: kexec: Fix memory leak of elf header buffer 2023-01-07 11:15:57 +01:00
entry.S RISC-V: Fix unannoted hardirqs-on in return to userspace slow-path 2022-12-31 13:26:23 +01:00
fpu.S
ftrace.c
head.h
head.S
image-vars.h
irq.c
jump_label.c
kexec_relocate.S
kgdb.c
machine_kexec.c riscv: kexec: Fixup irq controller broken in kexec crash path 2022-12-08 11:30:21 +01:00
machine_kexec_file.c
Makefile
mcount-dyn.S
mcount.S
module-sections.c
module.c
patch.c
perf_callchain.c
perf_regs.c
process.c
ptrace.c
reset.c
riscv_ksyms.c
sbi.c
setup.c riscv: mm: Proper page permissions after initmem free 2022-12-08 11:30:18 +01:00
signal.c RISC-V: Fix unannoted hardirqs-on in return to userspace slow-path 2022-12-31 13:26:23 +01:00
smp.c
smpboot.c
soc.c
stacktrace.c riscv: stacktrace: Fixup ftrace_graph_ret_addr retp argument 2023-01-07 11:15:57 +01:00
suspend.c
suspend_entry.S
sys_riscv.c
syscall_table.c
time.c
trace_irq.c
trace_irq.h
traps.c RISC-V: Align the shadow stack 2022-12-31 13:26:23 +01:00
traps_misaligned.c
vdso.c
vmlinux-xip.lds.S
vmlinux.lds.S