From patchwork Wed Oct 4 07:41:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: tip-bot2 for Thomas Gleixner X-Patchwork-Id: 148166 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2a8e:b0:403:3b70:6f57 with SMTP id in14csp2587510vqb; Wed, 4 Oct 2023 00:41:29 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFPTBZ6rRY2ZgvMZ9JFMZTYcgujAqqkwW7Y4pYUGfJyOKFaiJ2rakydAAHEpxPBFS2z2Ejh X-Received: by 2002:a17:902:d30d:b0:1c5:ecff:1bc7 with SMTP id b13-20020a170902d30d00b001c5ecff1bc7mr1657298plc.4.1696405288997; Wed, 04 Oct 2023 00:41:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696405288; cv=none; d=google.com; s=arc-20160816; b=idxBqdrtjDC86hlB5c2GHuoeiZa4v9U9JDQNXLdyzdMrc4/h2UR0XMXNmwZVpzNEDo FtUurZeciGVxSef2sgStxUPjR7FzIWcQZseXatwXMPugXi62aqxTG1YcwhYsiWbzLiFn 9yj8Adc1KL4uj5Ns5c3HWmAUIfLIdBTtc5wfBLfiv36LHY0DlyfbwA+IKp85J1+gjCEF 5x4+7O447sOyMDz1vG01aW5y5ubv8QIDtFchbKskg6CC/an5LaKZbYruxgxLWxHJbf6T dMA858HFgyUnM5lEuBAqOUBpdqgHhtPY5yrYkFtDvTpsis71fF/bxcx4X8HHNfQCdzIN VL7A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:robot-unsubscribe :robot-id:message-id:mime-version:references:in-reply-to:cc:subject :to:reply-to:sender:from:dkim-signature:dkim-signature:date; bh=N3DAeRCTXgcmL6wGVPGeNq0prqCeKyw0QqbONR1xZzA=; fh=nbezmC2TbzCfv1UOM39SZTxMPRfdCCVj1Grwuunxz9I=; b=IeBbjEEYxSCuKGr7oq0LxohqJfj2dLua/Ep6UAT/aT9sltQ2pBxIgjWiAVwomtydOP /4re8g3fmIX0W1Mgm4xK57E4YicqNTJApEPPO/tpqQjU94o+HYEdXzr26XnQln2VNRXu WulrUQeYglp04dPliVavTnPgC9dKMTCF+QpmWjdNTbDj/UsshdVIzlGwGrxkqQTztntm QvW4L7oFCVtWEaMJtW3RcHgAFaNESqpDuKnCjJpYXVphURaU8moYPgVyVHBJgadYFxg0 PDhnk5X9jX/emCPZa/Z3JKdyUk8pZMnMRwW8Oqhz699jYcxET0Pg3tnaEnCNyrE+9JVl nmVw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=Q+wQZ0+k; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id k12-20020a170902d58c00b001c563263222si3326399plh.376.2023.10.04.00.41.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Oct 2023 00:41:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=Q+wQZ0+k; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 3DD82804ACF4; Wed, 4 Oct 2023 00:41:28 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241528AbjJDHlT (ORCPT + 18 others); Wed, 4 Oct 2023 03:41:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42892 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241543AbjJDHlQ (ORCPT ); Wed, 4 Oct 2023 03:41:16 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0C128AD; Wed, 4 Oct 2023 00:41:11 -0700 (PDT) Date: Wed, 04 Oct 2023 07:41:08 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1696405269; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=N3DAeRCTXgcmL6wGVPGeNq0prqCeKyw0QqbONR1xZzA=; b=Q+wQZ0+kZ+Df3U8BgTnZQUMdhZE3NH1TUEbqHW/kRE/0PeUE1ueE734AyeBuuVELApI8Yf eObZh6nDTDMxCCWvrAomMqgvlGCiu7T7P6B8+ljoR4xEwQS4k9mX9x/hG1o2InJ0qA4hd8 +pKt1UdZfPgKeuYHi2xCzQsSaYx29d5h6Vow2xAND9EHI3PhW0ht3O6BH8H2LHHyjbRLJn 6xYobE47r5Y+F+4aDxRRvjBM/cH3wuF6QPnaiPJRW9+8doGF6ZwcY+U5zxI8/OTEqJfCW5 5ri7rtAzAV6AOfg2jAZdAF4jmPDdOBZeUJ+UkHGMSNZMK04qB47LBPkW1shosQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1696405269; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=N3DAeRCTXgcmL6wGVPGeNq0prqCeKyw0QqbONR1xZzA=; b=YziiVtxsZ1a8Jf5cVXyQ7mu4FCn3bG8pZhRWIt7QOBXwC9SjsDEtR9IRdm2KqO7ZNHpv87 b1fNN8FaqoCt/VDQ== From: "tip-bot2 for Justin Stitt" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: x86/mm] x86/tdx: Replace deprecated strncpy() with strtomem_pad() Cc: Justin Stitt , Ingo Molnar , Kees Cook , Dave Hansen , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20231003-strncpy-arch-x86-coco-tdx-tdx-c-v2-1-0bd21174a217@google.com> References: <20231003-strncpy-arch-x86-coco-tdx-tdx-c-v2-1-0bd21174a217@google.com> MIME-Version: 1.0 Message-ID: <169640526821.3135.14252605949556446798.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Wed, 04 Oct 2023 00:41:28 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778809872697343318 X-GMAIL-MSGID: 1778809872697343318 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 AuthorDate: Tue, 03 Oct 2023 21:54:59 Committer: Ingo Molnar 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 Signed-off-by: Ingo Molnar Reviewed-by: Kees Cook Acked-by: Dave Hansen 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;