[LibOS] No input validation is done for flag parameter in fchownat syscall
Description of the problem
Incorrect input is given for flag parameter which is caught in Linux native but not in Graphene native which result in passing of the testcase mentioned. TestFile:- fchownat01_run TestResult: 4 subtest PASS and 1 subtest FAIL TestCase: {-1, EINVAL, 9999, &dir_fd, TESTFILE_1} TestSummary: 1 TPASS : fchownat() returned the expected errno 0: Success: TEST_ERRNO=SUCCESS(0): Success 2 TPASS : fchownat() returned the expected errno -1: Not a directory: TEST_ERRNO=ENOTDIR(20): Not a directory 3 TPASS : fchownat() returned the expected errno -1: Bad file descriptor: TEST_ERRNO=EBADF(9): Bad file descriptor 4 TFAIL : fchownat() returned 0, expected -1, errno=22: TEST_ERRNO=SUCCESS(0): Success 5 TPASS : fchownat() returned the expected errno 0: Success: TEST_ERRNO=SUCCESS(0): Success
Steps to reproduce
To repro this issue, run fchownat01_setup in linux native and fchownat01_run in Graphene environment fchownat01.zip
Expected results
TPASS : fchownat() returned the expected errno -1: Invalid argument: TEST_ERRNO=EINVAL(22): Invalid argument
Actual results
TFAIL : fchownat() returned 0, expected -1, errno=22: TEST_ERRNO=SUCCESS(0): Success
Retested with release 1.2rc1 and issue is still reproducible
fchownat() implementation in Graphene does some checks (but doesn't care about flags, uid, gid) and then doesn't perform any "change ownership" logic but simply returns success:
https://github.com/oscarlab/graphene/blob/f1a9c785128522ae4abc604a7ae10f4d4e7f0573/LibOS/shim/src/sys/shim_file.c#L239
Technically, Graphene doesn't support permissions/ownership of files so must return ENOSYS. Returning success is widely misleading.