From: sashiko-bot@kernel.org
To: "Ye Liu" <ye.liu@linux.dev>
Cc: linux-security-module@vger.kernel.org,
linux-trace-kernel@vger.kernel.org
Subject: Re: [PATCH v4 11/15] tracing/fgraph: convert process/thread iterator to for_each_process_thread_rculock
Date: Mon, 21 Sep 2026 10:27:04 +0000 [thread overview]
Message-ID: <20260921102704.8820D1F000FF@smtp.kernel.org> (raw)
In-Reply-To: <20260921092101.89285-12-ye.liu@linux.dev>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] trace/fgraph: mixed goto-based error handling with scope-based cleanup
--
commit 6422a16035934ad7c858389b51cb5a7d9fecc15f
Author: Ye Liu <liuye@kylinos.cn>
tracing/fgraph: convert process/thread iterator to for_each_process_thread_rculock
This commit converts the manual rcu_read_lock() and rcu_read_unlock() pair
around the for_each_process_thread() loop in alloc_retstack_tasklist() to use
the for_each_process_thread_rculock() macro. This scopes the RCU read lock to
the loop body using a scoped guard, and removes the manual unlock label in the
error handling path.
> diff --git a/kernel/trace/fgraph.c b/kernel/trace/fgraph.c
> index 40d373d65f9b9..f797ce1192233 100644
> --- a/kernel/trace/fgraph.c
> +++ b/kernel/trace/fgraph.c
> @@ -1057,11 +1057,10 @@ static int alloc_retstack_tasklist(unsigned long **ret_stack_list)
> }
> }
>
> - rcu_read_lock();
> - for_each_process_thread(g, t) {
> + for_each_process_thread_rculock(g, t) {
> if (start == end) {
> ret = -EAGAIN;
> - goto unlock;
> + goto free;
[Severity: Low]
This doesn't cause a direct runtime bug here, but does this change mix
goto-based cleanup with scope-based cleanup?
The for_each_process_thread_rculock() macro initializes a scope-based RCU
guard via scoped_guard(rcu). By using goto free; to jump out of the
scoped guard to a manual cleanup label, this explicitly violates the
strict kernel cleanup rule in include/linux/cleanup.h meant to prevent
double-free and resource leak bugs. That rule states that goto-based
cleanup and scope-based cleanup must never be mixed in the same function.
While jumping out of scoped_guard() here triggers the RCU unlock safely
before executing the manual free label, should alloc_retstack_tasklist()
be fully converted to use scope-based cleanup for the ret_stack_list
allocations as well, or should it stick to manual RCU locks to avoid
mixing paradigms?
> }
>
> if (t->ret_stack == NULL) {
[ ... ]
> @@ -1074,9 +1073,6 @@ static int alloc_retstack_tasklist(unsigned long **ret_stack_list)
> t->ret_stack = ret_stack_list[start++];
> }
> }
> -
> -unlock:
> - rcu_read_unlock();
> free:
> for (i = start; i < end; i++)
> kmem_cache_free(fgraph_stack_cachep, ret_stack_list[i]);
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260921092101.89285-1-ye.liu@linux.dev?part=11
next prev parent reply other threads:[~2026-09-21 10:27 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-21 9:20 [PATCH v4 00/15] sched: introduce for_each_process_rculock and for_each_thread_rculock Ye Liu
2026-09-21 9:20 ` [PATCH v4 01/15] " Ye Liu
2026-09-21 9:41 ` sashiko-bot
2026-09-21 9:20 ` [PATCH v4 02/15] mm/oom_kill: convert process/thread iterators to for_each_*_rculock Ye Liu
2026-09-21 9:46 ` sashiko-bot
2026-09-21 19:58 ` Oleg Nesterov
2026-09-21 9:20 ` [PATCH v4 03/15] mm/ksm: convert process iterator to for_each_process_rculock Ye Liu
2026-09-21 9:51 ` sashiko-bot
2026-09-21 19:59 ` Oleg Nesterov
2026-09-21 9:20 ` [PATCH v4 04/15] mm/memory-failure: " Ye Liu
2026-09-21 9:55 ` sashiko-bot
2026-09-21 9:20 ` [PATCH v4 05/15] cpu/hotplug: " Ye Liu
2026-09-21 10:04 ` sashiko-bot
2026-09-21 9:20 ` [PATCH v4 06/15] freezer: convert thread iterator to for_each_thread_rculock Ye Liu
2026-09-21 10:07 ` sashiko-bot
2026-09-21 9:20 ` [PATCH v4 07/15] hung_task: convert process/thread iterators to for_each_*_rculock Ye Liu
2026-09-21 10:10 ` sashiko-bot
2026-09-21 9:20 ` [PATCH v4 08/15] locking/lockdep: " Ye Liu
2026-09-21 10:14 ` sashiko-bot
2026-09-21 9:20 ` [PATCH v4 09/15] rcu: convert process/thread iterator to for_each_process_thread_rculock Ye Liu
2026-09-21 10:18 ` sashiko-bot
2026-09-21 16:09 ` Paul E. McKenney
2026-09-21 9:20 ` [PATCH v4 10/15] sched: convert process/thread iterators to for_each_*_rculock Ye Liu
2026-09-21 10:23 ` sashiko-bot
2026-09-21 9:20 ` [PATCH v4 11/15] tracing/fgraph: convert process/thread iterator to for_each_process_thread_rculock Ye Liu
2026-09-21 10:27 ` sashiko-bot [this message]
2026-09-21 9:20 ` [PATCH v4 12/15] unwind: " Ye Liu
2026-09-21 10:32 ` sashiko-bot
2026-09-21 9:20 ` [PATCH v4 13/15] fs: convert process/thread iterators to for_each_*_rculock Ye Liu
2026-09-21 10:39 ` sashiko-bot
2026-09-21 9:33 ` [PATCH v4 14/15] lib: convert process iterator to for_each_process_rculock Ye Liu
2026-09-21 10:42 ` sashiko-bot
2026-09-21 20:12 ` Oleg Nesterov
2026-09-21 9:33 ` [PATCH v4 15/15] security/landlock: convert thread iterator to for_each_thread_rculock Ye Liu
2026-09-21 10:46 ` 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=20260921102704.8820D1F000FF@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=linux-security-module@vger.kernel.org \
--cc=linux-trace-kernel@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=ye.liu@linux.dev \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox