linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Jan Kara <jack@suse.cz>
To: Thorsten Blum <thorsten.blum@linux.dev>
Cc: Kees Cook <kees@kernel.org>,
	Alexander Viro <viro@zeniv.linux.org.uk>,
	 Christian Brauner <brauner@kernel.org>, Jan Kara <jack@suse.cz>,
	linux-mm@kvack.org,  linux-fsdevel@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/2] exec: use strnlen() in __set_task_comm
Date: Wed, 1 Apr 2026 18:30:55 +0200	[thread overview]
Message-ID: <wesnxxbjdbzstv2weyuyhcmorz3nuib6hz6msfxmrdlbuyow7x@e7rodhd7s7zm> (raw)
In-Reply-To: <20260401152039.724811-3-thorsten.blum@linux.dev>

On Wed 01-04-26 17:20:40, Thorsten Blum wrote:
> Use strnlen() to limit source string scanning to 'TASK_COMM_LEN - 1'
> bytes.
> 
> Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>

Looks good. Feel free to add:

Reviewed-by: Jan Kara <jack@suse.cz>

								Honza

> ---
>  fs/exec.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/fs/exec.c b/fs/exec.c
> index 9ea3a775d51e..ba12b4c466f6 100644
> --- a/fs/exec.c
> +++ b/fs/exec.c
> @@ -1074,7 +1074,7 @@ static int unshare_sighand(struct task_struct *me)
>   */
>  void __set_task_comm(struct task_struct *tsk, const char *buf, bool exec)
>  {
> -	size_t len = min(strlen(buf), sizeof(tsk->comm) - 1);
> +	size_t len = strnlen(buf, sizeof(tsk->comm) - 1);
>  
>  	trace_task_rename(tsk, buf);
>  	memcpy(tsk->comm, buf, len);
-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR


  reply	other threads:[~2026-04-01 16:31 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-01 15:20 Thorsten Blum
2026-04-01 16:30 ` Jan Kara [this message]
2026-04-01 19:28 ` Kees Cook

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=wesnxxbjdbzstv2weyuyhcmorz3nuib6hz6msfxmrdlbuyow7x@e7rodhd7s7zm \
    --to=jack@suse.cz \
    --cc=brauner@kernel.org \
    --cc=kees@kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=thorsten.blum@linux.dev \
    --cc=viro@zeniv.linux.org.uk \
    /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