From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) (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 62F441C3C14 for ; Thu, 20 Feb 2025 02:22:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=139.178.84.217 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740018122; cv=none; b=LHB9B4IL4Txd1FiIBVG10+CVMfs8QXc7eT72F/3lstzANillRU/M4JKJ983OzNbYLTwEkMjm5/i1/WjT0Gtek7cz0u45YZHV7BaUy/iYVcok74PqihspsrKIWr+KELe05GfHBjwXWYb/lo8Eq3zvKGIxw5pSPLX5HNeDUr7tRLU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740018122; c=relaxed/simple; bh=CsKE1O38t52KiDz42xjoVchy3XbzTa/Ox6cYeUTmN2o=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=k14NwjBsJj/oPkkDT3cbmD04McQKeDTXuEjGx81G8t3jUz/luAtqCj30fOsXjWlfNz3AkLBXPorWEQBGNGEjsEHJBdLUqaFaFQAV4A81lb6Rw+VqwWJigtewP0inT+VRKviDK1SAt1yNahIQ4fKEa6eofGD33OfCfg5pOFIhHLY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=kernel.org; spf=pass smtp.mailfrom=kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=iPWAverB; arc=none smtp.client-ip=139.178.84.217 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=kernel.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=kernel.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="iPWAverB" Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 2666A5C598F; Thu, 20 Feb 2025 02:21:20 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 03670C4CED1; Thu, 20 Feb 2025 02:21:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1740018119; bh=CsKE1O38t52KiDz42xjoVchy3XbzTa/Ox6cYeUTmN2o=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=iPWAverBseQNUwurQ+ue9mcQ3yObYrdhiPCoGRhbnZFL/cAjTpWfe1AmIt50Pl7lZ rHt4QfEOkJ41lkhLfitj8NZYkWNtH2ZXBm/blLk4moFU6g8thv/kw3CSft4749/mqU N+YC6M74gTPmrQw2W5fOW1zzUUAtvLxUNDA4BH7FoycgihzdlYH9qJ2yP2PJ5Js7Lp YkHapP5/qyvdD61ksSS79UvIqpWwxFWyIYXseDXmnFFGovm2HryPsVc9TA3bTshn+Q b9n+jl89FoHDmeqrzJE5wqdL8RmidlxWBJV1LtmlBHx8xxFW81/Qa2KnbTTps5yGez 3T9I+P5eP+0CQ== Date: Wed, 19 Feb 2025 18:21:54 -0800 From: Kees Cook To: Thorsten Blum Cc: Geert Uytterhoeven , Jean-Michel Hautbois , linux-hardening@vger.kernel.org, linux-m68k@lists.linux-m68k.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] m68k: mm: Replace deprecated strncpy() with strscpy() Message-ID: <202502191820.DA875C6@keescook> References: <20250213141037.50394-2-thorsten.blum@linux.dev> Precedence: bulk X-Mailing-List: linux-m68k@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20250213141037.50394-2-thorsten.blum@linux.dev> On Thu, Feb 13, 2025 at 03:10:36PM +0100, Thorsten Blum wrote: > strncpy() is deprecated for NUL-terminated destination buffers. Use > strscpy() instead and remove the manual NUL-termination. > > Compile-tested only. > > Link: https://github.com/KSPP/linux/issues/90 > Cc: linux-hardening@vger.kernel.org > Signed-off-by: Thorsten Blum > --- > arch/m68k/kernel/setup_mm.c | 3 +-- > 1 file changed, 1 insertion(+), 2 deletions(-) > > diff --git a/arch/m68k/kernel/setup_mm.c b/arch/m68k/kernel/setup_mm.c > index 15c1a595a1de..48ce67947678 100644 > --- a/arch/m68k/kernel/setup_mm.c > +++ b/arch/m68k/kernel/setup_mm.c > @@ -243,8 +243,7 @@ void __init setup_arch(char **cmdline_p) > setup_initial_init_mm((void *)PAGE_OFFSET, _etext, _edata, _end); > > #if defined(CONFIG_BOOTPARAM) > - strncpy(m68k_command_line, CONFIG_BOOTPARAM_STRING, CL_SIZE); > - m68k_command_line[CL_SIZE - 1] = 0; > + strscpy(m68k_command_line, CONFIG_BOOTPARAM_STRING, CL_SIZE); > #endif /* CONFIG_BOOTPARAM */ > process_uboot_commandline(&m68k_command_line[0], CL_SIZE); > *cmdline_p = m68k_command_line; m68k_command_line lives in rwdata, so it should be 0-initialized by default, so there should be no behavioral difference here (i.e. it will be zero-padded), and it is used as a C String, so there was unlikely to be anything depending on the NUL-padding. Reviewed-by: Kees Cook -- Kees Cook