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
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Wed, 04 Oct 2023 07:41:08 -0000
From:   "tip-bot2 for Justin Stitt" <tip-bot2@...utronix.de>
To:     linux-tip-commits@...r.kernel.org
Cc:     Justin Stitt <justinstitt@...gle.com>,
        Ingo Molnar <mingo@...nel.org>,
        Kees Cook <keescook@...omium.org>,
        Dave Hansen <dave.hansen@...ux.intel.com>, x86@...nel.org,
        linux-kernel@...r.kernel.org
Subject: [tip: x86/mm] x86/tdx: Replace deprecated strncpy() with strtomem_pad()

The following commit has been merged into the x86/mm branch of tip:

Commit-ID:     c9babd5d95abf3fae6e798605ce5cac98e08daf9
Gitweb:        https://git.kernel.org/tip/c9babd5d95abf3fae6e798605ce5cac98e08daf9
Author:        Justin Stitt <justinstitt@...gle.com>
AuthorDate:    Tue, 03 Oct 2023 21:54:59 
Committer:     Ingo Molnar <mingo@...nel.org>
CommitterDate: Wed, 04 Oct 2023 09:34:07 +02:00

x86/tdx: Replace deprecated strncpy() with strtomem_pad()

strncpy() works perfectly here in all cases, however, it is deprecated and
as such we should prefer more robust and less ambiguous string APIs:

    https://www.kernel.org/doc/html/latest/process/deprecated.html#strncpy-on-nul-terminated-strings

Let's use strtomem_pad() as this matches the functionality of strncpy()
and is _not_ deprecated.

Signed-off-by: Justin Stitt <justinstitt@...gle.com>
Signed-off-by: Ingo Molnar <mingo@...nel.org>
Reviewed-by: Kees Cook <keescook@...omium.org>
Acked-by: Dave Hansen <dave.hansen@...ux.intel.com>
Link: https://github.com/KSPP/linux/issues/90
Link: https://lore.kernel.org/r/20231003-strncpy-arch-x86-coco-tdx-tdx-c-v2-1-0bd21174a217@google.com
---
 arch/x86/coco/tdx/tdx.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/coco/tdx/tdx.c b/arch/x86/coco/tdx/tdx.c
index 1d6b863..2e1be59 100644
--- a/arch/x86/coco/tdx/tdx.c
+++ b/arch/x86/coco/tdx/tdx.c
@@ -119,7 +119,7 @@ static void __noreturn tdx_panic(const char *msg)
 	} message;
 
 	/* VMM assumes '\0' in byte 65, if the message took all 64 bytes */
-	strncpy(message.str, msg, 64);
+	strtomem_pad(message.str, msg, '\0');
 
 	args.r8  = message.r8;
 	args.r9  = message.r9;

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ