Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp716504rdg; Wed, 11 Oct 2023 03:41:46 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG7fDp1aTxqA6WTXhYxYcS5F+gNOEiKN5lK1m9iOSyxvl3vY32rSNtzrrHwhijDT0F9cAPb X-Received: by 2002:a05:6a00:a18:b0:693:3e55:59b4 with SMTP id p24-20020a056a000a1800b006933e5559b4mr18243343pfh.8.1697020905537; Wed, 11 Oct 2023 03:41:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697020905; cv=none; d=google.com; s=arc-20160816; b=DfUwp/bpcXE6Wm8ujGUo9JtuHd67D86W/Z1DSp5v2Pkiyh7Wku8Y/FEZDRPCRUz4AG pLP5hjsUcd//KZrTmi2NaMhm8ZfxPrlzTxs24UYxDrSJg8labtn1Yx8KyO6r2FImmeYM Jzjd6UPHfp42IYl9zPCEnf/8JRhNT4RuHpy9vh0lIRQ3lW3RcEbF02OlBEJP5W1F9wz1 jaYJFd5vVVgLTjGF5oRf97mtMJPuyQvlWd20vbr2eMtyCx3W3Fcy18bCUDyArXQnbbIq lUzlqI2doJsOLicJRU0UtD+etpZA8cmQB3i1ozLeNtt9HvyEas1XnL0TPPxwLVzyXcLR 3akA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=tA2uHC+cejpWKZTpGwMyZc2cssFjHQG+5JjdPWJtxDw=; fh=rG9eSrbSkCVabs6/dtJBuKq1RO7qF4yI7LD6AQHKj+E=; b=ZAzhTYlYiFQg2XKNhyCa2w6qZrnh2frMPKSA3RxKMEKhnJFIp3s6cwtKu8PfsMykua ZK/q9+anXG3HNJqLJpLIclDGF6eDbSGIAMIqXF2FKB5vbK+1nQE7qQGfo6QhGEzQx2Tp ufgPWHy+crX3cjcr2FSJrorbINQXJ3ZefqZ8GW4EeJnYaXdQtPUogmpW2X4Y1vuXtj+i 7afoB4r5JlostdYfaPllzLvgdbAe+wmKUDL5N1oz9ePBtUOUfzTq6wRGKb4wKxMYcj4j 5tLO8agNijHTM2LB8ljorpT7ieZCGYtsA9+ia5KRHCpPRD4AwiF0wVQOpgr7Fgr5lg+t q6Lw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=TqeuOLMx; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from morse.vger.email (morse.vger.email. [23.128.96.31]) by mx.google.com with ESMTPS id s22-20020a056a00195600b00690da05391fsi12454528pfk.255.2023.10.11.03.41.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Oct 2023 03:41:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) client-ip=23.128.96.31; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=TqeuOLMx; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id ACCE98079ADC; Wed, 11 Oct 2023 03:41:41 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234819AbjJKKlV (ORCPT + 99 others); Wed, 11 Oct 2023 06:41:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40154 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234810AbjJKKlT (ORCPT ); Wed, 11 Oct 2023 06:41:19 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A076FBA; Wed, 11 Oct 2023 03:41:17 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1BECEC433C7; Wed, 11 Oct 2023 10:41:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1697020877; bh=anlzUPl7ZpZUKXtz2bt3SGpGSz5+2RISrv6OvPdB5VM=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=TqeuOLMx4e1yNDzaxqpQm0RlWgrkKGCg3FPPuJ7chlHlfgONlgqxysH/VcSait1I+ En6ItSF6hsZN0B9iCwOe8Szwy8spTC2yBOCUGBKS4RGyrOAhmx8M4wHNsm+Rs4uvYq jHXnBZXqQZ1dUlFc7QzAdxdQiqqNk+U58DqEoMXfT9yynAK3+jw80vXlWYLLNJDJ9c /WmsCuJUQ6Yll3vqUvitMKtIp7mINQ64WK5V+RGkxWnTP//3YWjTKXeWw4B3gcI0z9 s0/o5p0PGPemUkU5r3lwsMJL3rFwfyuYKqdqwTZMS2Yb2zZMb29MTAMElpn/1P+796 GDsUc1j3KS75A== Date: Wed, 11 Oct 2023 12:41:13 +0200 From: Alejandro Colomar To: Rik van Riel Cc: linux-man@vger.kernel.org, LKML , kernel-team@meta.com, Eric Biederman Subject: Re: [PATCH] execve.2: execve also returns E2BIG if a string is too long Message-ID: References: <20231010234153.021826b1@imladris.surriel.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="ZwlcAQNhET8ZExSa" Content-Disposition: inline In-Reply-To: <20231010234153.021826b1@imladris.surriel.com> X-Spam-Status: No, score=2.4 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (morse.vger.email [0.0.0.0]); Wed, 11 Oct 2023 03:41:41 -0700 (PDT) X-Spam-Level: ** --ZwlcAQNhET8ZExSa Content-Type: text/plain; protected-headers=v1; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Date: Wed, 11 Oct 2023 12:41:13 +0200 From: Alejandro Colomar To: Rik van Riel Cc: linux-man@vger.kernel.org, LKML , kernel-team@meta.com, Eric Biederman Subject: Re: [PATCH] execve.2: execve also returns E2BIG if a string is too long Hi Rik, On Tue, Oct 10, 2023 at 11:41:53PM -0400, Rik van Riel wrote: > Document that if a command line or environment string is too long (> MAX_= ARG_STRLEN), execve will also return E2BIG. That's already implied by the current text: E2BIG The total number of bytes in the environment (envp) and argum= ent list (argv) is too large. That means that size_t bytes; bytes =3D 0; for (char *e =3D envp; e !=3D NULL; e++) bytes +=3D strlen(e) + 1; // I have doubts about the +1 for (char *a =3D argv; a !=3D NULL; a++) bytes +=3D strlen(a) + 1; // Same doubts if (bytes > MAX_ARG_STRLEN) // Maybe >=3D ? return -E2BIG; >=20 > Signed-off-by: Rik van Riel > --- > man2/execve.2 | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) >=20 > diff --git a/man2/execve.2 b/man2/execve.2 > index 0d9582492ad1..c1a359d01872 100644 > --- a/man2/execve.2 > +++ b/man2/execve.2 > @@ -449,7 +449,7 @@ The total number of bytes in the environment > .RI ( envp ) > and argument list > .RI ( argv ) > -is too large. > +is too large, or an argument or environment string is too long. Please use semantic newlines: $ MANWIDTH=3D72 man man-pages | sed -n '/Use semantic newlines/,/^$/p' Use semantic newlines In the source of a manual page, new sentences should be started on new lines, long sentences should be split into lines at clause breaks (commas, semicolons, colons, and so on), and long clauses should be split at phrase boundaries. This convention, sometimes known as "semantic newlines", makes it easier to see the effect of patches, which often operate at the level of in=E2=80= =90 dividual sentences, clauses, or phrases. Thanks, Alex > .TP > .B EACCES > Search permission is denied on a component of the path prefix of > --=20 > 2.41.0 >=20 >=20 --=20 --ZwlcAQNhET8ZExSa Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEE6jqH8KTroDDkXfJAnowa+77/2zIFAmUme8kACgkQnowa+77/ 2zLKiw//ZOA7Nq0uA05ugaXbCPWN/txWsn+y9oxApUHLy1RygRjiPCsRK8XhNvde AueRu+yXv+OGAbOTGCDJNJqp0smMiCParVtLGwr8hxp9l1J3GPbFBGSsTUSlXUwy y9LgkfY3ZiGT419unGJI0Mbep/koSYBl+X7kLyWQYz6I+lpFGZAFAmLj7fpqGNpq mcH1M6cTPB7ip1HdseTptBoJ3yI3JEIPPf8GF9+HdcubfVaYoXQ/qw9xRy5coh7H emgFrcu4UD1L6/WOmLenPZ6mkOSqTi1AiERZIpGtkxksJLgBZPUY3jV+bqKUuOtS M8TCwTbnM8EiPdQQlK4lE425Eymzla2vVRilY7+s6rsLKGdZRDla6Plm3Q23xxa9 2+mjAgLZURFadQIhj6GRH/0+cSUFRTDEkw7mt00RES8/9h0oTxVmpnV0+slQMqjf P5zAznodF9rcyq7s/T7MVZwJNnRUEixz+B+JfqCnoE8Id2Eh1Oo9GAyuZ6C3v28R 5m6MflH9HBtjzNUgWTm69UxdMAtPhcCp5orD6cnrlEDX4jpVRbZ0NORcbxesyxo/ n+LDCtakCJsZks6GJZOsfZqChcEjLeutzR96T8HZWiMfiKJJOOeW5lNebWHxmr9d yVdFwPWLfL4Gk8JScIO7JhVmGCnQn6UbCxam7c7AQpZFSrisIo8= =jOsU -----END PGP SIGNATURE----- --ZwlcAQNhET8ZExSa--