[4/4] tst-personality.c: Handle personality failing with errno EPERM
Checks
Context |
Check |
Description |
dj/TryBot-apply_patch |
success
|
Patch applied to master at the time it was sent
|
dj/TryBot-32bit |
success
|
Build for i686
|
Commit Message
When running under a systemd service with LockPersonality set or
in a container with a personality seccomp filter the personality
syscall might fail with errno EPERM for some personality calls
so that the kernel execution domain can not be changed from the
default. Return 77 (to indicate the test is unsupported) in that
case.
---
sysdeps/unix/sysv/linux/tst-personality.c | 37 ++++++++++++++++++++---
1 file changed, 32 insertions(+), 5 deletions(-)
@@ -30,13 +30,40 @@ do_test (void)
errno = 0xdefaced;
saved_persona = personality (0xffffffff);
- if (personality (test_persona) != saved_persona
- || personality (0xffffffff) == -1
- || personality (PER_LINUX) == -1
- || personality (0xffffffff) != PER_LINUX
- || 0xdefaced != errno)
+ if (saved_persona == -1 && errno == EPERM)
+ return 77;
+
+ if (personality (test_persona) != saved_persona)
+ {
+ if (errno == EPERM)
+ {
+ rc = 77;
+ goto out;
+ }
+ else
+ rc = 1;
+ }
+
+ if (personality (0xffffffff) == -1)
+ rc = 1;
+
+ if (personality (PER_LINUX) == -1)
+ {
+ if (errno == EPERM)
+ {
+ rc = 77;
+ goto out;
+ }
+ rc = 1;
+ }
+
+ if (personality (0xffffffff) != PER_LINUX)
+ rc = 1;
+
+ if (0xdefaced != errno)
rc = 1;
+out:
(void) personality (saved_persona);
return rc;
}