From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wr1-f52.google.com (mail-wr1-f52.google.com [209.85.221.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E8C753D9678 for ; Mon, 8 Jun 2026 18:20:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.52 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780942811; cv=none; b=sWSKOWavSOcOJT4hRQlte2ZiNs7WdGk45ehZryQd26oytdQgED5Edc/NiBK/edBZmTT64HvTmHEEjh4lLJa5KRLj4o3jE3BHhmBet41z6dxpKl5jO5i6jV3VTz9WmIGNqp6arB+TX3AmO/3MACbz7EGLN/NZAwuTYPgGi7rJ/dU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780942811; c=relaxed/simple; bh=uwsZ3rg1UDET6SuAP7hOzDi5eSbDRr98eL5zTg6W9wg=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=uwpeA9gRSjlGm8avTUNzVFnpo5lTk/B+3onl0y5UYFLCxYqBSGKH+fs3HEGskRUZiwRT169RPVrSRaT0/ffs6yQqn8MZRArsv3c1wWNI0ASxpb3PpUo2ofrh3ay2fS4O1ahay0OvC7eP5Jc4qSWyHQyfH7PPDZUZgbc119fyHeQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=NKk9lbdl; arc=none smtp.client-ip=209.85.221.52 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="NKk9lbdl" Received: by mail-wr1-f52.google.com with SMTP id ffacd0b85a97d-4602e2a0372so3287595f8f.3 for ; Mon, 08 Jun 2026 11:20:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1780942807; x=1781547607; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:from:to:cc:subject:date :message-id:reply-to; bh=IM32Hg+/N9sZmZsEYWIoImVUskuRRqFje5vCWqdJGu8=; b=NKk9lbdl4FYAZ1zxJ6uJy2UY8xtXN/xO0sk2iK8vyc72Ornh6t3J/hiLinD5Fq9ETx NcccXyWqz2wkvAw9pzZFRftcEk3d3Hy7qQdHQsYC8X6kwEZZzCQJyJKD2pKjUY2WAySJ Q7qRPZpLdzZGStWjSMX5NcFYNDqHnyGfLTbTcZADmh9I3J36PQbfIaHUdEUdzGlzCJaf lH4OAPCS9SkCoI25c3w4HVUQDYZUwlKYGFo1tUnrUujYK7MJm9glmWoGwUHjPIX2Pmf8 Fpgjl8rG9dB+2xlFN6YVx7pZQ6PwVH+8sGtoKdMCPd84PcgU01WC66cNfURwwxdLHT9v G8AA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780942807; x=1781547607; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=IM32Hg+/N9sZmZsEYWIoImVUskuRRqFje5vCWqdJGu8=; b=k9RdIhsJ5G02pec2uG4prJ1uYzLYj4Ya7hmtQHVXzp/y47KWcfI2kcbVF6QNjW4lGy uvsap0LJO0xXgrVHl276kysUIozo1SILGRLAz/UZO/jr7m0T02TushFjRey9XSOwqxpI y4Tx26aNWKHqkmMlEkcBR5O4G2wvYCPa2ZjJy13zxuszjLAYTIrWE1QvuOCtBo+ADCK2 9SyS9NeUYWdZrIp4TEXAGR5tVpuMHhtGp/qLE6E9VRzWukSkfshU3s3HLeyD8QSpBv3Z RQ5N4KBXGh4ryIROnCRyziXhbrEPDFvUiPWgLHM+d6SaLIPik0U4I7CUj9yK9aPeb9qO IscA== X-Forwarded-Encrypted: i=1; AFNElJ+UtVZmL47+n+DvfOfejd/pl0JbpBY4lQTZ1nCEonCYvh6Nwq16evIk1uuCo4QvKl5eVZLM4KgUA4S+lVg=@vger.kernel.org X-Gm-Message-State: AOJu0YxUxN/dPMhtzbstpP3pni+gilGCs8+ervtScVSLWjez+ul3o6zD B9Yw0dxzxSifcpDTdci+6hz8jp8Yav2rVyRdiUYtnIpOnNCfXKqh12uX X-Gm-Gg: Acq92OGCW6KNbKQZVzq+2ain4OjW6W6qEfHQ5s7Rd9VPAXQorclQUhU0fmLVSbDirxK 5b1rW8/ex6CakZxAwc8PZsqI1gofNkz/JxBIW5V0/rnXGCE/7RR9b3+kDeTHlq1K5Ivz8U7oYCi +xgLqNOByQrZ12eqQfRI/5i6Y5C6VTtdBMTmyNT0AsjvGqKo3BJTrqfT7Vmk9i0dACvBZ7tySv5 oFdKDtvxwSIBpXNPUGi/LzaI5tpxDClPIKNNCBM3VHUBo+P/xXRpF3Xnp6SPE+tDmJbo56zxedI OtEt98p9IG7uwDD0WEXUMCLsaKWXBumL0J0dTXstoUlIhmXAQJxT31p32n9bl7GQnkdqkE0fP0v 8Q0B9NY+LDpqq0ed6u6jngbdrvCuAr/JmBmsDwVF8AdxWhAEMRLgwgRpUlmCcs9PMyRobrcYgrC lmWND9kzVj2B4uRarum6JegMDqCSF3TmC41hsrnpULdNzKvqIeIwVrhsNNA4vccUmrF+dwOVHES Yjv04zf6w== X-Received: by 2002:adf:fd04:0:b0:43b:3b80:6776 with SMTP id ffacd0b85a97d-46030751decmr20596399f8f.30.1780942807204; Mon, 08 Jun 2026 11:20:07 -0700 (PDT) Received: from pumpkin (82-69-66-36.dsl.in-addr.zen.co.uk. [82.69.66.36]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4601f2dcde3sm56294211f8f.1.2026.06.08.11.20.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Jun 2026 11:20:06 -0700 (PDT) Date: Mon, 8 Jun 2026 19:20:04 +0100 From: David Laight To: Rob Herring Cc: Kees Cook , linux-hardening@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Arnd Bergmann , Saravana Kannan Subject: Re: [PATCH next] drivers/of/overlay: Use memcpy() to copy known length strings Message-ID: <20260608192004.796f2c47@pumpkin> In-Reply-To: References: <20260608095523.2606-32-david.laight.linux@gmail.com> X-Mailer: Claws Mail 4.1.1 (GTK 3.24.38; arm-unknown-linux-gnueabihf) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On Mon, 8 Jun 2026 12:35:06 -0500 Rob Herring wrote: > On Mon, Jun 8, 2026 at 4:55=E2=80=AFAM wro= te: > > > > From: David Laight > > > > The lengths have been used for the kzalloc(), use the same ones for the= copy. =20 >=20 > This doesn't answer why we are doing this. Only the below which gets > removed on commit provides the reasoning. I will resend with an extra line (or two) of description above the ---. (I was using -m 'text' to add the commit message and using same text for equivalent changes to multiple files - seem to have got caught out!) -- David >=20 > > > > 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/of/overlay.c | 4 ++-- > > 1 file changed, 2 insertions(+), 2 deletions(-) > > > > diff --git a/drivers/of/overlay.c b/drivers/of/overlay.c > > index c1c5686fc7b1..656867009514 100644 > > --- a/drivers/of/overlay.c > > +++ b/drivers/of/overlay.c > > @@ -258,8 +258,8 @@ static struct property *dup_and_fixup_symbol_prop( > > if (!new_prop->name || !new_prop->value) > > goto err_free_new_prop; > > > > - strcpy(new_prop->value, target_path); > > - strcpy(new_prop->value + target_path_len, path_tail); > > + memcpy(new_prop->value, target_path, target_path_len); > > + memcpy(new_prop->value + target_path_len, path_tail, path_tail_= len); > > > > of_property_set_flag(new_prop, OF_DYNAMIC); > > > > -- > > 2.39.5 > > =20