From patchwork Sat Jan 7 11:37:11 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: 40371 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp1259759wrt; Sat, 7 Jan 2023 03:38:03 -0800 (PST) X-Google-Smtp-Source: AMrXdXtyo+ViC/Gzrkt201oKgXkSlaNGfVTeYdUlnAbYuC0P58SQNgbdgg7rsN/ohdSxikLFn585 X-Received: by 2002:a17:90a:5312:b0:226:f35f:923b with SMTP id x18-20020a17090a531200b00226f35f923bmr1791201pjh.2.1673091482882; Sat, 07 Jan 2023 03:38:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673091482; cv=none; d=google.com; s=arc-20160816; b=b0H6NHVM7ij9LofvZbQHBtLoeydCnCkVfTa/jcL7Hx/3zUpX/FOgo2Gh0hOK0mmwnF rLAikyuA7wSt08xelpyBCXCdjwXny8rhfq/Q81zJmTtz1Dn59bUwrNTj+sFqL5VEsRP0 2M03xtv73moWLTLetUtURitUrg/A738JGr+YTTRJqRj0k0Zdv35f3Rgv7n2tRT32qIKo hec16J5OR9CTAKosuz0sxdmzdccJLx7LWjCZ0uMc/uZEvM70yfOZsw+V+vj+A/qeUHsu ew/YDTrqBYujM2cf7m5/joDHVdWtaRaDDjhUXudgGtcGFhyMRyjk8RH1T8opPLiUFjYY syIw== 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=r0TiEt6R/k7PhmvnMvJLv7VpfpmxF8iccSTw/Z9XGG4=; b=dhhGaQrgNeRWmj0szBl0bTRHyHs9AHnQCw+7hTH+5Gg3p3dXJB9q7+nvhY6d12cmaV FTZZDcZsN7ssZvXsTV3DKKPEoWODB1LRJOrrXfdoJGHhafWX0yBPzhGJdLqW8rJUMJ4S qh4hcFQ3VK6eO8TNw5CrI+9xDQ3ZxuQol/S7MLPtMOsnmNfQj6F7W5DiC+8Vys1jOOWf X7AzVt/eIEboqB51f765vY6M093YQBZndYGtLHXuUj+702X+g1tA3er/DOnh2LOoRwqU 2BRLSUbNQiuFNl/ZaJSVKZQyHF3+7cWLhTkuD9j+6CPkyZOQc0BwTa4VY+dCy2QDzh79 lcww== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=VFSwUTHA; dkim=neutral (no key) header.i=@linutronix.de; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b29-20020a631b5d000000b004a77afad410si4082871pgm.487.2023.01.07.03.37.50; Sat, 07 Jan 2023 03:38:02 -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; dkim=pass header.i=@linutronix.de header.s=2020 header.b=VFSwUTHA; dkim=neutral (no key) header.i=@linutronix.de; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230243AbjAGLhS (ORCPT + 99 others); Sat, 7 Jan 2023 06:37:18 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55724 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229475AbjAGLhP (ORCPT ); Sat, 7 Jan 2023 06:37:15 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AEE3A6DBA0; Sat, 7 Jan 2023 03:37:13 -0800 (PST) Date: Sat, 07 Jan 2023 11:37:11 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1673091432; 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=r0TiEt6R/k7PhmvnMvJLv7VpfpmxF8iccSTw/Z9XGG4=; b=VFSwUTHAnjIoOcAGBHqGIIfpJxSS2P94dwXHwnO2HDnncp106U1zisuAFpqzDDMwlwMSh7 WFGeiuXexjQv4ouDoap48o2ohuRDzBKGYfTFA5fegXMCREtvrH3Ae21HbePBqGJdbTpkbc 4D6F2oEQMjAf/3hcDFr+zzczh+c30DHo7xBkKQFKENnFqBBee/nKmt9Nvh5jg/BzqkfYip k6GlzNw6VALXOK1+oATBgGTvMhDukSbdqque/drVE6dY8zXWdrvX4XmVdKo0NBsliMs1zT W+47ozGhMw2qPpX3kkqhw9VFrKkS5xeW5aezBSgtY0Uwkt9odaWfLxzxj8wnNQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1673091432; 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=r0TiEt6R/k7PhmvnMvJLv7VpfpmxF8iccSTw/Z9XGG4=; b=n9VK123stcS1SNnrXfZd61PKSC7tgjyp/zi1IO/GG3I2J6bXRFImdtoSfUouSuNlrn8PbW nfxIrkjpDx9ocyDQ== From: "tip-bot2 for Xu Panda" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: x86/platform] x86/mce/dev-mcelog: use strscpy() to instead of strncpy() Cc: Xu Panda , Yang Yang , Ingo Molnar , Tony Luck , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <202212031419324523731@zte.com.cn> References: <202212031419324523731@zte.com.cn> MIME-Version: 1.0 Message-ID: <167309143194.4906.10220848041501270532.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS 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-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1751174463182656863?= X-GMAIL-MSGID: =?utf-8?q?1754363574539426154?= The following commit has been merged into the x86/platform branch of tip: Commit-ID: 7ddf0050a21fdcc025c3cb1055fe3db60df1cd97 Gitweb: https://git.kernel.org/tip/7ddf0050a21fdcc025c3cb1055fe3db60df1cd97 Author: Xu Panda AuthorDate: Sat, 03 Dec 2022 14:19:32 +08:00 Committer: Ingo Molnar CommitterDate: Sat, 07 Jan 2023 11:47:35 +01:00 x86/mce/dev-mcelog: use strscpy() to instead of strncpy() 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 Signed-off-by: Ingo Molnar Reviewed-by: Tony Luck Link: https://lore.kernel.org/r/202212031419324523731@zte.com.cn --- arch/x86/kernel/cpu/mce/dev-mcelog.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/arch/x86/kernel/cpu/mce/dev-mcelog.c b/arch/x86/kernel/cpu/mce/dev-mcelog.c index 100fbee..a05ac07 100644 --- a/arch/x86/kernel/cpu/mce/dev-mcelog.c +++ b/arch/x86/kernel/cpu/mce/dev-mcelog.c @@ -105,8 +105,7 @@ static ssize_t set_trigger(struct device *s, struct device_attribute *attr, { char *p; - strncpy(mce_helper, buf, sizeof(mce_helper)); - mce_helper[sizeof(mce_helper)-1] = 0; + strscpy(mce_helper, buf, sizeof(mce_helper)); p = strchr(mce_helper, '\n'); if (p)