Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp3146737rwb; Fri, 2 Dec 2022 23:13:21 -0800 (PST) X-Google-Smtp-Source: AA0mqf6d2v55T8CqR+mZz2s+1SNHgQ/0IOjMcV6Naupqja5J7zMIVIyN4v2sNHnPLKRWfuaxIH7m X-Received: by 2002:a17:90a:4d48:b0:219:4487:f763 with SMTP id l8-20020a17090a4d4800b002194487f763mr25953285pjh.201.1670051601706; Fri, 02 Dec 2022 23:13:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670051601; cv=none; d=google.com; s=arc-20160816; b=acx53uD4maHBFTkwnqzrLmxWgXd9h8UhsxrYAa4Y194yun3yyhJqbu3DBMUokvHVEv ut2daveuEPgX0IORoif+9CiaVEPUdP8x62dum6G/oypHi3Cjtk/L9TCAcYgdMyz3AZ2q nc/ys8WttQ7yFUjUMpPF4jJhMzV4ICFJJh0rlSyJNpj1OFOLCT6hEKpzln+EJqfp22vo sJQFesFTfuuoKeCLNqBI3VyTh82nHHRTKE9S5a+CxdYR6Aqbj4tIrqQg+yPoFLmGiJbf XQTsktRuLhZK6udWVIIFr+ptHZAf3EtyTn6gtyssfqDrX0FbxWwqkvvCTGEawv9j4tpc qDRw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:subject:cc:to:from:mime-version:message-id:date; bh=P2Twls+mt6cx3r0J7P83/ql7I+3JkigLFBFlKhQVmm8=; b=uzckKf+fDHvf3hjao3AQwR9mQbXDtrbF7x6vy5BBoapYm0P4V3Dwbfuhg70YNuhzoS H4AUOUqV13wgwU2owGb1j6J9g3lKcXROIlzdJ4B+/rir1/zdlPjbLogJv7xsGd53azwi D/6Ob+/J+wwypnHrpLtY3h0U4WFId1zP+vzuiXzBl4yC3pFU4I9UZpZ7qIT/N0beV6TY hmBAD6lOl7RZRT7hgmjHeHNhfcuejkEp3FKls1WOiimEQVUMqlfsTjwnbw/SIDFCgLcz ZKvSb1Uho7fvjGmNCEn+qKTORvXS8HI15gSv0DUhZVFtsxGi8UcWtDgDeeSwUKs0NxI0 aQeQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=zte.com.cn Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s15-20020a17090aad8f00b001faf26eed66si8787228pjq.150.2022.12.02.23.13.11; Fri, 02 Dec 2022 23:13:21 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=zte.com.cn Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231311AbiLCGYX (ORCPT + 82 others); Sat, 3 Dec 2022 01:24:23 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47528 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230414AbiLCGYV (ORCPT ); Sat, 3 Dec 2022 01:24:21 -0500 Received: from mxhk.zte.com.cn (mxhk.zte.com.cn [63.216.63.35]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6EE61C23D2; Fri, 2 Dec 2022 22:24:20 -0800 (PST) Received: from mse-fl1.zte.com.cn (unknown [10.5.228.132]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mxhk.zte.com.cn (FangMail) with ESMTPS id 4NPKXM0Jvqz5BNS0; Sat, 3 Dec 2022 14:24:19 +0800 (CST) Received: from szxlzmapp04.zte.com.cn ([10.5.231.166]) by mse-fl1.zte.com.cn with SMTP id 2B36OF6L089225; Sat, 3 Dec 2022 14:24:15 +0800 (+08) (envelope-from yang.yang29@zte.com.cn) Received: from mapi (szxlzmapp02[null]) by mapi (Zmail) with MAPI id mid14; Sat, 3 Dec 2022 14:24:17 +0800 (CST) Date: Sat, 3 Dec 2022 14:24:17 +0800 (CST) X-Zmail-TransId: 2b04638aeb9173903db7 X-Mailer: Zmail v1.0 Message-ID: <202212031424175433783@zte.com.cn> Mime-Version: 1.0 From: To: Cc: , , , , , , , , , , , , , , Subject: =?UTF-8?B?W1BBVENIIGxpbnV4LW5leHRdIHg4Ni9wbGF0Zm9ybS91djogdXNlIHN0cnNjcHkgdG8gaW5zdGVhZCBvZiBzdHJuY3B5KCk=?= Content-Type: text/plain; charset="UTF-8" X-MAIL: mse-fl1.zte.com.cn 2B36OF6L089225 X-Fangmail-Gw-Spam-Type: 0 X-FangMail-Miltered: at cgslv5.04-192.168.250.138.novalocal with ID 638AEB93.000 by FangMail milter! X-FangMail-Envelope: 1670048659/4NPKXM0Jvqz5BNS0/638AEB93.000/10.5.228.132/[10.5.228.132]/mse-fl1.zte.com.cn/ X-Fangmail-Anti-Spam-Filtered: true X-Fangmail-MID-QID: 638AEB93.000/4NPKXM0Jvqz5BNS0 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_PASS,UNPARSEABLE_RELAY 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 From: Xu Panda The implementation of strscpy() is more robust and safer. That's now the recommended way to copy NUL terminated strings. Signed-off-by: Xu Panda Signed-off-by: Yang Yang --- arch/x86/platform/uv/uv_nmi.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/arch/x86/platform/uv/uv_nmi.c b/arch/x86/platform/uv/uv_nmi.c index a60af0230e27..1b0c8062c731 100644 --- a/arch/x86/platform/uv/uv_nmi.c +++ b/arch/x86/platform/uv/uv_nmi.c @@ -205,8 +205,7 @@ static int param_set_action(const char *val, const struct kernel_param *kp) char arg[ACTION_LEN], *p; /* (remove possible '\n') */ - strncpy(arg, val, ACTION_LEN - 1); - arg[ACTION_LEN - 1] = '\0'; + strscpy(arg, val, ACTION_LEN - 1); p = strchr(arg, '\n'); if (p) *p = '\0'; @@ -959,7 +958,7 @@ static int uv_handle_nmi(unsigned int reason, struct pt_regs *regs) /* Unexpected return, revert action to "dump" */ if (master) - strncpy(uv_nmi_action, "dump", strlen(uv_nmi_action)); + strscpy(uv_nmi_action, "dump", strlen(uv_nmi_action)); } /* Pause as all CPU's enter the NMI handler */ -- 2.15.2