From: sashiko-bot@kernel.org
To: "André Almeida" <andrealmeid@igalia.com>
Cc: linux-trace-kernel@vger.kernel.org
Subject: Re: [PATCH v5 3/6] lib/string_kunit: Add test for copy_task_comm()
Date: Thu, 27 Aug 2026 18:47:15 +0000 [thread overview]
Message-ID: <20260827184715.BAFE01F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260827-tonyk-long_name-v5-3-5fa843782a00@igalia.com>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] Calling `set_task_comm()` with a zero-initialized dummy `task_struct` will cause a kernel panic if tracepoints or perf events are enabled, due to a NULL pointer dereference on `task->signal`.
- [Low] The test uses an unexported kernel symbol (`__set_task_comm`), which will cause a linker failure when the KUnit test is compiled as a module.
--
commit 6dcb08d5f95331fc252e0238ecf8e3db7d303fb5
Author: André Almeida <andrealmeid@igalia.com>
lib/string_kunit: Add test for copy_task_comm()
This commit adds a new KUnit test for copy_task_comm() to verify copying from
a task_struct works correctly. It tests the standard case as well as special
cases where the source and destination buffer sizes mismatch.
> diff --git a/lib/tests/string_kunit.c b/lib/tests/string_kunit.c
> index 0819ace5b0275..27a27ab13254a 100644
> --- a/lib/tests/string_kunit.c
> +++ b/lib/tests/string_kunit.c
[ ... ]
> @@ -881,6 +881,43 @@ static void string_bench_strrchr(struct kunit *test)
> STRING_BENCH_BUF(test, buf, len, strrchr, buf, '\0');
> }
>
> +#define TASK_NAME "task_name"
> +#define TASK_NAME_LEN 9
> +#define TASK_MAX_LEN TASK_COMM_LEN
> +#define SMALLER_LEN (TASK_NAME_LEN - 3)
> +#define BIGGER_LEN (TASK_MAX_LEN + 3)
> +
> +static void string_copy_task_comm(struct kunit *test)
> +{
> + char str[TASK_MAX_LEN] = TASK_NAME, copy[TASK_MAX_LEN],
> + smaller_buf[SMALLER_LEN], bigger_buf[BIGGER_LEN];
> + static struct task_struct task, *tsk = &task;
> + int len1, len2, i;
> +
> + /* set and get task name */
> + set_task_comm(tsk, str);
[Severity: High]
Will this cause a kernel panic if tracepoints or perf events are enabled
during the test?
The test uses a zero-initialized static task_struct. The set_task_comm()
macro invokes __set_task_comm(), which eventually calls trace_task_rename()
and perf_event_comm().
If the task_rename tracepoint is enabled, the tracepoint macro dereferences
tsk->signal->oom_score_adj. Similarly, if COMM perf events are active,
perf_event_comm() calls perf_event_pid() which dereferences
tsk->signal->pids[PIDTYPE_TGID].
Since the dummy task's signal pointer is NULL, won't either path crash
the kernel with a NULL pointer dereference?
[Severity: Low]
Does this introduce a build failure when the test is compiled as a module?
CONFIG_STRING_KUNIT_TEST can be built as a module. The set_task_comm() macro
calls __set_task_comm(), which is defined in fs/exec.c but does not appear
to be exported via EXPORT_SYMBOL.
Will this result in a linker failure at the modpost stage for module builds?
> + copy_task_comm(copy, tsk, TASK_COMM_LEN);
[ ... ]
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260827-tonyk-long_name-v5-0-5fa843782a00@igalia.com?part=3
next prev parent reply other threads:[~2026-08-27 18:47 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-27 18:22 [PATCH v5 0/6] sched: Add support for long task name André Almeida
2026-08-27 18:23 ` [PATCH v5 1/6] treewide: Get rid of get_task_comm() André Almeida
2026-08-27 18:40 ` sashiko-bot
2026-08-27 18:23 ` [PATCH v5 2/6] treewide: Replace memcpy(..., current->comm) with copy_task_comm() André Almeida
2026-08-27 18:35 ` sashiko-bot
2026-08-27 18:23 ` [PATCH v5 3/6] lib/string_kunit: Add test for copy_task_comm() André Almeida
2026-08-27 18:47 ` sashiko-bot [this message]
2026-08-27 18:23 ` [PATCH v5 4/6] sched: Extend task command name with TASK_COMM_EXT_LEN André Almeida
2026-08-27 19:05 ` sashiko-bot
2026-08-27 18:23 ` [PATCH v5 5/6] prctl: Add support for long user thread names André Almeida
2026-08-27 19:08 ` sashiko-bot
2026-08-27 18:23 ` [PATCH v5 6/6] selftests: prctl: Add test for long " André Almeida
2026-08-27 19:14 ` sashiko-bot
2026-08-30 21:24 ` kernel test robot
2026-08-30 22:55 ` kernel test robot
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=20260827184715.BAFE01F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=andrealmeid@igalia.com \
--cc=linux-trace-kernel@vger.kernel.org \
--cc=sashiko-reviews@lists.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