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] [day] [month] [year] [list]
Date:   Sat, 07 Jan 2023 11:37:11 -0000
From:   "tip-bot2 for Xu Panda" <tip-bot2@...utronix.de>
To:     linux-tip-commits@...r.kernel.org
Cc:     Xu Panda <xu.panda@....com.cn>, Yang Yang <yang.yang29@....com>,
        Ingo Molnar <mingo@...nel.org>,
        Tony Luck <tony.luck@...el.com>, x86@...nel.org,
        linux-kernel@...r.kernel.org
Subject: [tip: x86/platform] x86/mce/dev-mcelog: use strscpy() to instead of strncpy()

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 <xu.panda@....com.cn>
AuthorDate:    Sat, 03 Dec 2022 14:19:32 +08:00
Committer:     Ingo Molnar <mingo@...nel.org>
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 <xu.panda@....com.cn>
Signed-off-by: Yang Yang <yang.yang29@....com>
Signed-off-by: Ingo Molnar <mingo@...nel.org>
Reviewed-by: Tony Luck <tony.luck@...el.com>
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)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ