From nobody Sat Feb 7 20:44:23 2026 Received: from out-188.mta1.migadu.com (out-188.mta1.migadu.com [95.215.58.188]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 35E6226AEC for ; Fri, 25 Apr 2025 08:01:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.188 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745568090; cv=none; b=VIRfRyFEentHv7oRmFCOpfKTiP+YsfD5bYan43e0wYmKlvD/g/4fDR9bhSheZ1xOTV+GZX+/J30WmvTg88wAtU7JrrvmjWQPlV/wyXBve7tZiaNk3m47WTJfGLo0ZVKXwUgRkmSGZI61tWS1efIQs2FHbI6nZPSa4BQ5xNLnMEs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745568090; c=relaxed/simple; bh=9i0pqeJF9Lv6Vi+wvxKY/gQ+rtNhrwok614Nr1Sr4JE=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=jm3/EnaQYyPc4OBKqLGsDvLQS4wogrm6YiFhC9DtEPIAVU5y52MVOCyBqQmyzwKz0s5pr9nHbZ+g4QA50hzta5G1O20NzHPl3KJW5zo+QFpaAsovpVmYUfHRxcwpHvnZb9iGFROWMsd2fldOR+kXZxy9TStuWqEQDKVD1Zq8TOQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=G9Jt30zz; arc=none smtp.client-ip=95.215.58.188 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="G9Jt30zz" X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1745568085; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=ysvHHKCoxOnwQA+EqA6Oq9PHFBYzde/132axQDe0NyE=; b=G9Jt30zzgf32eLKfsf7tyBckgc77qsPK17FWt1YtgldgE1D8gcPJcopTrE3e0+7JKBvBmV NYWXYeQ/GrVYTSakQcISWs5Nk+AiGIjj1eZMM0sPucMK/gpwrWinMbBtvFMdHayTnLdPxh 42j/xDljnjxTtpC65mu48C1tEdTngkk= From: Thorsten Blum To: Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , Perry Yuan , Mario Limonciello , Rik van Riel , Tom Lendacky , Max Grobecker , Sandipan Das , "Ahmed S. Darwish" , Mateusz Guzik , Brian Gerst , Uros Bizjak , Brendan Jackman , "Xin Li (Intel)" , Tony Luck , Juergen Gross , Andy Shevchenko , Russell Senior , Sohil Mehta , Ravi Bangoria , Eric Biggers , Alison Schofield Cc: linux-hardening@vger.kernel.org, Thorsten Blum , Ingo Molnar , linux-kernel@vger.kernel.org Subject: [PATCH] x86/cpu: Replace deprecated strcpy() with strscpy() Date: Fri, 25 Apr 2025 09:49:11 +0200 Message-ID: <20250425074917.1531-3-thorsten.blum@linux.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Migadu-Flow: FLOW_OUT Content-Type: text/plain; charset="utf-8" strcpy() is deprecated; use strscpy() instead. In cyrix.c, use 'c->x86_model_id' directly and remove the local variable 'buf' to retain the array size of the destination buffer. No functional changes intended. Link: https://github.com/KSPP/linux/issues/88 Signed-off-by: Thorsten Blum --- arch/x86/kernel/cpu/amd.c | 3 ++- arch/x86/kernel/cpu/common.c | 6 +++--- arch/x86/kernel/cpu/cyrix.c | 7 +++---- arch/x86/kernel/cpu/intel.c | 2 +- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/arch/x86/kernel/cpu/amd.c b/arch/x86/kernel/cpu/amd.c index 2b36379ff675..3a6daa862536 100644 --- a/arch/x86/kernel/cpu/amd.c +++ b/arch/x86/kernel/cpu/amd.c @@ -8,6 +8,7 @@ #include #include #include +#include #include #include #include @@ -643,7 +644,7 @@ static void init_amd_k8(struct cpuinfo_x86 *c) } =20 if (!c->x86_model_id[0]) - strcpy(c->x86_model_id, "Hammer"); + strscpy(c->x86_model_id, "Hammer"); =20 #ifdef CONFIG_SMP /* diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c index 12126adbc3a9..ea43e70a9b40 100644 --- a/arch/x86/kernel/cpu/common.c +++ b/arch/x86/kernel/cpu/common.c @@ -183,9 +183,9 @@ static void default_init(struct cpuinfo_x86 *c) if (c->cpuid_level =3D=3D -1) { /* No cpuid. It must be an ancient CPU */ if (c->x86 =3D=3D 4) - strcpy(c->x86_model_id, "486"); + strscpy(c->x86_model_id, "486"); else if (c->x86 =3D=3D 3) - strcpy(c->x86_model_id, "386"); + strscpy(c->x86_model_id, "386"); } #endif } @@ -1919,7 +1919,7 @@ static void identify_cpu(struct cpuinfo_x86 *c) const char *p; p =3D table_lookup_model(c); if (p) - strcpy(c->x86_model_id, p); + strscpy(c->x86_model_id, p); else /* Last resort... */ sprintf(c->x86_model_id, "%02x/%02x", diff --git a/arch/x86/kernel/cpu/cyrix.c b/arch/x86/kernel/cpu/cyrix.c index dfec2c61e354..07521e3f94d8 100644 --- a/arch/x86/kernel/cpu/cyrix.c +++ b/arch/x86/kernel/cpu/cyrix.c @@ -192,7 +192,6 @@ static void early_init_cyrix(struct cpuinfo_x86 *c) static void init_cyrix(struct cpuinfo_x86 *c) { unsigned char dir0, dir0_msn, dir0_lsn, dir1 =3D 0; - char *buf =3D c->x86_model_id; const char *p =3D NULL; =20 /* @@ -352,9 +351,9 @@ static void init_cyrix(struct cpuinfo_x86 *c) dir0_msn =3D 7; break; } - strcpy(buf, Cx86_model[dir0_msn & 7]); + strscpy(c->x86_model_id, Cx86_model[dir0_msn & 7]); if (p) - strcat(buf, p); + strcat(c->x86_model_id, p); return; } =20 @@ -416,7 +415,7 @@ static void cyrix_identify(struct cpuinfo_x86 *c) if (c->x86 =3D=3D 4 && test_cyrix_52div()) { unsigned char dir0, dir1; =20 - strcpy(c->x86_vendor_id, "CyrixInstead"); + strscpy(c->x86_vendor_id, "CyrixInstead"); c->x86_vendor =3D X86_VENDOR_CYRIX; =20 /* Actually enable cpuid on the older cyrix */ diff --git a/arch/x86/kernel/cpu/intel.c b/arch/x86/kernel/cpu/intel.c index cdc9813871ef..5e60aaa871cb 100644 --- a/arch/x86/kernel/cpu/intel.c +++ b/arch/x86/kernel/cpu/intel.c @@ -605,7 +605,7 @@ static void init_intel(struct cpuinfo_x86 *c) } =20 if (p) - strcpy(c->x86_model_id, p); + strscpy(c->x86_model_id, p); } #endif =20 --=20 2.49.0