From: Kees Cook <keescook@chromium.org>
To: Muhammad Usama Anjum <usama.anjum@collabora.com>
Cc: Eric Biederman <ebiederm@xmission.com>,
Shuah Khan <shuah@kernel.org>, Mark Brown <broonie@kernel.org>,
linux-mm@kvack.org, linux-kernel@vger.kernel.org,
linux-kselftest@vger.kernel.org,
"kernel@collabora.com" <kernel@collabora.com>
Subject: Re: [Test Failure Report] exec: Test failures in execveat
Date: Tue, 5 Mar 2024 13:00:58 -0800 [thread overview]
Message-ID: <202403051256.7A50FE28E7@keescook> (raw)
In-Reply-To: <02c8bf8e-1934-44ab-a886-e065b37366a7@collabora.com>
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
next prev parent reply other threads:[~2024-03-05 21:01 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-05 14:20 Muhammad Usama Anjum
2024-03-05 21:00 ` Kees Cook [this message]
2024-03-07 9:22 ` Muhammad Usama Anjum
2024-03-07 20:39 ` Kees Cook
2024-03-11 17:08 ` Muhammad Usama Anjum
2024-03-13 5:23 ` Kees Cook
2024-03-14 3:05 ` Kees Cook
2024-03-14 8:49 ` Muhammad Usama Anjum
2024-03-19 11:17 Khannanov Lenar
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=202403051256.7A50FE28E7@keescook \
--to=keescook@chromium.org \
--cc=broonie@kernel.org \
--cc=ebiederm@xmission.com \
--cc=kernel@collabora.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=shuah@kernel.org \
--cc=usama.anjum@collabora.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox