From: sashiko-bot@kernel.org
To: "Jinchao Wang" <wangjinchao600@gmail.com>
Cc: linux-perf-users@vger.kernel.org
Subject: Re: [RFC PATCH 05/13] mm/kwatch: add watch expression parser and dereference engine
Date: Tue, 14 Jul 2026 18:45:51 +0000 [thread overview]
Message-ID: <20260714184551.DC9EE1F00A3A@smtp.kernel.org> (raw)
In-Reply-To: <20260714183107.12463-1-wangjinchao600@gmail.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] kwatch_deref_resolve fails to validate intermediate pointers against the kernel-space boundary, leading to potential kernel panics.
--
--- Patch [5]: [RFC PATCH 05/13] mm/kwatch: add watch expression parser and dereference engine ---
commit 2105aab4719c42ad84e86aced2cb286ed992fb63
Author: Jinchao Wang <wangjinchao600@gmail.com>
mm/kwatch: add watch expression parser and dereference engine
This commit introduces the watch expression parser and dereference engine
for KWatch. It provides functions to parse a textual watch expression into
a configuration and resolve the pointer chain dynamically at probe time.
> diff --git a/mm/kwatch/deref.c b/mm/kwatch/deref.c
> new file mode 100644
> index 0000000000000..a93c76139e7cd
> --- /dev/null
> +++ b/mm/kwatch/deref.c
[ ... ]
> +int kwatch_deref_resolve(const struct kwatch_config *cfg, struct pt_regs *regs,
> + unsigned long *out_addr, u16 *out_len)
> +{
[ ... ]
> + /* 2. The Pointer-Chasing FSM */
> + for (i = 0; i < cfg->offset_count; i++) {
> + addr += cfg->offsets[i];
> +
> + if (i < cfg->offset_count - 1) {
> + unsigned long next_addr;
> +
> + /* Dynamically read the pointer contents at runtime */
> + if (get_kernel_nofault(next_addr, (unsigned long *)addr))
[Severity: High]
Is it safe to read from addr using get_kernel_nofault() before validating
that it falls within the kernel address space?
If a user configures a watch expression where an intermediate pointer
evaluates to a user-space address, reading it via get_kernel_nofault()
might trigger a hardware protection violation (e.g., SMAP or PAN) on
architectures where copy_from_kernel_nofault() does not internally
validate the address boundary.
Should the boundary check be moved inside the pointer-chasing loop prior
to the get_kernel_nofault() call?
> + return -EFAULT;
> +
> + addr = next_addr;
> + }
> + }
> +
> + /* Enforce strict Kernel-Space boundary */
> + if (unlikely(addr < TASK_SIZE_MAX))
> + return -EINVAL;
> +
> + *out_addr = addr;
> + *out_len = cfg->watch_len;
> + return 0;
> +}
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260714182243.10687-1-wangjinchao600@gmail.com?part=5
next prev parent reply other threads:[~2026-07-14 18:45 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-14 18:22 [RFC PATCH 00/13] mm/kwatch: dynamic hardware watchpoints for hunting memory corruption Jinchao Wang
2026-07-14 18:22 ` [RFC PATCH 01/13] arch: add HAVE_REINSTALL_HW_BREAKPOINT Jinchao Wang
2026-07-14 18:22 ` [RFC PATCH 02/13] x86/hw_breakpoint: Unify breakpoint install/uninstall Jinchao Wang
2026-07-14 18:47 ` sashiko-bot
2026-07-14 18:22 ` [RFC PATCH 03/13] x86/hw_breakpoint: Add arch_reinstall_hw_breakpoint Jinchao Wang
2026-07-14 19:22 ` sashiko-bot
2026-07-14 18:30 ` [RFC PATCH 04/13] HWBP: Add modify_wide_hw_breakpoint_local() API Jinchao Wang
2026-07-14 19:41 ` sashiko-bot
2026-07-14 18:31 ` [RFC PATCH 05/13] mm/kwatch: add watch expression parser and dereference engine Jinchao Wang
2026-07-14 18:45 ` sashiko-bot [this message]
2026-07-14 18:31 ` [RFC PATCH 06/13] mm/kwatch: add lockless per-task context pool Jinchao Wang
2026-07-14 18:44 ` sashiko-bot
2026-07-14 18:31 ` [RFC PATCH 07/13] stacktrace: export stack_trace_save_regs() Jinchao Wang
2026-07-14 18:42 ` sashiko-bot
2026-07-14 18:32 ` [RFC PATCH 08/13] mm/kwatch: add hardware breakpoint backend Jinchao Wang
2026-07-14 18:50 ` sashiko-bot
2026-07-14 21:14 ` Steven Rostedt
2026-07-14 18:32 ` [RFC PATCH 09/13] mm/kwatch: add probe lifecycle runtime Jinchao Wang
2026-07-14 19:53 ` sashiko-bot
2026-07-14 18:32 ` [RFC PATCH 10/13] mm/kwatch: add anchor thread for global watchpoints Jinchao Wang
2026-07-14 18:48 ` sashiko-bot
2026-07-14 18:33 ` [RFC PATCH 11/13] mm/kwatch: add debugfs control plane Jinchao Wang
2026-07-14 18:58 ` sashiko-bot
2026-07-14 18:33 ` [RFC PATCH 12/13] mm/kwatch: add KUnit tests for the watch expression parser Jinchao Wang
2026-07-14 18:50 ` sashiko-bot
2026-07-14 18:33 ` [RFC PATCH 13/13] Documentation/dev-tools: document KWatch Jinchao Wang
2026-07-14 18:48 ` sashiko-bot
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=20260714184551.DC9EE1F00A3A@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=wangjinchao600@gmail.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.