From: kernel test robot <lkp@intel.com>
To: "Vladimir Kondratiev" <vladimir.kondratiev@mobileye.com>,
"Paul Walmsley" <pjw@kernel.org>,
"Palmer Dabbelt" <palmer@dabbelt.com>,
"Albert Ou" <aou@eecs.berkeley.edu>,
"Alexandre Ghiti" <alex@ghiti.fr>,
"Masami Hiramatsu" <mhiramat@kernel.org>,
"Oleg Nesterov" <oleg@redhat.com>,
"Peter Zijlstra" <peterz@infradead.org>,
"Guo Ren" <guoren@kernel.org>,
"Pekka Enberg" <penberg@kernel.org>,
"Patrick Stählin" <me@packi.ch>
Cc: oe-kbuild-all@lists.linux.dev, linux-riscv@lists.infradead.org,
linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org,
Vladimir Kondratiev <vladimir.kondratiev@mobileye.com>
Subject: Re: [PATCH v4 2/3] riscv: probes: reject probes inside an LR/SC sequence
Date: Mon, 16 Nov 2026 04:12:52 +0800 [thread overview]
Message-ID: <202611160417.wVX1is4j-lkp@intel.com> (raw)
In-Reply-To: <20261115-probes-in-lrsc-v4-2-48b9b036bd1d@mobileye.com>
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@intel.com/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@intel.com/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@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202611160417.wVX1is4j-lkp@intel.com/
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
WARNING: multiple messages have this Message-ID (diff)
From: kernel test robot <lkp@intel.com>
To: "Vladimir Kondratiev" <vladimir.kondratiev@mobileye.com>,
"Paul Walmsley" <pjw@kernel.org>,
"Palmer Dabbelt" <palmer@dabbelt.com>,
"Albert Ou" <aou@eecs.berkeley.edu>,
"Alexandre Ghiti" <alex@ghiti.fr>,
"Masami Hiramatsu" <mhiramat@kernel.org>,
"Oleg Nesterov" <oleg@redhat.com>,
"Peter Zijlstra" <peterz@infradead.org>,
"Guo Ren" <guoren@kernel.org>,
"Pekka Enberg" <penberg@kernel.org>,
"Patrick Stählin" <me@packi.ch>
Cc: oe-kbuild-all@lists.linux.dev, linux-riscv@lists.infradead.org,
linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org,
Vladimir Kondratiev <vladimir.kondratiev@mobileye.com>
Subject: Re: [PATCH v4 2/3] riscv: probes: reject probes inside an LR/SC sequence
Date: Mon, 16 Nov 2026 04:12:52 +0800 [thread overview]
Message-ID: <202611160417.wVX1is4j-lkp@intel.com> (raw)
In-Reply-To: <20261115-probes-in-lrsc-v4-2-48b9b036bd1d@mobileye.com>
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@intel.com/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@intel.com/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@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202611160417.wVX1is4j-lkp@intel.com/
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
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
next prev parent reply other threads:[~2026-11-15 20:13 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-15 12:37 [PATCH v4 0/3] riscv: probes: reject probes inside an LR/SC sequence Vladimir Kondratiev
2026-11-15 12:37 ` Vladimir Kondratiev
2026-11-15 12:37 ` [PATCH v4 1/3] riscv: kprobes: fix out-of-bounds read in riscv_probe_decode_insn Vladimir Kondratiev
2026-11-15 12:37 ` Vladimir Kondratiev
2026-11-15 12:37 ` [PATCH v4 2/3] riscv: probes: reject probes inside an LR/SC sequence Vladimir Kondratiev
2026-11-15 12:37 ` Vladimir Kondratiev
2026-11-15 13:01 ` sashiko-bot
2026-11-15 18:37 ` kernel test robot
2026-11-15 18:37 ` kernel test robot
2026-11-15 20:12 ` kernel test robot [this message]
2026-11-15 20:12 ` kernel test robot
2026-11-15 12:37 ` [PATCH v4 3/3] riscv: kprobes: add KUnit test for LR/SC sequence rejection Vladimir Kondratiev
2026-11-15 12:37 ` Vladimir Kondratiev
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=202611160417.wVX1is4j-lkp@intel.com \
--to=lkp@intel.com \
--cc=alex@ghiti.fr \
--cc=aou@eecs.berkeley.edu \
--cc=guoren@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-riscv@lists.infradead.org \
--cc=linux-trace-kernel@vger.kernel.org \
--cc=me@packi.ch \
--cc=mhiramat@kernel.org \
--cc=oe-kbuild-all@lists.linux.dev \
--cc=oleg@redhat.com \
--cc=palmer@dabbelt.com \
--cc=penberg@kernel.org \
--cc=peterz@infradead.org \
--cc=pjw@kernel.org \
--cc=vladimir.kondratiev@mobileye.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.