linux/tools/testing/selftests/exec
Kees Cook 1710742994 selftests/exec: Perform script checks with /bin/bash
It seems some shells linked to /bin/sh don't have consistent behavior
with error codes on execution failures. Explicitly use /bin/bash so that
"not found" errors are correctly generated. Repeating the comment from
the test:

/*
 * 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.
 */

Reported-by: Muhammad Usama Anjum <usama.anjum@collabora.com>
Closes: https://lore.kernel.org/lkml/02c8bf8e-1934-44ab-a886-e065b37366a7@collabora.com/
Signed-off-by: Kees Cook <keescook@chromium.org>
---
Cc: Eric Biederman <ebiederm@xmission.com>
Cc: Shuah Khan <shuah@kernel.org>
Cc: Mark Brown <broonie@kernel.org>
Cc: linux-mm@kvack.org
Cc: linux-kselftest@vger.kernel.org
2024-03-05 16:06:01 -08:00
..
.gitignore selftests/exec: add generated files to .gitignore 2022-03-03 15:17:04 -07:00
binfmt_script.py selftests/exec: Rename file binfmt_script to binfmt_script.py 2022-02-23 17:25:29 -07:00
execveat.c selftests/exec: Perform script checks with /bin/bash 2024-03-05 16:06:01 -08:00
load_address.c tools/testing/selftests: add self-test for verifying load alignment 2020-10-16 11:11:21 -07:00
Makefile linux-kselftest-next-5.18-rc1 2022-03-23 12:53:00 -07:00
non-regular.c selftests/exec: add file type errno tests 2020-08-14 19:56:56 -07:00
null-argv.c selftests/exec: Test for empty string on NULL argv 2022-03-01 16:16:27 -08:00
recursion-depth.c exec selftests: test ->recursion_depth 2019-05-14 19:52:50 -07:00