From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796387355; b=WVOeOT7tTfr3vpHWx109GW8Ps25cUsHyMu+mh5OKMdauxePYx75EnvdRJr3IupveRaQl JbX6jccWMECt3ZM08cErswGvuDoJj6U8DEBBMhpX48n/0ZW1kEtZZm4KWiBMMXw8wI0gW feb2/FefN5MZE/ay5fOv9KFJHcL16J+DD9L9pB5SbHbcacPruQ4cnKm4i4e4/n1pHk3Vf TxOBGF4B0X7cpRBjOmuol0Z3EcBK/E6scaRajtbBSGPJ30AgcYpGbvzI3kW0Kp+jeCmhK uvTf5016nul0Tb5lEed5v2IZ8uCCShZAi/YN0y0noFEiNELNJhy/CfDWNmg2Uiwtlpw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796387355; h=Received:DKIM-Signature:Date:From:To:Cc:Subject:Message-ID: References:MIME-Version:Content-Type:Content-Disposition:In-Reply-To; bh=H4qz7o8SZzaR1t8TVl+EmJodiiZIRlmhMZn31zJY50M=; b=0OwVW+yiBWINNqkGlKa1TUnXWhs+IrBjyreEW3idSQ73OdobLAw2CT/QHT4cwAWzikbD wjPlLxIH/1bxFizPDlCLCTw4t2kEQYS6bDVLfHGRVKTqX5dhds6tOU8isxcplGXX6Z8Ya w6PKsIjaG8DCbNyHOeemSDwXLgcTN9ZhUs78mqihQIGjG8foTnhG/EToACt7cGeLKSdBX rtaLqXk8zXfYLRWumq+K/NcYw49a6UPOU5iZyEpjGNBDGkaPytpQ9PjkG9idJRjLr4Ies /36kDMFowstCDr1a5wXntxpMoYXt3RYMZieavjKQzAPnKFNZKBiN15BesSvA0nUElUw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=Ndau03EL; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 44D45606A322; Fri, 4 Dec 2026 12:29:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=Ndau03EL Received: by smtp.kernel.org (Postfix) with ESMTPSA id 01DDD1F00897; Fri, 4 Dec 2026 12:29:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796387355; bh=H4qz7o8SZzaR1t8TVl+EmJodiiZIRlmhMZn31zJY50M=; h=Date:From:To:Cc:Subject:References:In-Reply-To; b=Ndau03EL/BaXLo6IXtLjOEVknx+Gyn9QtfM0TQOQTEPg85BG/UkoYMw/wFerMtTB8 flNm62dnnRNQvSLkCkmoZ8PgGiBalFGGCnMsAvOH9mlN+rbx4grHRDMASCZLsV75K6 dDy1pydTmz3pVgBMR3DWOkJvyv9I+Dsa/qkBlaZaaMKEK06HzB20uyE+l9KhyNGjnj KhLSwoddx7puprDOpPxVdJbpC5cOrKT8Pv36xPSmpmt6eAa4Ppu3UFgOsTftcbr6B6 SPLMI9Gpdgzk/x5ddqeE0GN2fez+gZTTWUeKhIW+SF7iiuxjlfici1Aedc8n9YvPh/ LMOl7pylXgEsQ== Date: Fri, 4 Dec 2026 13:29:07 +0100 From: Alejandro Colomar To: Alejandro Colomar , Andy Shevchenko , Kees Cook Cc: linux-hardening@vger.kernel.org, Krzysztof Kozlowski , "Maciej W. Rozycki" , Geert Uytterhoeven , Andreas Schwab , Andy Shevchenko , Bartosz Golaszewski , Daniel Scally , Danilo Krummrich , Greg Kroah-Hartman , Hans Verkuil , Heikki Krogerus , Joe Perches , Johan Hovold , Kees Cook , Laurent Pinchart , Len Brown , Linus Torvalds , Linus Walleij , Namhyung Kim , "Rafael J. Wysocki" , Rob Herring , Sakari Ailus , Saravana Kannan , Steven Rostedt , Tom Zanussi , linux-acpi@vger.kernel.org, driver-core@lists.linux.dev, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-gpio@vger.kernel.org Subject: Re: [PATCH v8 0/4] Add strprefix() and fix a bug with it Message-ID: References: X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="rix3gpwvwznkhjfj" Content-Disposition: inline In-Reply-To: --rix3gpwvwznkhjfj Content-Type: text/plain; protected-headers=v1; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable From: Alejandro Colomar To: Alejandro Colomar , Andy Shevchenko , Kees Cook Cc: linux-hardening@vger.kernel.org, Krzysztof Kozlowski , "Maciej W. Rozycki" , Geert Uytterhoeven , Andreas Schwab , Andy Shevchenko , Bartosz Golaszewski , Daniel Scally , Danilo Krummrich , Greg Kroah-Hartman , Hans Verkuil , Heikki Krogerus , Joe Perches , Johan Hovold , Kees Cook , Laurent Pinchart , Len Brown , Linus Torvalds , Linus Walleij , Namhyung Kim , "Rafael J. Wysocki" , Rob Herring , Sakari Ailus , Saravana Kannan , Steven Rostedt , Tom Zanussi , linux-acpi@vger.kernel.org, driver-core@lists.linux.dev, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-gpio@vger.kernel.org Subject: Re: [PATCH v8 0/4] Add strprefix() and fix a bug with it Message-ID: References: MIME-Version: 1.0 In-Reply-To: Hi, Here's a gentle ping on this patch set. Have a lovely day! Alex > Date: 2026-11-26 13:17:12+0100 > From: Alejandro Colomar > > Hi! >=20 > str_has_prefix() is based on sizes and lengths, which means it must > overload the valid length 0 to mean not found. This is a typical > consequence of choosing to design an API around sizes and lengths, and > vanishes when moving to pointer-based similar APIs. >=20 > According to its author (Steven R.), str_has_prefix() was never meant to > accept an empty prefix, but that's not documented, and there's no > obvious reason why that would be acceptable for a generic string > function (as opposed to a function very specific to its original use). > Anyway, as suggested by Steven, I've added a WARN_ON_ONCE() to catch > such uses, and also added documentation stating this limitation. >=20 > If the function had been named something like strprefix_len(), that > design would have made sense, but being called str_has_prefix(), the > obvious way to call it will result in bugs, because the name contradicts > its intended use. >=20 > Users of strings need a function whose behavior extends naturally to the > empty string, and we can do better, by returning a pointer. And indeed, > users have ended up using str_has_prefix() with empty prefix, expecting > it to work (as is natural of a generic string API with that name). >=20 > This patch set adds strprefix(), and uses strprefix() in one place to > fix a bug reported by Bartosz. >=20 > It also adds streq(3), just because it simplifies the tests, and is also > a nice interface. >=20 > This patch set doesn't include the sibling strsuffix(), and also doesn't > replace any other cases which would benefit from strprefix(), to allow > merging it quickly. I'll work on a follow-up patch, including the > patches from v6 that have been dropped in this v7, after this has been > applied. >=20 >=20 > Have a lovely day! > Alex >=20 >=20 > Changes in v8 > ~~~~~~~~~~~~~ >=20 > - [*/4] > - Add Tested-by and Reviewed-by tags. > - [4/4] > - Remove Message-ID tags. [Andy, Geert, Bartosz] >=20 > See the range-diff and interdiff below. >=20 > v1: > v2: > v3: > v4: > v5: > v6: > v7: >=20 > Testing > ~~~~~~~ >=20 > Since there are no code changes since v7, I haven't tested again. > See the link for v7 above to see the testing of v7. Bartosz also > tested v7. >=20 >=20 > Alejandro Colomar (4): > string: Add streq() > string: Add strprefix() > string: Document corner-case misbehavior in str_has_prefix() for empty > prefix > device property: Fix fwnode_name_eq() for empty node names >=20 > drivers/base/property.c | 5 +--- > drivers/clk/socfpga/clk-gate-a10.c | 2 -- > drivers/clk/socfpga/clk.h | 1 - > include/linux/string.h | 42 +++++++++++++++++++++++++++--- > lib/tests/string_kunit.c | 22 ++++++++++++++++ > 5 files changed, 61 insertions(+), 11 deletions(-) >=20 > Interdiff against v7: > Range-diff against v7: > 1: ad8500a6eb0a ! 1: 8f3840fa232e string: Add streq() > @@ Commit message > =20 > This removes some driver-specific definitions of streq(3). > =20 > + Tested-by: Bartosz Golaszewski > + Reviewed-by: Bartosz Golaszewski > Signed-off-by: Alejandro Colomar > =20 > ## drivers/clk/socfpga/clk-gate-a10.c ## > 2: b32d70163fb4 ! 2: a688f0a1c20a string: Add strprefix() > @@ Commit message > =20 > Closes: https://lore.kernel.org/linux-hardening/20261104-fwnode-= for-each-prop-v1-1-6e28fe1c72c4@oss.qualcomm.com/ > Reported-by: Bartosz Golaszewski > + Tested-by: Bartosz Golaszewski > + Reviewed-by: Bartosz Golaszewski > Signed-off-by: Alejandro Colomar > =20 > ## include/linux/string.h ## > 3: c4131a109098 ! 3: fb24c7a543f8 string: Document corner-case misbehav= ior in str_has_prefix() for empty prefix > @@ Commit message > =20 > Closes: https://lore.kernel.org/linux-hardening/20261104-fwnode-= for-each-prop-v1-1-6e28fe1c72c4@oss.qualcomm.com/ > Reported-by: Bartosz Golaszewski > + Tested-by: Bartosz Golaszewski > + Reviewed-by: Bartosz Golaszewski > Signed-off-by: Alejandro Colomar > =20 > ## include/linux/string.h ## > 4: 396395e1d02c ! 4: 5c23d229235a device property: Fix fwnode_name_eq()= for empty node names > @@ Commit message > Closes: https://lore.kernel.org/linux-hardening/20261104-fwnode-= for-each-prop-v1-1-6e28fe1c72c4@oss.qualcomm.com/ > Reported-by: Bartosz Golaszewski > Reviewed-by: Sakari Ailus > - Message-ID: > Reviewed-by: Bartosz Golaszewski > - Message-ID: > Tested-by: Bartosz Golaszewski > - Message-ID: > Signed-off-by: Alejandro Colomar > =20 > ## drivers/base/property.c ## > --=20 > 2.55.0 >=20 --=20 --rix3gpwvwznkhjfj Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEES7Jt9u9GbmlWADAi64mZXMKQwqkFAmsSshIACgkQ64mZXMKQ wql5GA/9Hsw90/6ZXHUiJgh15ujBXY6Cwrg3FYvuafTrJQWUDzSn2QFajAnEp2bs x3zt6GthmXnVOfjMSc7ughVyKoKTg/RGoJF861I++FtLnZ5Y6lZLZJ5UV80dRs/t tQpBRUuKrkH3rnasWcfkmBvz2gJFMWu/e4ugk8KOXirnYPEhAQWzgFJUUkNBkMrG G3VWCN6qmUG1suR0EABFBzHPk89jiZ+2UhbjMSAOndqR345A40H9xX65X3kgSCix V/olDL1p0J24ydsHvtIh7b/azpT9MumDwswXd9XcKNZDtwAmMor/+zJmAX+KdG1I g+l19syGqkUhbVrH5w87I01klHtQa1punSOfwz8qs1VLDvqJzraG28uhnTxM5hVH shE9NxMXBYsXZP8U/IXEVoBYS0y6KvkQ8gAof1AHaTvPw/jqFHGvloEOjtIBM79R eUf0l6ZQ7VKcmENv+g+2pYHQb/mxOsT1OCM2OhslnNdao5xwd95L0LhsulUu6xfn zZxPs1mJuehaI425Y5Qom5Mmxfxia3PCDNlDIJstDqsW9McwnuNXPDAjwmggCM5H aZozkVjkfjAoDAmQrb7t6Yion6VlreFKeXZ7yHS30mqIuAsq3LY/A1nTWQZWtIh/ UsaZKPsKwNx2Js7KL2Uvtg8+bJ6qFfsfI32KggyjFyRkIVpC6oI= =flwD -----END PGP SIGNATURE----- --rix3gpwvwznkhjfj--