linux-trace-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "André Almeida" <andrealmeid@igalia.com>
Cc: linux-trace-kernel@vger.kernel.org
Subject: Re: [PATCH v6 5/6] prctl: Add support for long user thread names
Date: Thu, 10 Sep 2026 17:12:32 +0000	[thread overview]
Message-ID: <20260910171232.B4D551F000FF@smtp.kernel.org> (raw)
In-Reply-To: <20260910-tonyk-long_name-v6-5-d70afbf194c5@igalia.com>

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] Incorrect argument passed to `strscpy_pad` in Smack LSM causes an out-of-bounds read, leaking `struct task_struct` heap memory to the kernel log.
- [High] Incorrect argument passed to `copy_task_comm` in the BPF test module causes an invalid pointer dereference and kernel panic.
--

commit a226c4fbdd68ce01686ac76a75507a8ad81e5825
Author: André Almeida <andrealmeid@igalia.com>
Subject: prctl: Add support for long user thread names

This commit adds support for getting and setting long user thread names
with pr_set_ext_name and pr_get_ext_name.

[ ... ]

> diff --git a/security/smack/smack_lsm.c b/security/smack/smack_lsm.c
> --- a/security/smack/smack_lsm.c
> +++ b/security/smack/smack_lsm.c
> @@ -138,6 +138,8 @@ smk_bu_tsk_to_obj(struct task_struct *tsk, const struct task_smack *tsp,
>  	char acc[SMK_NUM_ACCESS_TYPE + 1];
>  	char comm[TASK_COMM_LEN];
>  
> +	strscpy_pad(comm, tsk);
        ^^^^^^^^^^^^^^^^^^^^^^

[Severity: High]
This isn't a bug introduced by this patch, but by an earlier patch in the
reviewed patchset. It remains unfixed in the final state of the series.

Does this code pass the correct argument to strscpy_pad()?

The strscpy_pad() call implicitly converts struct task_struct *tsk to 
const char *, causing the first 16 bytes of the task_struct to be copied 
into the comm buffer and subsequently logged via pr_info().

Could this cause an out-of-bounds read, leaking struct task_struct heap 
memory to the kernel log when smack bringup auditing is enabled and a 
relevant access check fails or is logged?

Exposing raw task structures to logs bypasses kernel address space layout 
randomization and leaks kernel layout data.

[ ... ]

> diff --git a/tools/testing/selftests/bpf/test_kmods/bpf_testmod-events.h b/tools/testing/selftests/bpf/test_kmods/bpf_testmod-events.h
> --- a/tools/testing/selftests/bpf/test_kmods/bpf_testmod-events.h
> +++ b/tools/testing/selftests/bpf/test_kmods/bpf_testmod-events.h
> @@ -20,7 +20,7 @@ TRACE_EVENT(bpf_testmod_test_read,
>  	),
>  	TP_fast_assign(
>  		__entry->pid = task->pid;
> -		memcpy(__entry->comm, task->comm, TASK_COMM_LEN);
> +		copy_task_comm(__entry->comm, task->comm, TASK_COMM_LEN);
                                              ^^^^^^^^^^

[Severity: High]
This isn't a bug introduced by this patch, but by an earlier patch in the
reviewed patchset. It remains unfixed in the final state of the series.

Are we passing the correct argument type to copy_task_comm() here?

The inline function copy_task_comm() expects a struct task_struct * 
but receives task->comm, which is a string pointer.

Inside copy_task_comm(), evaluating tsk->comm treats the string's memory 
address as a task_struct and adds the structural offset of the comm field, 
yielding a wildly invalid address. 

When bpf_testmod_test_read() executes during bpf selftests, won't this 
cause a wild pointer dereference and kernel panic?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260910-tonyk-long_name-v6-0-d70afbf194c5@igalia.com?part=5

  reply	other threads:[~2026-09-10 17:12 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-10 16:49 [PATCH v6 0/6] sched: Add support for long task name André Almeida
2026-09-10 16:49 ` [PATCH v6 1/6] treewide: Get rid of get_task_comm() André Almeida
2026-09-10 16:58   ` sashiko-bot
2026-09-10 16:49 ` [PATCH v6 2/6] treewide: Replace memcpy(..., current->comm) with copy_task_comm() André Almeida
2026-09-10 16:58   ` sashiko-bot
2026-09-10 16:49 ` [PATCH v6 3/6] lib/string_kunit: Add test for copy_task_comm() André Almeida
2026-09-10 16:49 ` [PATCH v6 4/6] sched: Extend task command name with TASK_COMM_EXT_LEN André Almeida
2026-09-10 16:49 ` [PATCH v6 5/6] prctl: Add support for long user thread names André Almeida
2026-09-10 17:12   ` sashiko-bot [this message]
2026-09-10 16:49 ` [PATCH v6 6/6] selftests: prctl: Add test for long " André Almeida
2026-09-10 17:00   ` 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=20260910171232.B4D551F000FF@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;
as well as URLs for NNTP newsgroup(s).