Received: by 2002:a05:7412:2a8a:b0:fc:a2b0:25d7 with SMTP id u10csp469848rdh; Wed, 7 Feb 2024 09:52:16 -0800 (PST) X-Google-Smtp-Source: AGHT+IFFNa7OWiI/ZbdxAOP5ozQIN3K7P7xueLAbejkzv4MwNzGJ47kFBQnL9ntttIhGiJd9nPcL X-Received: by 2002:a05:6359:4c28:b0:178:7986:a586 with SMTP id kj40-20020a0563594c2800b001787986a586mr3784277rwc.5.1707328336183; Wed, 07 Feb 2024 09:52:16 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707328336; cv=pass; d=google.com; s=arc-20160816; b=BT5NJzgZPstzkBH+BjahHrD+XbFlart/eH0QkA9I6VMpxW84GuQPwsvfE7ANaFMG59 Hq4QwjSeFPH08yB1xM49FTlN3ipiE3BLdkhsDoOfPiTYFjArRHuIZ7hhDv4WbcXab/d/ rFnKSQP2xwzrhpv5C0cHwct4xwPF2gzmko+1lBJVxc3RvEkvgyjrUzV5Ypt3ZRgfDzdN PiFQxmYotZzNNDLDxbur2np0SK924oZWHLIXvEgjxGdhvV+9eBcLrXWKOgCkQAem0GGq CkomwPDHaWox8AgvHKmV2piFwc+e81LS23MzpQH4qHsZZNBBoso4BPYUZdxe6Y1trbA3 l8pg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=eaGHk2OWa64/I10L/xQQJe59trrcxp4jWd9IlpfddAc=; fh=kncPWA+oByB4lXilN9fJQseBBPljgxk1SCb0vAJBF5s=; b=Gik1Fb61Y1KIS5nz34GqDTUsXISg+u1K+RKTJNRvm6MGb5ahLDNQ1k0Y9GssYDbLXc f++o4OabSehTG89ZMw1NrSqOZu/R3/B0ThZqy24x/Hj0rJauwtA6IZjqorTBkaG4FFEd aG8gDaPJI041WbZX7ODre+wXlepL2lv+FPgzrYlGYqWQBgdpirwOF5McH+JE4Go7H2Yf OfRtx0XrOUI+8TldU3wIzgoYKuahj/kBd2tbTy39y3kd+jasFbXb9CQW/rWNI0gxLiqM yTrmRCqPKUDYEC+Qwx4i4+wE8NOhbnjfxIq/s/3AjSnswoblrK9IGrA7AgRXQbbAe6aV SyLA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ucw.cz header.s=gen1 header.b=AJv7n9vD; arc=pass (i=1 spf=pass spfdomain=ucw.cz dkim=pass dkdomain=ucw.cz dmarc=pass fromdomain=ucw.cz); spf=pass (google.com: domain of linux-kernel+bounces-56850-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-56850-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=ucw.cz X-Forwarded-Encrypted: i=2; AJvYcCWWNB3OWAvk8VF1GqIupB1AEaOw4bcZWKtc6s8d1N4Q/oty/sRf6xfH7piiywenrybSAKUQU8WLv4Fe0h3K7geekVu99de5eGJMyLP44A== Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id w189-20020a6362c6000000b005cfbd190e57si1984398pgb.297.2024.02.07.09.52.15 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Feb 2024 09:52:16 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-56850-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@ucw.cz header.s=gen1 header.b=AJv7n9vD; arc=pass (i=1 spf=pass spfdomain=ucw.cz dkim=pass dkdomain=ucw.cz dmarc=pass fromdomain=ucw.cz); spf=pass (google.com: domain of linux-kernel+bounces-56850-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-56850-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=ucw.cz Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 1428028746D for ; Wed, 7 Feb 2024 17:52:05 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3C2F782D6D; Wed, 7 Feb 2024 17:51:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ucw.cz header.i=@ucw.cz header.b="AJv7n9vD" Received: from jabberwock.ucw.cz (jabberwock.ucw.cz [46.255.230.98]) (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 7C5B582C88; Wed, 7 Feb 2024 17:51:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=46.255.230.98 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707328318; cv=none; b=gBtFf+mQzpx+yxXeAugDP7yzFnmAmIQkq7qoWUKumW+lsPKaJphTpWbGY4Uqr0ADzf8IdBvZ8sVZdlAOvA20bbaCXme6bfio8O4kpRSIG4ylMNBXHOj1OTr0u0C+GBlfgVoRrFX4BE5HbSA39tnhNIbgtTzrdGGbPbe8U1aUx7E= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707328318; c=relaxed/simple; bh=KB1LsbI9/iUC8oYPnytmZnQblhHYCQTehzwzfDiz2RA=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=OxauPeqm593dLMJhS0yuxIt8aMZj8gXHhUhLmDrHXxLwKsRmFxDjZkVVNE/mjB7/ZWK1982mrdnZsE4GsXReOg0TTfNMooxgeDYanNWoBg3ntm/LrcyDM3y2uzTdgzGpD8Hf4b5Q7ZkpG39ep0+cTeC5rGKRuvU8X/wXPhVVmgI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ucw.cz; spf=pass smtp.mailfrom=ucw.cz; dkim=pass (1024-bit key) header.d=ucw.cz header.i=@ucw.cz header.b=AJv7n9vD; arc=none smtp.client-ip=46.255.230.98 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ucw.cz Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ucw.cz Received: by jabberwock.ucw.cz (Postfix, from userid 1017) id 916C01C0076; Wed, 7 Feb 2024 18:51:46 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ucw.cz; s=gen1; t=1707328306; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=eaGHk2OWa64/I10L/xQQJe59trrcxp4jWd9IlpfddAc=; b=AJv7n9vDjSfyeVJ2zRfFUlcvMAlJ5YlI0FUBCziNAg2SKhPXoBMIEiemllfSOK6zjhP+l/ gNRZbnVdDpziFPHSXZzflNXhpNbPNqTw/bUXOXvsJUt/CH5Xb7W9heD7rAJgyTIZ/gL3eM yigL4XjNp7M0VPjFJmMmk0bsLTqHIc0= Date: Wed, 7 Feb 2024 18:51:45 +0100 From: Pavel Machek To: Justin Stitt Cc: Kees Cook , Andy Shevchenko , Rasmus Villemoes , linux-hardening@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [RFC] string: Allow 2-argument strscpy() Message-ID: References: <20240129202901.work.282-kees@kernel.org> <20240129215525.4uxchtrywzzsrauc@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="eLOfAe0GFtq5q4sl" Content-Disposition: inline In-Reply-To: <20240129215525.4uxchtrywzzsrauc@google.com> --eLOfAe0GFtq5q4sl Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hi! > > Using sizeof(dst) is the overwhelmingly common case for strscpy(). > > Instead of requiring this everywhere, allow a 2-argument version to be > > used that will use the sizeof() internally. >=20 > Yeah, this is definitely the case. I have a ton of patches replacing > strncpy with strscpy [1] and many of them match the pattern of: > | strscpy(dest, src, sizeof(dest)) >=20 > BTW, this hack for function overloading is insane. Never really looked in= to > it before. This hack is insane, but this is also highly confusing, please don't do this. BR, Pavel --=20 People of Russia, stop Putin before his war on Ukraine escalates. --eLOfAe0GFtq5q4sl Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iF0EABECAB0WIQRPfPO7r0eAhk010v0w5/Bqldv68gUCZcPDMQAKCRAw5/Bqldv6 8l3TAJ9JeO899iqkl6Ymsyx096x6S41JLQCdE2n2yCsojfhW1w17jM7QJNEtg/c= =8PgS -----END PGP SIGNATURE----- --eLOfAe0GFtq5q4sl--