[LTP] [PATCH v2 09/13] syscalls/mount03: Copy setuid_test to execute instead of 'TEST FILE'

Punit Agrawal punit.agrawal@arm.com
Wed Nov 29 17:50:30 CET 2017


Cyril Hrubis <chrubis@suse.cz> writes:

> Hi!
>> When testing the MS_NOSUID mount flag, mount03 forgets to copy
>> setuid_test into the new filesystem. Instead it writes 'TEST FILE' into
>> a new file and attempts to execute it with S_ISUID. This fails, but not
>> for the reasons ltp expects.
>
> What is the exact error here? I guess that the file does not have
> execute bit set and that check kicks in first?

I have a feeling that we might be cross-talking on this one.

IIUC, the intention for the test is to try and execute the binary
setuid_test (built from setuid_test.c). Instead, the test creates a file
named "setuid_test" at the mount location and writes "TEST FILE" into
it.

       snprintf(file, PATH_MAX, "%ssetuid_test", path_name);
       SAFE_FILE_PRINTF(cleanup, file, "TEST FILE");

It then tries to execute this file containing the text string which
fails with the message -

/bin/sh: 0: Can't open /tmp/mouc0EQuB/mntpoint/setuid_test
mount03     6  TPASS  :  mount(2) passed with rwflag = 2

The patch copies the file setuid_test into the mounted filesystem at
which point we no longer get the "/bin/sh:" message.

>
> Anyway we really should check the errno from the exec() is EPERM which
> should have caught this problem.

I would argue that this is another problem with the test and should be
fixed in a separate patch on top.

Let me now if that makes sense. Or have I missed something?

Thanks,
Punit


More information about the ltp mailing list