From: sashiko-bot@kernel.org
To: "Xiange Pi" <xiange.pi@intel.com>, "Kees Cook" <kees@kernel.org>,
"Alexander Viro" <viro@zeniv.linux.org.uk>,
"Christian Brauner" <brauner@kernel.org>
Cc: "Jan Kara" <jack@suse.cz>, linux-mm@kvack.org
Subject: Re: [PATCH] exec: annotate lockless tsk->comm update with data_race()
Date: Wed, 25 Nov 2026 08:50:46 +0000 [thread overview]
Message-ID: <sashiko-outbox-232945@kernel.org> (raw)
In-Reply-To: <20261124083848.1430527-1-xiange.pi@intel.com>
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Low] exec: data_race() in __set_task_comm() still triggers KCSAN on
readers
--
commit a04284363b9bce90bc6367728fc880cc5b2fd84a
Author: Xiange Pi <xiange.pi@intel.com>
exec: annotate lockless tsk->comm update with data_race()
This commit wraps the memcpy() and memset() calls in __set_task_comm()
with data_race() to suppress KCSAN warnings on lockless updates to
tsk->comm.
> diff --git a/fs/exec.c b/fs/exec.c
> index 8d2b14e1d455c..9a47cb27ce5d0 100644
> --- a/fs/exec.c
> +++ b/fs/exec.c
> @@ -1100,8 +1100,16 @@ void __set_task_comm(struct task_struct *tsk, const char *buf, bool exec)
> size_t len = strnlen(buf, sizeof(tsk->comm) - 1);
>
> trace_task_rename(tsk, buf);
> - memcpy(tsk->comm, buf, len);
> - memset(&tsk->comm[len], 0, sizeof(tsk->comm) - len);
> + /*
> + * tsk->comm is read locklessly by many users (e.g. tracepoints,
> + * printk). comm[TASK_COMM_LEN - 1] is never written with a non-NUL
> + * byte, so concurrent readers see a bounded, NUL-terminated string;
> + * at worst a mix of the old and new name. Mark the update as
> + * intentionally racy.
> + */
> + data_race(memcpy(tsk->comm, buf, len));
> + /* Same as above: lockless readers tolerate a partially updated comm. */
> + data_race(memset(&tsk->comm[len], 0, sizeof(tsk->comm) - len));
[Severity: Low]
Does annotating only the writer in __set_task_comm() actually suppress
KCSAN reports for unannotated lockless readers of tsk->comm?
data_race() disables KCSAN only on the writer thread via
__kcsan_disable_current(). Unannotated readers such as strlen() in
tracepoints or get_task_comm() still set up read watchpoints on tsk->comm
in kcsan_setup_watchpoint(). When a concurrent __set_task_comm() modifies
a watched byte to a different value, kcsan_found_watchpoint() on the
writer returns early without consuming the watchpoint, and the reader then
reports an unknown-origin data race under the default
CONFIG_KCSAN_REPORT_RACE_UNKNOWN_ORIGIN=y:
kernel/kcsan/core.c:kcsan_found_watchpoint() {
if (!kcsan_is_enabled(ctx))
return;
...
/*
* If the other thread does not want to ignore the access, and there was
* a value change as a result of this thread's operation, we will still
* generate a report of unknown origin.
*
* Use CONFIG_KCSAN_REPORT_RACE_UNKNOWN_ORIGIN=n to filter.
*/
}
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261124083848.1430527-1-xiange.pi@intel.com?part=1
prev parent reply other threads:[~2026-11-25 8:50 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-24 8:38 [PATCH] exec: annotate lockless tsk->comm update with data_race() Xiange Pi
2026-11-25 8:50 ` sashiko-bot [this message]
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=sashiko-outbox-232945@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=brauner@kernel.org \
--cc=jack@suse.cz \
--cc=kees@kernel.org \
--cc=linux-mm@kvack.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=viro@zeniv.linux.org.uk \
--cc=xiange.pi@intel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox