Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp947416rdg; Wed, 11 Oct 2023 09:43:41 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFDuxeIIXRAaEpFzpvTtZf4dIUiDErjQ3308Ggijnrs43597Ks8ItjZQOhlIC3B0lD4VDwd X-Received: by 2002:a05:6a20:914b:b0:140:c838:2b2e with SMTP id x11-20020a056a20914b00b00140c8382b2emr22944719pzc.22.1697042621128; Wed, 11 Oct 2023 09:43:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697042621; cv=none; d=google.com; s=arc-20160816; b=pJrcrrKP049f49LeCUMmfmXtKnRKP4KB8KplmYYLsn5vIEMxhtOZ+13syWdPfmcxLs opzxaUrVO49Bevfol6mBndH3Q3u2b9SnK11LLhpKWLMxL0fuHmQd6yEXd67oCdveMfLX 7UUnqau7jHnsfCZ6Lfc4XJxqnk55uK7o0csRgyCFmY9PTggoY5y8cHMFwir3GqyTPY7m qVIvV/3GRtrSipd5PVGfGKATB0w3AxM2pPI224Sbv5G0Oqv1ORzaJ8oQA3vAU8GjsYkz r29Y4LNJUxnIBb8Wbr9S2Fx412KyXU3vfxy+un5Eu2/iexqaeYGsAHFsyfhaJdhG3wqz mR5g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:subject:cc:to:from:date; bh=jaUHsWg51XuMLN/khlO/4kcdTC8oleHQroxQFVg7hyM=; fh=HYxLO3S768M7tUNLkDARmUq/zTs37P/jEkR4H0foy4g=; b=PJ4cYw359zULLYO2k1pXDqU8ft4HU3oLgjecvYbAYoYTKlKQ8D/yFNs9kahSo8r0Ry UdKvvWbf/1twk+N069gpUt+JMci2aloq0TkJu3hH43w/2YsEqZjxTXy9KCwfLceub7kg I0Na7W2X3c+YiMosHaJJaMxZCKyeTEhcBTPs3g/CcPApZdu3EBqb42Z1tjiJzHilwQ0d 3cniBKZ6vSbLaHnt0tjrYh/yQcrSSeaPEZRFFfVzBLruNHIBRveeInDyJzMYkV1C8YXm gfU4iRVKLSOtGeW5IexyCNcQkEQ+WJJdMUKEBJZQyIaYsx3P+Va4BniNwaBu7VH1C5BD 5uvg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id z7-20020a170903018700b001bb8df95094si75378plg.509.2023.10.11.09.43.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Oct 2023 09:43:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 2B2F080E7114; Wed, 11 Oct 2023 09:43:40 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346812AbjJKQnc (ORCPT + 99 others); Wed, 11 Oct 2023 12:43:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40350 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235108AbjJKQnb (ORCPT ); Wed, 11 Oct 2023 12:43:31 -0400 Received: from shelob.surriel.com (shelob.surriel.com [96.67.55.147]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 435FA8F; Wed, 11 Oct 2023 09:43:29 -0700 (PDT) Received: from [2601:18c:9101:a8b6:6e0b:84ff:fee2:98bb] (helo=imladris.surriel.com) by shelob.surriel.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96.1) (envelope-from ) id 1qqcIb-0004RY-2Q; Wed, 11 Oct 2023 12:43:05 -0400 Date: Wed, 11 Oct 2023 12:43:01 -0400 From: Rik van Riel To: Alejandro Colomar Cc: linux-man@vger.kernel.org, kernel-team@meta.com, linux-kernel@vger.kernel.org, Matthew House , Eric Biederman Subject: [PATCH v3] execve.2: execve also returns E2BIG if a string is too long Message-ID: <20231011124301.4d93ea72@imladris.surriel.com> X-Mailer: Claws Mail 4.1.1 (GTK 3.24.38; x86_64-redhat-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: riel@surriel.com X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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 (snail.vger.email [0.0.0.0]); Wed, 11 Oct 2023 09:43:40 -0700 (PDT) The execve syscall returns -E2BIG in 3 cases: - The total length of the command line arguments and environment is too large. - An argument or environment string is longer than MAX_ARG_STRLEN. - The full path to the executable exceeds MAX_ARG_STRLEN. Spell out all 3 cases in the -E2BIG section. Discovered by moving a too large commandline parameter to an environment variable, and finding that things still did not work. Examined the code in fs/exec.c to get the details. This shell script starts failing at 2^17 on a system with 4kB page size: ./exec2big.sh: line 10: /bin/true: Argument list too long fork failed at loop 17 STRING="a" for loop in `seq 20`; do STRING="$STRING$STRING" export STRING if /bin/true ; then : # still under the limit else echo "fork failed at loop $loop" fi done Signed-off-by: Rik van Riel Suggested-by: Matthew House --- man2/execve.2 | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/man2/execve.2 b/man2/execve.2 index 0d9582492ad1..85c6ec15df3c 100644 --- a/man2/execve.2 +++ b/man2/execve.2 @@ -449,7 +449,8 @@ The total number of bytes in the environment .RI ( envp ) and argument list .RI ( argv ) -is too large. +is too large, an argument or environment string is too long, or +the full path name to the executable is too long. .TP .B EACCES Search permission is denied on a component of the path prefix of -- 2.41.0