All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Jinchao Wang" <wangjinchao600@gmail.com>
Cc: linux-perf-users@vger.kernel.org
Subject: Re: [RFC PATCH v2 10/13] mm/kwatch: add anchor thread for global watchpoints
Date: Fri, 17 Jul 2026 13:20:33 +0000	[thread overview]
Message-ID: <20260717132033.A68001F00A3A@smtp.kernel.org> (raw)
In-Reply-To: <20260717130609.1903443-1-wangjinchao600@gmail.com>

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [Medium] `kwatch_anchor_start()` overwrites `kwatch_anchor_tsk` without checking if a thread is already running, permanently leaking the previous kernel thread.
- [Low] Undefined reference to `kwatch_auto_stop` causing a linker error.
--

--- Patch [10]: [RFC PATCH v2 10/13] mm/kwatch: add anchor thread for global watchpoints ---
commit a3eb869f890aaa4760c373cf20d5f98126ae7d23
Author: Jinchao Wang <wangjinchao600@gmail.com>

mm/kwatch: add anchor thread for global watchpoints

This patch adds a kernel thread that sleeps for a configured duration to
bound the watch window for global variables. When the duration expires,
the thread schedules a work item to tear down the session.

> diff --git a/mm/kwatch/anchor.c b/mm/kwatch/anchor.c
> new file mode 100644
> index 0000000000000..e87eb5e813ff2
> --- /dev/null
> +++ b/mm/kwatch/anchor.c
[ ... ]
> +static void kwatch_auto_stop_handler(struct work_struct *work)
> +{
> +	kwatch_auto_stop();
> +}

[Severity: Low]
Does this cause a linker error? kwatch_auto_stop() is called here, but it
appears to be undefined in the tree, which would result in a build failure
when CONFIG_KWATCH=y is enabled.

[ ... ]
> +int kwatch_anchor_start(u16 duration)
> +{
> +	kwatch_anchor_tsk = kthread_run(kwatch_anchor_thread_fn,
> +					(void *)(unsigned long)duration,
> +					"kwatch_anchor");
> +	if (IS_ERR(kwatch_anchor_tsk)) {

[Severity: Medium]
What happens if this function is called while an anchor thread is already
running? The global kwatch_anchor_tsk pointer is unconditionally overwritten
here without verifying if a previous thread is active or stopping it. 

Since the leaked thread loops waiting for kthread_should_stop() on a lost
task pointer, could this permanently leak the previous thread's task_struct
and stack?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260717125023.1895892-1-wangjinchao600@gmail.com?part=10

  reply	other threads:[~2026-07-17 13:20 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-17 12:50 [RFC PATCH v2 00/13] mm/kwatch: dynamic hardware watchpoints for hunting memory corruption Jinchao Wang
2026-07-17 13:02 ` [RFC PATCH v2 01/13] arch: add HAVE_REINSTALL_HW_BREAKPOINT Jinchao Wang
2026-07-17 13:02 ` [RFC PATCH v2 02/13] x86/hw_breakpoint: Unify breakpoint install/uninstall Jinchao Wang
2026-07-17 13:15   ` sashiko-bot
2026-07-17 13:03 ` [RFC PATCH v2 03/13] x86/hw_breakpoint: Add arch_reinstall_hw_breakpoint Jinchao Wang
2026-07-17 13:03 ` [RFC PATCH v2 04/13] HWBP: Add modify_wide_hw_breakpoint_local() API Jinchao Wang
2026-07-17 13:21   ` sashiko-bot
2026-07-17 13:04 ` [RFC PATCH v2 05/13] mm/kwatch: add watch expression parser and dereference engine Jinchao Wang
2026-07-17 13:15   ` sashiko-bot
2026-07-17 13:04 ` [RFC PATCH v2 06/13] mm/kwatch: add lockless per-task context pool Jinchao Wang
2026-07-17 13:19   ` sashiko-bot
2026-07-17 13:04 ` [RFC PATCH v2 07/13] stacktrace: export stack_trace_save_regs() Jinchao Wang
2026-07-17 13:05 ` [RFC PATCH v2 08/13] mm/kwatch: add hardware breakpoint backend Jinchao Wang
2026-07-17 13:24   ` sashiko-bot
2026-07-17 13:05 ` [RFC PATCH v2 09/13] mm/kwatch: add probe lifecycle runtime Jinchao Wang
2026-07-17 13:20   ` sashiko-bot
2026-07-17 13:06 ` [RFC PATCH v2 10/13] mm/kwatch: add anchor thread for global watchpoints Jinchao Wang
2026-07-17 13:20   ` sashiko-bot [this message]
2026-07-17 13:06 ` [RFC PATCH v2 11/13] mm/kwatch: add debugfs control plane Jinchao Wang
2026-07-17 13:27   ` sashiko-bot
2026-07-17 13:07 ` [RFC PATCH v2 12/13] mm/kwatch: add KUnit tests for the watch expression parser Jinchao Wang
2026-07-17 13:07 ` [RFC PATCH v2 13/13] Documentation/dev-tools: document KWatch Jinchao Wang
2026-07-17 13:30   ` sashiko-bot
2026-07-17 13:41 ` [RFC PATCH v2 00/13] mm/kwatch: dynamic hardware watchpoints for hunting memory corruption Dave Hansen
2026-07-17 18:10   ` Borislav Petkov

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=20260717132033.A68001F00A3A@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.