Received: by 2002:a05:7412:bbc7:b0:fc:a2b0:25d7 with SMTP id kh7csp484790rdb; Thu, 1 Feb 2024 14:43:49 -0800 (PST) X-Google-Smtp-Source: AGHT+IFto0IU4JzHrSZgwWdxt572GkXn5Yb4fEY7jnJgeMYBljmnWRZZtRE7drmelGXR/xouyqqs X-Received: by 2002:a05:6a20:3613:b0:199:3b3f:25d8 with SMTP id r19-20020a056a20361300b001993b3f25d8mr5665853pze.61.1706827429651; Thu, 01 Feb 2024 14:43:49 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706827429; cv=pass; d=google.com; s=arc-20160816; b=elW/O1zC4Mnpq3jI2W9Gx1yskvC2Hn61gr5JSau4piM9Io8qP7FxZIhOYWFMpsBc52 ztkvRtWmWZKhwLAST+gttpCLtQMWrZR+dRaptdVZuDJL7QlOATwN1sxiN4qEWRNsaWBt +8JlNdbw4W2xWNaekmvS/343xFi18XhPszx1pB3XuLyBBcQ5zD8mHvpffpPeNPDRoyc1 a6Y9kF4I7UFsX6rK1vvljY1s1kkKGS/O/4FI1Vw+YIDPZudzFISfNUfZqHe6y2zyAzj+ xfp/zJ4iFFsqObKX/5LuikdzdK+5KkqWZIlPjM4fOUzt/hL3yBlx1wy0tgNcqRk8Gb6c wdQA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:content-language:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:accept-language :in-reply-to:references:message-id:date:thread-index:thread-topic :subject:cc:to:from; bh=+FEiqruD2PhiHiOREenoir18YObY1XMyZp7vO4EV3A4=; fh=HV4DC1m3FkzUpNvcgjFE/wpsos7r+u/LGV6HlUKx3Ow=; b=VEElWLDZB7JlzSPv6jBhMWJuzH8vu18JJvuhQVTCm6s6u87LCUgISR/49XrSMQhlh1 9VqYIPKp/rKuESWOkWW11PtIp8dgFCRixogysYNHKrK5rRVNpw/gHw/o6k9ENMANFQSZ K3m/ubo7wpP4aIXo5kJbxyk+hIKUbxylNYOuJ8t/EuDnLL8ARoKKmKKHn+Il9DkXjexk 7C0/Ih7CgDAlQl2jEVBAC85mc1wTnMS/U5KtCLIFIDpIcumlPAyWDKyyG4T+SGLGuWGO KXctf5FTYjQpkVAoaosO4kZL3tiKe0R+y5gI+R7sbHJJNfcidA8Smh7SQPgBXXXKfkty Z1XQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=aculab.com dmarc=pass fromdomain=aculab.com); spf=pass (google.com: domain of linux-kernel+bounces-48943-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-48943-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=aculab.com X-Forwarded-Encrypted: i=1; AJvYcCWy5OiJhuvmuMBdf+haSQTHFC2zMCeusOPLzHm2nG6fyC7HO7jnpbtlUntoP6vuEq6BVrzLI1g63U4vQiRZmynUi/DT1wRxZdZDDJxPYQ== Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id g8-20020aa79f08000000b006ddc1bf70ecsi389079pfr.34.2024.02.01.14.43.49 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Feb 2024 14:43:49 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-48943-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=aculab.com dmarc=pass fromdomain=aculab.com); spf=pass (google.com: domain of linux-kernel+bounces-48943-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-48943-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=aculab.com 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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 91C63B219E2 for ; Thu, 1 Feb 2024 22:30:13 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id DCA8240BF4; Thu, 1 Feb 2024 22:30:07 +0000 (UTC) Received: from eu-smtp-delivery-151.mimecast.com (eu-smtp-delivery-151.mimecast.com [185.58.85.151]) (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 9261E405F7 for ; Thu, 1 Feb 2024 22:30:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.58.85.151 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706826607; cv=none; b=tFAxmvP8xFCaLqvGutV9KEBD5IGwH2+K4269A8dBpPfjBzH4OlBWA/tU53H0HbVKu6GknXOwFKKCHp2nGjNqZTdfT/54TrHq3TvvKD2/NprnjzCoCeAE9BS1CTOq586XVaFTyuLudMZOwUgr76xQQulllXOYUhU56vCMrfw2Efk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706826607; c=relaxed/simple; bh=+FEiqruD2PhiHiOREenoir18YObY1XMyZp7vO4EV3A4=; h=From:To:CC:Subject:Date:Message-ID:References:In-Reply-To: MIME-Version:Content-Type; b=DQ/f5SF3cojBYHczX8sNDbffS3at6IYkNC/08bezSiG+eyMuOQePEdDJHhBPZfluZVTry4ZvZ0KYyVlnDbrgNTuydEOwiK14lMnbAcdqPKovtfqpy8+5LpvxxpehETeHAPNwZ5DXAhTO8gBkxd4lKCmdDaEzhHWFVZ0ILo1j+Nk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ACULAB.COM; spf=pass smtp.mailfrom=aculab.com; arc=none smtp.client-ip=185.58.85.151 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ACULAB.COM Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=aculab.com Received: from AcuMS.aculab.com (156.67.243.121 [156.67.243.121]) by relay.mimecast.com with ESMTP with both STARTTLS and AUTH (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id uk-mta-92-6SPxv_cpN_qKS1Gtzru5yA-1; Thu, 01 Feb 2024 22:29:54 +0000 X-MC-Unique: 6SPxv_cpN_qKS1Gtzru5yA-1 Received: from AcuMS.Aculab.com (10.202.163.6) by AcuMS.aculab.com (10.202.163.6) with Microsoft SMTP Server (TLS) id 15.0.1497.48; Thu, 1 Feb 2024 22:29:37 +0000 Received: from AcuMS.Aculab.com ([::1]) by AcuMS.aculab.com ([::1]) with mapi id 15.00.1497.048; Thu, 1 Feb 2024 22:29:37 +0000 From: David Laight To: 'Kees Cook' , Andy Shevchenko , Rasmus Villemoes CC: "linux-hardening@vger.kernel.org" , "linux-kernel@vger.kernel.org" Subject: RE: [RFC] string: Allow 2-argument strscpy() Thread-Topic: [RFC] string: Allow 2-argument strscpy() Thread-Index: AQHaUvHLFgl6ZJLHe0apLw7TCgOYwbD2FRpA Date: Thu, 1 Feb 2024 22:29:37 +0000 Message-ID: <9dae4c62fc164abeaa7915f9e53fdb28@AcuMS.aculab.com> References: <20240129202901.work.282-kees@kernel.org> In-Reply-To: <20240129202901.work.282-kees@kernel.org> Accept-Language: en-GB, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-transport-fromentityheader: Hosted Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: aculab.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable From: Kees Cook > Sent: 29 January 2024 20:29 >=20 > 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. You may want to (try to) add a check that the first argument is actually an array rather than just a pointer. But the cpp output bloat can get silly and slow the build down. I guess no one would do: =09x =3D min(strscpy(a, b), strscpy(c, d)); but you can never tell :-) =09David - Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1= PT, UK Registration No: 1397386 (Wales)