]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
seccomp: permit specifying multiple errnos for a syscall 9942/head
authorLucas Werkmeister <mail@lucaswerkmeister.de>
Wed, 29 Aug 2018 19:35:38 +0000 (21:35 +0200)
committerLucas Werkmeister <mail@lucaswerkmeister.de>
Fri, 7 Sep 2018 19:44:13 +0000 (21:44 +0200)
If more than one errno is specified for a syscall in SystemCallFilter=,
use the last one instead of reporting an error. This is especially
useful when used with system call sets:

    SystemCallFilter=@privileged:EPERM @reboot

This will block any system call requiring super-user capabilities with
EPERM, except for attempts to reboot the system, which will immediately
terminate the process. (@reboot is included in @privileged.)

This also effectively fixes #9939, since specifying different errnos for
“the same syscall” (same pseudo syscall number) is no longer an error.

src/shared/seccomp-util.c

index 5072ceb2d109713e3271229210ee75b06057bb38..ff3537c5e97fe513b2ec27b1da6e71d4f4d3550b 100644 (file)
@@ -1061,10 +1061,8 @@ int seccomp_parse_syscall_filter_full(
                                 case -ENOMEM:
                                         return flags & SECCOMP_PARSE_LOG ? log_oom() : -ENOMEM;
                                 case -EEXIST:
-                                        if (flags & SECCOMP_PARSE_LOG)
-                                                log_warning("System call %s already blocked with different errno: %d",
-                                                            name, PTR_TO_INT(hashmap_get(filter, INT_TO_PTR(id + 1))));
-                                        return -EINVAL;
+                                        assert_se(hashmap_update(filter, INT_TO_PTR(id + 1), INT_TO_PTR(errno_num)) == 0);
+                                        break;
                                 default:
                                         return r;
                                 }