From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 996ABC54798 for ; Tue, 5 Mar 2024 21:01:05 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 19A166B0071; Tue, 5 Mar 2024 16:01:05 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 149A36B007B; Tue, 5 Mar 2024 16:01:05 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0114C6B007D; Tue, 5 Mar 2024 16:01:04 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id E5E396B0071 for ; Tue, 5 Mar 2024 16:01:04 -0500 (EST) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id B00BF140990 for ; Tue, 5 Mar 2024 21:01:04 +0000 (UTC) X-FDA: 81864205248.03.23F8DE0 Received: from mail-pf1-f182.google.com (mail-pf1-f182.google.com [209.85.210.182]) by imf14.hostedemail.com (Postfix) with ESMTP id E631A100017 for ; Tue, 5 Mar 2024 21:01:01 +0000 (UTC) Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=chromium.org header.s=google header.b="BuAlbl/h"; spf=pass (imf14.hostedemail.com: domain of keescook@chromium.org designates 209.85.210.182 as permitted sender) smtp.mailfrom=keescook@chromium.org; dmarc=pass (policy=none) header.from=chromium.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1709672462; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=ZF432v09KlF629RNN3u5qcmSSQ2n+BPZ5TK5Cfww29c=; b=IOVt8WFcSICHKvy2l7dHITjxhUNYpHjoEo2HTcvcy9URtUu4H/mmKUJTRYTDUqUK4Xa1r3 PBCiC+nbnUGP1Cb1GsY5RDxpDh2IoKhL5BjKREsRxTfdin6LCiT4/g31JZ4W2VO4QPCLi3 8A8mF4LAi30ApHe9tmDik46y9ASyt0s= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1709672462; a=rsa-sha256; cv=none; b=8CCev77PKPdQzJuZ4CwRqI7628DEZTXcV3NFCigg5u+HxwSiG/d8zVpLujR+cWTTkyaSUT mgfnMK8gIlo9XyiVdW+K+JfgJo0tvYwxIkC38KxlvDbYmVeR7M2/vQoCPTlMknYM+M3dEY N++iUmKQnq5g2eJ0MHwTHkCv4LALssA= ARC-Authentication-Results: i=1; imf14.hostedemail.com; dkim=pass header.d=chromium.org header.s=google header.b="BuAlbl/h"; spf=pass (imf14.hostedemail.com: domain of keescook@chromium.org designates 209.85.210.182 as permitted sender) smtp.mailfrom=keescook@chromium.org; dmarc=pass (policy=none) header.from=chromium.org Received: by mail-pf1-f182.google.com with SMTP id d2e1a72fcca58-6e61851dbaeso1829612b3a.2 for ; Tue, 05 Mar 2024 13:01:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1709672461; x=1710277261; darn=kvack.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=ZF432v09KlF629RNN3u5qcmSSQ2n+BPZ5TK5Cfww29c=; b=BuAlbl/hAUYctqnoWWwUzOgKMele8WmK2Ft9mW8iuIvSMmpWmdCp+BrMjq9FqxnLPx aMu+0oejQUdAp9N3v+1m3qVu1Rs3JIX2dqXMUL9/yGeJ1a6RSL31zY07UYaWKrLQN53g 7sXqPDx2BqvgIPfnlRpAD/w7AQQ7c65Qf31fI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709672461; x=1710277261; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=ZF432v09KlF629RNN3u5qcmSSQ2n+BPZ5TK5Cfww29c=; b=XNDGApBpuAtikPAxC5yneGFdblavTWhR12PUNg6hVEhMfr/pvj6zaApeLlSozKGk+8 MN/itrUyz4wzueRhkEZc/+KE+BXS5ZAsiLxclpNUqaiO76eMGN1mBxfFBO56fAAGASG1 GiNtYKAfAPJpCAD8SaBypBiCVBg3kV2TXJGi7n9Boazy8NXsnrx2qdbF5XyyKdOWGA02 P+Xy2dJGqgMaMSO8eC/aWSEJT8o0T/O76mQc1nOwHGaCIwL/I/l+rfkBgthIwdNmzamx iAJ9pRDdjOjZBgh/eNZRHG4p6Ig2lD9sftmxF61ADkFhEPI0YthalVPKBuGRax5G7R/n 7mvQ== X-Forwarded-Encrypted: i=1; AJvYcCXUWUeOEQE+x3POQLxkCCBky/DfrGs69wjIwxhl7NtnVj7x4/msn6tKiA0qIRK0kE8QmlUNOiJ/VWbeJBfRjOSD5lc= X-Gm-Message-State: AOJu0YzQhMDOeTqERc8QrCQeP2F2aqJg6ouBRXO3bQ5h0IW3OW5vPMuV /Q2ULeqLT1CAaFMaZ9rJop7nQfwcnvYoppTpNkdAX1VqHmTT3klbHBNSIdwFQA== X-Google-Smtp-Source: AGHT+IFgU6Ny/h5rqcqqC1Dq853UHL6pR3leCjAfvblgUgL0FZjcQ559bVzwVH8cdJcz3mW5XsbNzQ== X-Received: by 2002:a05:6a00:3d10:b0:6e5:a009:9eb4 with SMTP id lo16-20020a056a003d1000b006e5a0099eb4mr15506921pfb.0.1709672459215; Tue, 05 Mar 2024 13:00:59 -0800 (PST) Received: from www.outflux.net ([198.0.35.241]) by smtp.gmail.com with ESMTPSA id r5-20020aa79885000000b006e530aca55asm9416426pfl.123.2024.03.05.13.00.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Mar 2024 13:00:58 -0800 (PST) Date: Tue, 5 Mar 2024 13:00:58 -0800 From: Kees Cook To: Muhammad Usama Anjum Cc: Eric Biederman , Shuah Khan , Mark Brown , linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, "kernel@collabora.com" Subject: Re: [Test Failure Report] exec: Test failures in execveat Message-ID: <202403051256.7A50FE28E7@keescook> References: <02c8bf8e-1934-44ab-a886-e065b37366a7@collabora.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <02c8bf8e-1934-44ab-a886-e065b37366a7@collabora.com> X-Stat-Signature: p9of81h53mzqg6yfctfi4ajo78rw4oxr X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: E631A100017 X-Rspam-User: X-HE-Tag: 1709672461-513072 X-HE-Meta: U2FsdGVkX19cVQVF4PMc3YCPPcTHvTGsRcCyRDrOpss/Vofmb8uT2bWhxfIDPLtPwd7MjQ+w/Ez+BFh/CstqOG6ApFGgGyPuFD9QiXWbD5rR6Y7wa2JEmx5ElXok8aUwenHt+jA9KfUe2dmT/oPWPlpGeeHo+jjQMtv1ciOTQFaVEpxyyoNoWg4XaNrxhDLqDzboGpBhg4/4o8WUkoU4l/sZ8gJJcMoSXZJgHlfBXlrWaMwPxg4bTsNo0O0rZYbERjFDC1oP/ltAhjGOgepxG7AzLPLWksPRA2dkCxdn4lAEYUQQByau2m3T4stuhVKIO33K6AoWw86wOQjczFOmD3aujYeoST1Os9QoKgCDZeHmCeTNGA4oIfsZ70Jd77nx14eY0ifn5HUrEYs5lwQuRP3OIWANeLw0971+dWST+LArLQGMKDT9hOq1V3Te1EPSla9OLOXthOM9Yuh3qOxcI2uGyBkQZEq/KMONfFwWPnrQ3HVvk0POiAI7lfgZP7LljDa1x+yKNckY26C410wqC2ZyyeiUitHpEhZVCQCerMQFeZM0ImtRAGmJOjm8xdXkHtgmYDlva0Cvjv4Dm/fAW3CB9hi323Q6iZVVmZyjEsi41XIp9EUlY9MhmODtZVPF1aUs/IkSTfjVcPXMgRt0iSeAzr00cR2vGJLVYqupJ/j/5zqukq3NNm3FYivqIoJzeLsqpaSq102r7gf9SHVUpZTcMzUJqDw4deAgxkyYmY9sjLLScU/FtlTWeyA28XPO3ulHhIH0+boEfBL2CJjXI8nZuqaXUSxI0RSakVbwqF3fMSkXIwDIJO213mxEVYiqwC0d4m+Zt+vr0QNoJkzNvaoNHradzyEH35ePlcEw6hY8AmfZqqwG4Z1xtkzvKUP0U6YoKCXN9WthJ/uygExfZsTOA2F/vEK5o8za9fmIWlaD5fm+AHPrr849fClBy2iUz4nE30+BgvaG5gViDMG njkVIEKN JGHm1vZUkk9TBGofD/F8RzQ/o6kK3CO01FCW0gRCl8HG1dsjfbCICeooyeO+lL1pP3zeOrjOQ1yMWUZAWEcWj/8FgXtQopE2she4Y+Hoil5P5+aXrv2m3ZOLN3g== X-Bogosity: Ham, tests=bogofilter, spamicity=0.095153, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: On Tue, Mar 05, 2024 at 07:20:27PM +0500, Muhammad Usama Anjum wrote: > Hello, > > I've been running execveat (execveat.c) locally on v6.1 and next-20240228. > It has flaky test case. There are some test cases which fail consistently. > The comment (not very clear) on top of failing cases is as following: > > /* > * Execute as a long pathname relative to "/". If this is a script, > * the interpreter will launch but fail to open the script because its > * name ("/dev/fd/5/xxx....") is bigger than PATH_MAX. > * > * The failure code is usually 127 (POSIX: "If a command is not found, > * the exit status shall be 127."), but some systems give 126 (POSIX: > * "If the command name is found, but it is not an executable utility, > * the exit status shall be 126."), so allow either. > */ > The file name is just less than PATH_MAX (4096) and we are expecting the > execveat() to fail with particular 99 or 127/128 error code. But kernel is > returning 1 error code. Snippet from full output: > > # child 3493092 exited with 1 not 99 nor 99 > # child 3493094 exited with 1 not 127 nor 126 > > I'm not sure if test is wrong or the kernel has changed the return error codes. The error code is actually coming from the script interpreter (in this case, "/bin/sh"). On my system, /bin/sh is /bin/dash, and I see the failure. If I manually change "script" to use "#!/bin/bash", the test passes for me. Since lots of other selftests appears to depend on /bin/bash, I think the right fix is simply: diff --git a/tools/testing/selftests/exec/execveat.c b/tools/testing/selftests/exec/execveat.c index bf79d664c8e6..0546ca24f2b2 100644 --- a/tools/testing/selftests/exec/execveat.c +++ b/tools/testing/selftests/exec/execveat.c @@ -393,7 +393,7 @@ static int run_tests(void) static void prerequisites(void) { int fd; - const char *script = "#!/bin/sh\nexit $*\n"; + const char *script = "#!/bin/bash\nexit $*\n"; /* Create ephemeral copies of files */ exe_cp("execveat", "execveat.ephemeral"); Can you test this and let me know if this fixes it for you? Thanks for the report! -Kees -- Kees Cook