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-next>] [day] [month] [year] [list]
Message-Id: <20240604044228.2910712-1-liujinlong@kylinos.cn>
Date: Tue,  4 Jun 2024 12:42:28 +0800
From: liujinlong <mingliu6104@...il.com>
To: kees@...nel.org
Cc: thunder.leizhen@...wei.com,
	yonghong.song@...ux.dev,
	ndesaulniers@...gle.com,
	song@...nel.org,
	ardb@...nel.org,
	maninder1.s@...sung.com,
	azeemshaikh38@...il.com,
	linux-kernel@...r.kernel.org,
	liujinlong <liujinlong@...inos.cn>,
	k2ci <kernel-bot@...inos.cn>
Subject: [PATCH] sprint_symbol: Replace strcpy with memmove to handle potential overlap

In the function __sprint_symbol, replace strcpy with memmove to ensure
correct behavior even if the source and destination buffers overlap.
This change prevents potential undefined behavior flagged by recent
compilers as [-Werror=restrict].

Reported-by: k2ci <kernel-bot@...inos.cn>
Signed-off-by: liujinlong <liujinlong@...inos.cn>
---
 kernel/kallsyms.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/kallsyms.c b/kernel/kallsyms.c
index 22ea19a36e6e..3c3a77fcd020 100644
--- a/kernel/kallsyms.c
+++ b/kernel/kallsyms.c
@@ -489,7 +489,7 @@ static int __sprint_symbol(char *buffer, unsigned long address,
 		return sprintf(buffer, "0x%lx", address - symbol_offset);
 
 	if (name != buffer)
-		strcpy(buffer, name);
+		memmove(buffer, name, strlen(name) + 1);
 	len = strlen(buffer);
 	offset -= symbol_offset;
 
-- 
2.17.1


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ