From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 D65A3342538; Sat, 4 Jul 2026 09:10:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783156223; cv=none; b=s7RcxeuOv9+Gr7Tk+c/O+BYCqiK7AhiLgf+u5yic2N+kiR6BDpB13jFkt/TZMJFZ6IePRmiTGx+W6OwvkdDmTeKI9cENhtphOcN8hLe7ttdJVsLaqG+6yYN5kGVHaUhKKVNDE3m3C3pEi0Nz+NnJINiMfLeLErf9fy+hgC1pe+E= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783156223; c=relaxed/simple; bh=WHQp6O5UqBznnh17N+e9Ls0ks6AdwQ8G63PjlS+dlOo=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=JWE21EKMPMiMApFLLEO1fUXE/xWijvgAlMnrWw9i4Cu4TygLJ/TtuFN9GaGSwU9Z4j6fQ177K1A8pHBxVOnZGhAq0OeZIr7QzW1oh7nBkgdJvoXGKkSIx2w4yrPPW+J6cTYObJPeFgqeK9mQx2srC6XUSkmxgy1sz6VtWnsZeJ4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=mpKZ4WvB; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="mpKZ4WvB" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8563F1F000E9; Sat, 4 Jul 2026 09:10:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1783156222; bh=53EQLw8XTEKafDGHQxdckYh+PN5Z8cHEu1Ax3kBjkYQ=; h=Date:Subject:To:Cc:References:From:In-Reply-To; b=mpKZ4WvB1LGdTw/vgASBVUBuaZlEfZeN8b1CQ7ChT63YY4UYXNWKcpSMS9vf/g560 G1v3sXJYYcunL1fwyBgAKYbKwgnLjSgxwOUUbpklJR7dcnhkYjW8981fYk0HLz4gYC 3jbApuPrxjc0EZRJt3+gfakE7mVV2KK13kI1IflqOwlz7WggXSDdQgwelGykLer7v0 mvl7pn7UbBhOFT61LgMujJzotLp6bVAmJDNNTLSikTXunU8Z3EHu7nFtlJ4yBuoOgu CrMbCze98EfT0Yujmu4S+XRb42FQkUOxT3Ror6libgvFbNa/bJTJ5x+i7kZcBWRdpA YZH09UM8bRpkg== Message-ID: Date: Sat, 4 Jul 2026 11:10:18 +0200 Precedence: bulk X-Mailing-List: linux-hardening@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH next] drivers/bus/fsl-mc: Use strscpy() to copy strings into arrays To: david.laight.linux@gmail.com, Kees Cook , Ioana Ciornei Cc: Arnd Bergmann , linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org, linuxppc-dev@lists.ozlabs.org References: <20260608095500.2567-1-david.laight.linux@gmail.com> Content-Language: fr-FR From: "Christophe Leroy (CS GROUP)" In-Reply-To: <20260608095500.2567-1-david.laight.linux@gmail.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Le 08/06/2026 à 11:54, david.laight.linux@gmail.com a écrit : > From: David Laight > > Replacing strcpy() with strscpy() ensures than overflow of the target > buffer cannot happen. > > Signed-off-by: David Laight > --- > This is one of a group of patches that remove potentially unbounded > strcpy() calls. > > They are mostly replaced by strscpy() or, when strlen() has just been > called, with memcpy() (usually including the '\0'). > > Calls with copy string literals into arrays are left unchanged. > They are safe and easily detected as such. > > The changes were made by getting the compiler to detect the calls and > then fixing the code by hand. > > Note that all the changes are only compile tested. > > Some Makefiles were changed to allow files to contain strcpy(). > As well as 'difficult to fix' files, this included 'show' functions > as they really need to use sysfs_emit() or seq_printf(). > > All the patches are being sent individually to avoid very long cc lists. > Apologies for the terse commit messages and likely unexpected tags. > (There are about 100 patches in total.) > > drivers/bus/fsl-mc/fsl-mc-bus.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) Do you expect this patch to go via individual trees or will you apply them all together in a given tree ? Ioana, as usual I can take it via soc/fsl/ with your Ack. Christophe > > diff --git a/drivers/bus/fsl-mc/fsl-mc-bus.c b/drivers/bus/fsl-mc/fsl-mc-bus.c > index 221146e4860b..372175fe169c 100644 > --- a/drivers/bus/fsl-mc/fsl-mc-bus.c > +++ b/drivers/bus/fsl-mc/fsl-mc-bus.c > @@ -903,7 +903,7 @@ struct fsl_mc_device *fsl_mc_get_endpoint(struct fsl_mc_device *mc_dev, > int state, err; > > mc_bus_dev = to_fsl_mc_device(mc_dev->dev.parent); > - strcpy(endpoint1.type, mc_dev->obj_desc.type); > + strscpy(endpoint1.type, mc_dev->obj_desc.type); > endpoint1.id = mc_dev->obj_desc.id; > endpoint1.if_id = if_id; > > @@ -920,7 +920,7 @@ struct fsl_mc_device *fsl_mc_get_endpoint(struct fsl_mc_device *mc_dev, > return ERR_PTR(err); > } > > - strcpy(endpoint_desc.type, endpoint2.type); > + strscpy(endpoint_desc.type, endpoint2.type); > endpoint_desc.id = endpoint2.id; > endpoint = fsl_mc_device_lookup(&endpoint_desc, mc_bus_dev); > if (endpoint)