LSM: SafeSetID: fix userns bug in selftest
authorMicah Morton <mortonm@chromium.org>
Wed, 15 Jun 2022 21:19:06 +0000 (21:19 +0000)
committerMicah Morton <mortonm@chromium.org>
Fri, 15 Jul 2022 17:35:34 +0000 (17:35 +0000)
Not sure how this bug got in here but its been there since the original
merge. I think I tested the code on a system that wouldn't let me
clone() with CLONE_NEWUSER flag set so had to comment out these
test_userns invocations.

Trying to map UID 0 inside the userns to UID 0 outside will never work,
even with CAP_SETUID. The code is supposed to test whether we can map
UID 0 in the userns to the UID of the parent process (the one with
CAP_SETUID that is writing the /proc/[pid]/uid_map file).

Signed-off-by: Micah Morton <mortonm@chromium.org>
tools/testing/selftests/safesetid/safesetid-test.c

index 4b809c9..111dcbc 100644 (file)
@@ -194,7 +194,7 @@ static bool test_userns(bool expect_success)
                        printf("preparing file name string failed");
                        return false;
                }
-               success = write_file(map_file_name, "0 0 1", uid);
+               success = write_file(map_file_name, "0 %d 1", uid);
                return success == expect_success;
        }