From patchwork Wed Oct 11 14:11:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rik van Riel X-Patchwork-Id: 151444 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2908:b0:403:3b70:6f57 with SMTP id ib8csp569290vqb; Wed, 11 Oct 2023 07:12:15 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHuxw7iNvYFc3i1cCt9o1JHmZMRMLeTn8nn/1jGYzoBkLs/v0ZZN4Bh9YfrsC3Pfje3aXyy X-Received: by 2002:a05:6e02:5ce:b0:34f:a4f0:4fc4 with SMTP id l14-20020a056e0205ce00b0034fa4f04fc4mr20881684ils.2.1697033535216; Wed, 11 Oct 2023 07:12:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697033535; cv=none; d=google.com; s=arc-20160816; b=hjoNGdzLi3UGUqwJ3bBtQ6flDFw5OUpoLIJShQsUd4/TKLRQSbvyKqHwUhuX+DLXSI KM5x9qhGxSqrIxHq943vhXAjSK9SNRDwTb3BBkko1JcFi6egRbOIWotipZenFfXUCDa1 HenbVnktYp3regHSfGBlRwKXeYXcawIMzBc8Nx8kMYaTCaY87WtaEDo3w6Tf66EweKQU ApeUcKce03J3vaSttO2B7BVkTHZ5GtT0X4DvhbRXiWRn2TPThZqXjminEzBo3VFFDKzy GfT1KFwIxIEO1BsoEFuW+24cDUZn8wad84+RoAAMQMQReP5gpPaH/ewYpao88A4Yr42t 4+Og== 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=EEXYnPhszhtrxRcAa0qWRiMZeIJE5Y+LsmZGqghFh6g=; fh=Uxb8CmDRNETOOABXu/reqwMbtOmB6epPbc1mQgATnvM=; b=I2JOmmxXIcKNS1FgQa/ve7dVElg8TwwwkCmVz8AmAXKhYH/7SnJlLlN6EoaYPoUOYJ P26uC/oHtjbMsiLm/FvNpXBkgWsbXckm+wDVf48lPpM6uFdxDWlZYrOqrDkb3RR8h7UQ z7+P7Ou5xH+woYHli9KvnxOcRhsSGcvIB5sCl8ZiacjxcWkvROCjWQGiDQsyTn3WpfKs jLCAkNtdFCYyB6vVi04KTw1t4uarc8zI+MhY44S2pFfk8j7qF9Z3fHYTuf09ZPoGtINr 4XWmLsgp0SGxUmE3Ndn4PVfdyZJQBFRpkpV13kx+OX5U5cJC1wucUyw47iGwseaWVF30 Fl2Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id k67-20020a633d46000000b005a1d8815fefsi290058pga.187.2023.10.11.07.12.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Oct 2023 07:12:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 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 groat.vger.email (Postfix) with ESMTP id 130E080725E1; Wed, 11 Oct 2023 07:12:13 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232504AbjJKOL6 (ORCPT + 18 others); Wed, 11 Oct 2023 10:11:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53034 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232125AbjJKOL5 (ORCPT ); Wed, 11 Oct 2023 10:11:57 -0400 Received: from shelob.surriel.com (shelob.surriel.com [96.67.55.147]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9F2F294; Wed, 11 Oct 2023 07:11:55 -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 1qqZw2-0003Dg-2T; Wed, 11 Oct 2023 10:11:38 -0400 Date: Wed, 11 Oct 2023 10:11:34 -0400 From: Rik van Riel To: Alejandro Colomar Cc: linux-man@vger.kernel.org, kernel-team@meta.com, LKML , Eric Biederman , Matthew House Subject: [PATCH v2] execve.2: execve also returns E2BIG if a string is too long Message-ID: <20231011101134.709b8089@imladris.surriel.com> X-Mailer: Claws Mail 4.1.1 (GTK 3.24.38; x86_64-redhat-linux-gnu) MIME-Version: 1.0 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 groat.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 (groat.vger.email [0.0.0.0]); Wed, 11 Oct 2023 07:12:13 -0700 (PDT) X-Spam-Level: ** X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1779468636374485856 X-GMAIL-MSGID: 1779468636374485856 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. 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