From: Kees Cook <kees@kernel.org>
To: Thorsten Blum <thorsten.blum@linux.dev>
Cc: James Smart <james.smart@broadcom.com>,
Ram Vegesna <ram.vegesna@broadcom.com>,
"James E.J. Bottomley" <James.Bottomley@hansenpartnership.com>,
"Martin K. Petersen" <martin.petersen@oracle.com>,
linux-hardening@vger.kernel.org, linux-scsi@vger.kernel.org,
target-devel@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] scsi: elx: sli4: Replace deprecated strncpy() with strscpy()
Date: Tue, 8 Apr 2025 16:42:42 -0700 [thread overview]
Message-ID: <202504081642.6A3104D@keescook> (raw)
In-Reply-To: <20250408102843.804083-2-thorsten.blum@linux.dev>
On Tue, Apr 08, 2025 at 12:28:40PM +0200, Thorsten Blum wrote:
> strncpy() is deprecated for NUL-terminated destination buffers; use
> strscpy() instead.
>
> Since sli_config_cmd_init() already zeroes out the destination buffers,
> the potential NUL-padding by strncpy() is unnecessary. strscpy() copies
> only the required characters and guarantees NUL-termination.
>
> And since all three destination buffers have a fixed length, strscpy()
> automatically determines their size using sizeof() when the argument is
> omitted. This makes any explicit sizeof() calls unnecessary.
>
> The source strings are also NUL-terminated and meet the __must_be_cstr()
> requirement of strscpy().
>
> No functional changes intended.
>
> Link: https://github.com/KSPP/linux/issues/90
> Cc: linux-hardening@vger.kernel.org
> Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
Reviewed-by: Kees Cook <kees@kernel.org>
--
Kees Cook
next prev parent reply other threads:[~2025-04-08 23:42 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-08 10:28 [PATCH v2] scsi: elx: sli4: Replace deprecated strncpy() with strscpy() Thorsten Blum
2025-04-08 23:42 ` Kees Cook [this message]
2025-04-12 1:28 ` Martin K. Petersen
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=202504081642.6A3104D@keescook \
--to=kees@kernel.org \
--cc=James.Bottomley@hansenpartnership.com \
--cc=james.smart@broadcom.com \
--cc=linux-hardening@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=martin.petersen@oracle.com \
--cc=ram.vegesna@broadcom.com \
--cc=target-devel@vger.kernel.org \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.