linux-security-module.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jarkko Sakkinen <jarkko@kernel.org>
To: Thorsten Blum <thorsten.blum@linux.dev>
Cc: David Howells <dhowells@redhat.com>,
	Paul Moore <paul@paul-moore.com>,
	James Morris <jmorris@namei.org>,
	"Serge E. Hallyn" <serge@hallyn.com>,
	keyrings@vger.kernel.org, linux-security-module@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] keys: Replace memcpy with strscpy in proc_keys_show
Date: Wed, 19 Nov 2025 04:36:32 +0200	[thread overview]
Message-ID: <aR0tME7U4tYNH-x6@kernel.org> (raw)
In-Reply-To: <20251112172620.4254-2-thorsten.blum@linux.dev>

On Wed, Nov 12, 2025 at 06:26:21PM +0100, Thorsten Blum wrote:
> Use strscpy() to copy strings into the fixed-size buffer 'xbuf' instead
> of hardcoding the number of bytes to copy. This improves maintainability

I don't consider maintainaibility as a stimulus of applying change given
that as a word it means me absolutely nothing.

> and ensures the buffer is always NUL-terminated.
> 
> Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
> ---
>  security/keys/proc.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/security/keys/proc.c b/security/keys/proc.c
> index 4f4e2c1824f1..1d380766f45d 100644
> --- a/security/keys/proc.c
> +++ b/security/keys/proc.c
> @@ -10,6 +10,7 @@
>  #include <linux/fs.h>
>  #include <linux/proc_fs.h>
>  #include <linux/seq_file.h>
> +#include <linux/string.h>
>  #include <asm/errno.h>
>  #include "internal.h"
>  
> @@ -199,9 +200,9 @@ static int proc_keys_show(struct seq_file *m, void *v)
>  	/* come up with a suitable timeout value */
>  	expiry = READ_ONCE(key->expiry);
>  	if (expiry == TIME64_MAX) {
> -		memcpy(xbuf, "perm", 5);
> +		strscpy(xbuf, "perm");
>  	} else if (now >= expiry) {
> -		memcpy(xbuf, "expd", 5);
> +		strscpy(xbuf, "expd");
>  	} else {
>  		timo = expiry - now;
>  
> -- 
> 2.51.0
> 

BR, Jarkko

      reply	other threads:[~2025-11-19  2:36 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-12 17:26 [PATCH] keys: Replace memcpy with strscpy in proc_keys_show Thorsten Blum
2025-11-19  2:36 ` Jarkko Sakkinen [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=aR0tME7U4tYNH-x6@kernel.org \
    --to=jarkko@kernel.org \
    --cc=dhowells@redhat.com \
    --cc=jmorris@namei.org \
    --cc=keyrings@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-security-module@vger.kernel.org \
    --cc=paul@paul-moore.com \
    --cc=serge@hallyn.com \
    --cc=thorsten.blum@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).