Message ID | 20231011124301.4d93ea72@imladris.surriel.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2908:b0:403:3b70:6f57 with SMTP id ib8csp672004vqb; Wed, 11 Oct 2023 09:43:45 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH9uz6gknt1AOacjaqLNysZerd4XKvGXmcsX530DFdWE16OJP9+Tsm5/Echz4FhZkutuhBr X-Received: by 2002:a92:d9c4:0:b0:349:4e1f:e9a0 with SMTP id n4-20020a92d9c4000000b003494e1fe9a0mr21313491ilq.2.1697042625560; Wed, 11 Oct 2023 09:43:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697042625; cv=none; d=google.com; s=arc-20160816; b=L+XczjBTZJY0iObiVCRqha6x8Q/xvnb18AKkIGe5ONkuT2fTCML61m4TZjSO1q3+6b GbsFPe02gpPZv6+YNbSvgmhpMQ+2EC4Mc9x5JZP3+Yppu+t6PlJ1CGjH37KeWo2xfhM2 wv5kvd4TpfT1pgwH8ZXjVkMxRORQE4Bfiag4bk7jBSBeN5ItEi8YAYPDQJY5XPzF7mtM vtzT3PrMEIxhmF7waHChUnwbjjtQIfPL75D2M2ZvN3UibGuKlpA4Gb2pi8sV4CWGR9bq kejBX6Ssz0cKnAzfISGSlbOZWwYmAsME9S3rzLhU2V/QYlTXSViQq0C0IsGBsLCZR9Wr iYfw== 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 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from howler.vger.email (howler.vger.email. [2620:137:e000::3:4]) by mx.google.com with ESMTPS id n11-20020a63ee4b000000b005859c874eb7si128865pgk.701.2023.10.11.09.43.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Oct 2023 09:43:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) client-ip=2620:137:e000::3:4; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 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 howler.vger.email (Postfix) with ESMTP id 6890680E227D; Wed, 11 Oct 2023 09:43:43 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346959AbjJKQnc (ORCPT <rfc822;kartikey406@gmail.com> + 18 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 <rfc822;linux-kernel@vger.kernel.org>); 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 <riel@shelob.surriel.com>) 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 <riel@surriel.com> To: Alejandro Colomar <alx@kernel.org> Cc: linux-man@vger.kernel.org, kernel-team@meta.com, linux-kernel@vger.kernel.org, Matthew House <mattlloydhouse@gmail.com>, Eric Biederman <ebiederm@xmission.com> 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=2.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, 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 howler.vger.email Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Wed, 11 Oct 2023 09:43:43 -0700 (PDT) X-Spam-Level: ** X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1779478167987928633 X-GMAIL-MSGID: 1779478167987928633 |
Series |
[v3] execve.2: execve also returns E2BIG if a string is too long
|
|
Commit Message
Rik van Riel
Oct. 11, 2023, 4:43 p.m. UTC
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 <riel@surriel.com>
Suggested-by: Matthew House <mattlloydhouse@gmail.com>
---
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