Re: [Test Failure Report] exec: Test failures in execveat

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 3/6/24 2:00 AM, Kees Cook wrote:
> 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?
I've tested this patch. Still getting same failures.

> 
> Thanks for the report!
> 
> -Kees
> 

-- 
BR,
Muhammad Usama Anjum




[Index of Archives]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Device Mapper]

  Powered by Linux