From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from elvis.franken.de (elvis.franken.de [193.175.24.41]) by smtp.subspace.kernel.org (Postfix) with ESMTP id F3CF83093DB; Fri, 29 Aug 2025 10:31:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.175.24.41 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756463486; cv=none; b=ebBYQtfqnrTsias1GiQisCjkAbG2QYOP4s8wsdkztfSU56VlCi+xwVNV4AXRID7xExxeLck3Qij8R52mIgSgKVFv3OnK/3uLfpCFeoKZQvSKt/s5GAwc9Wb49gBfJ/0pvGrP76XmrVKF36lketPqwIEQ6KOhEERnIoCrZOP7WUk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756463486; c=relaxed/simple; bh=oK1vTC3I1CcIsF3aIfGOa5puBtc8td3Zh60PXSCKEvY=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=h4ZG1Azv4PiSifRIP12dyBB078up1YF3xvm10uEy8H+qqHiRiIpdKeMr/ggSCUKBFwo/KrWid0vjhg32V06thfqpBh5tcJ28mwEKNvgPPnWZmEX7w16ZZiuCGVUV1bhEkClLdgYsE0b9Snuug0oSbthLfrn0/V/dWrhqMMXnl1c= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=alpha.franken.de; spf=pass smtp.mailfrom=alpha.franken.de; arc=none smtp.client-ip=193.175.24.41 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=alpha.franken.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=alpha.franken.de Received: from uucp by elvis.franken.de with local-rmail (Exim 3.36 #1) id 1urwO2-0004GF-00; Fri, 29 Aug 2025 12:31:14 +0200 Received: by alpha.franken.de (Postfix, from userid 1000) id 05BBFC0D9E; Fri, 29 Aug 2025 12:26:32 +0200 (CEST) Date: Fri, 29 Aug 2025 12:26:32 +0200 From: Thomas Bogendoerfer To: Thorsten Blum Cc: linux-hardening@vger.kernel.org, linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 6/8] MIPS: octeon: Replace memset(0) + deprecated strcpy() with strscpy_pad() Message-ID: References: <20250817183728.612012-1-thorsten.blum@linux.dev> <20250817183728.612012-6-thorsten.blum@linux.dev> Precedence: bulk X-Mailing-List: linux-hardening@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: <20250817183728.612012-6-thorsten.blum@linux.dev> On Sun, Aug 17, 2025 at 08:37:16PM +0200, Thorsten Blum wrote: > Replace memset(0) followed by the deprecated strcpy() with strscpy_pad() > to improve octeon_fdt_set_phy(). This avoids zeroing the memory before > copying the string and ensures the destination buffer is only written to > once, simplifying the code and improving efficiency. > > Link: https://github.com/KSPP/linux/issues/88 > Signed-off-by: Thorsten Blum > --- > arch/mips/cavium-octeon/octeon-platform.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/arch/mips/cavium-octeon/octeon-platform.c b/arch/mips/cavium-octeon/octeon-platform.c > index 5e1dd4e6e82f..47677b5d7ed0 100644 > --- a/arch/mips/cavium-octeon/octeon-platform.c > +++ b/arch/mips/cavium-octeon/octeon-platform.c > @@ -13,6 +13,7 @@ > #include > #include > #include > +#include > > #include > #include > @@ -538,8 +539,7 @@ static void __init octeon_fdt_set_phy(int eth, int phy_addr) > > if (octeon_has_88e1145()) { > fdt_nop_property(initial_boot_params, phy, "marvell,reg-init"); > - memset(new_name, 0, sizeof(new_name)); > - strcpy(new_name, "marvell,88e1145"); > + strscpy_pad(new_name, "marvell,88e1145"); > p = fdt_getprop(initial_boot_params, phy, "compatible", > ¤t_len); > if (p && current_len >= strlen(new_name)) > -- > 2.50.1 applied to mips-next. Thomas. -- Crap can work. Given enough thrust pigs will fly, but it's not necessarily a good idea. [ RFC1925, 2.3 ]