From nobody Tue Sep 16 01:02:10 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9CA65C46467 for ; Sat, 7 Jan 2023 11:38:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230408AbjAGLhT (ORCPT ); Sat, 7 Jan 2023 06:37:19 -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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The following commit has been merged into the x86/platform branch of tip: Commit-ID: 7ddf0050a21fdcc025c3cb1055fe3db60df1cd97 Gitweb: https://git.kernel.org/tip/7ddf0050a21fdcc025c3cb1055fe3db60= df1cd97 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 dev= ice_attribute *attr, { char *p; =20 - strncpy(mce_helper, buf, sizeof(mce_helper)); - mce_helper[sizeof(mce_helper)-1] =3D 0; + strscpy(mce_helper, buf, sizeof(mce_helper)); p =3D strchr(mce_helper, '\n'); =20 if (p)