lists.openwall.net | lists / announce owl-users owl-dev john-users john-dev passwdqc-users yescrypt popa3d-users / oss-security kernel-hardening musl sabotage tlsify passwords / crypt-dev xvendor / Bugtraq Full-Disclosure linux-kernel linux-netdev linux-ext4 linux-hardening linux-cve-announce PHC | |
Open Source and information security mailing list archives
| ||
|
Message-ID: <202310121203.0415E3B@keescook> Date: Thu, 12 Oct 2023 12:03:32 -0700 From: Kees Cook <keescook@...omium.org> To: Justin Stitt <justinstitt@...gle.com> Cc: Ariel Elior <aelior@...vell.com>, Manish Chopra <manishc@...vell.com>, "David S. Miller" <davem@...emloft.net>, Eric Dumazet <edumazet@...gle.com>, Jakub Kicinski <kuba@...nel.org>, Paolo Abeni <pabeni@...hat.com>, netdev@...r.kernel.org, linux-kernel@...r.kernel.org, linux-hardening@...r.kernel.org Subject: Re: [PATCH v2] qed: replace uses of strncpy On Thu, Oct 12, 2023 at 06:35:41PM +0000, Justin Stitt wrote: > strncpy() is deprecated for use on NUL-terminated destination strings > [1] and as such we should prefer more robust and less ambiguous string > interfaces. > > This patch eliminates three uses of strncpy(): > > Firstly, `dest` is expected to be NUL-terminated which is evident by the > manual setting of a NUL-byte at size - 1. For this use specifically, > strscpy() is a viable replacement due to the fact that it guarantees > NUL-termination on the destination buffer. > > The next two cases should simply be memcpy() as the size of the src > string is always 3 and the destination string just wants the first 3 > bytes changed. > > To be clear, there are no buffer overread bugs in the current code as > the sizes and offsets are carefully managed such that buffers are > NUL-terminated. However, with these changes, the code is now more robust > and less ambiguous (and hopefully easier to read). > > Link: https://www.kernel.org/doc/html/latest/process/deprecated.html#strncpy-on-nul-terminated-strings [1] > Link: https://manpages.debian.org/testing/linux-manual-4.8/strscpy.9.en.html [2] > Link: https://github.com/KSPP/linux/issues/90 > Cc: linux-hardening@...r.kernel.org > Cc: Kees Cook <keescook@...omium.org> > Signed-off-by: Justin Stitt <justinstitt@...gle.com> Yup, this looks good to me now. Thanks! Reviewed-by: Kees Cook <keescook@...omium.org> -- Kees Cook
Powered by blists - more mailing lists