Re: [PATCH v4 2/3] riscv: probes: reject probes inside an LR/SC sequence

From: kernel test robot

Date: Sun Nov 15 2026 - 15:13:57 EST


Hi Vladimir,

kernel test robot noticed the following build warnings:

[auto build test WARNING on c03c1a14507dfaf8b856c2608f9ac216021fc222]

url: https://github.com/intel-lab-lkp/linux/commits/Vladimir-Kondratiev/riscv-kprobes-fix-out-of-bounds-read-in-riscv_probe_decode_insn/20261115-143733
base: c03c1a14507dfaf8b856c2608f9ac216021fc222
patch link: https://lore.kernel.org/r/20261115-probes-in-lrsc-v4-2-48b9b036bd1d%40mobileye.com
patch subject: [PATCH v4 2/3] riscv: probes: reject probes inside an LR/SC sequence
config: riscv-randconfig-1000-20261116 (https://download.01.org/0day-ci/archive/20261116/202611160417.wVX1is4j-lkp@xxxxxxxxx/config)
compiler: riscv64-linux-gcc (GCC) 15.3.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20261116/202611160417.wVX1is4j-lkp@xxxxxxxxx/reproduce)

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 <lkp@xxxxxxxxx>
| Closes: https://lore.kernel.org/oe-kbuild-all/202611160417.wVX1is4j-lkp@xxxxxxxxx/

All warnings (new ones prefixed by >>):

arch/riscv/kernel/probes/kprobes.c: In function 'arch_check_kprobe':
>> arch/riscv/kernel/probes/kprobes.c:72:20: warning: suggest explicit braces to avoid ambiguous 'else' [-Wdangling-else]
72 | if (tmp == addr)
| ^


vim +/else +72 arch/riscv/kernel/probes/kprobes.c

c22b0bcb1dd024 Guo Ren 2020-12-17 51
c0b7e72c7a4b06 Vladimir Kondratiev 2026-11-15 52 /*
c0b7e72c7a4b06 Vladimir Kondratiev 2026-11-15 53 * Walk the instructions from the enclosing symbol up to addr to check that
c0b7e72c7a4b06 Vladimir Kondratiev 2026-11-15 54 * addr is an instruction boundary. Then reject a probe inside an LR/SC
c0b7e72c7a4b06 Vladimir Kondratiev 2026-11-15 55 * sequence: the breakpoint trap drops the reservation, so the SC would fail
c0b7e72c7a4b06 Vladimir Kondratiev 2026-11-15 56 * and the loop would hit the probe again on every retry. The sequence is
c0b7e72c7a4b06 Vladimir Kondratiev 2026-11-15 57 * recognised by a forward scan with the constrained-sequence rules, as for
c0b7e72c7a4b06 Vladimir Kondratiev 2026-11-15 58 * uprobes, so an lr that is not followed by an sc (as in __cmpwait()) does
c0b7e72c7a4b06 Vladimir Kondratiev 2026-11-15 59 * not taint the rest of the function.
c0b7e72c7a4b06 Vladimir Kondratiev 2026-11-15 60 */
c0b7e72c7a4b06 Vladimir Kondratiev 2026-11-15 61 static int __kprobes arch_check_kprobe(unsigned long addr)
87f48c7ccc73af Guo Ren 2023-01-31 62 {
9e68bd803fac49 Fabian Vogt 2025-09-10 63 unsigned long tmp, offset;
9e68bd803fac49 Fabian Vogt 2025-09-10 64
9e68bd803fac49 Fabian Vogt 2025-09-10 65 /* start iterating at the closest preceding symbol */
9e68bd803fac49 Fabian Vogt 2025-09-10 66 if (!kallsyms_lookup_size_offset(addr, NULL, &offset))
c0b7e72c7a4b06 Vladimir Kondratiev 2026-11-15 67 return -EILSEQ;
9e68bd803fac49 Fabian Vogt 2025-09-10 68
9e68bd803fac49 Fabian Vogt 2025-09-10 69 tmp = addr - offset;
87f48c7ccc73af Guo Ren 2023-01-31 70
87f48c7ccc73af Guo Ren 2023-01-31 71 while (tmp <= addr) {
87f48c7ccc73af Guo Ren 2023-01-31 @72 if (tmp == addr)
c0b7e72c7a4b06 Vladimir Kondratiev 2026-11-15 73 if (riscv_probe_in_lrsc_body((u16 *)addr, RISCV_LRSC_SCAN_BYTES))
c0b7e72c7a4b06 Vladimir Kondratiev 2026-11-15 74 return -EINVAL;
c0b7e72c7a4b06 Vladimir Kondratiev 2026-11-15 75 else
c0b7e72c7a4b06 Vladimir Kondratiev 2026-11-15 76 return 0;
87f48c7ccc73af Guo Ren 2023-01-31 77
87f48c7ccc73af Guo Ren 2023-01-31 78 tmp += GET_INSN_LENGTH(*(u16 *)tmp);
87f48c7ccc73af Guo Ren 2023-01-31 79 }
87f48c7ccc73af Guo Ren 2023-01-31 80
c0b7e72c7a4b06 Vladimir Kondratiev 2026-11-15 81 return -EILSEQ;
87f48c7ccc73af Guo Ren 2023-01-31 82 }
87f48c7ccc73af Guo Ren 2023-01-31 83

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