]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
core,seccomp: refuse to specify errno for allow-listed syscalls
authorYu Watanabe <watanabe.yu+github@gmail.com>
Mon, 8 Mar 2021 02:57:59 +0000 (11:57 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Mon, 8 Mar 2021 12:28:38 +0000 (21:28 +0900)
src/core/dbus-execute.c
src/core/load-fragment.c
src/shared/seccomp-util.c

index 399986db4a441f4dcf3c7365df1cf9d14551dfa5..4a1585f663313d3025f1ebb87e12606ca80ccb73 100644 (file)
@@ -2252,6 +2252,9 @@ int bus_exec_context_set_transient_property(
                                 if (r < 0)
                                         return r;
 
+                                if (allow_list && e >= 0)
+                                        return -EINVAL;
+
                                 r = seccomp_parse_syscall_filter(n,
                                                                  e,
                                                                  c->syscall_filter,
index 41ee7b643805ce792a9795780b0595723272bc03..c6fc4fe083f989f74956979430c0ee69f2bf1222 100644 (file)
@@ -3209,13 +3209,20 @@ int config_parse_syscall_filter(
                 if (r == -ENOMEM)
                         return log_oom();
                 if (r < 0) {
-                        log_syntax(unit, LOG_WARNING, filename, line, r, "Invalid syntax, ignoring: %s", rvalue);
+                        log_syntax(unit, LOG_WARNING, filename, line, r,
+                                   "Invalid syntax, ignoring: %s", rvalue);
                         return 0;
                 }
 
                 r = parse_syscall_and_errno(word, &name, &num);
                 if (r < 0) {
-                        log_syntax(unit, LOG_WARNING, filename, line, r, "Failed to parse syscall:errno, ignoring: %s", word);
+                        log_syntax(unit, LOG_WARNING, filename, line, r,
+                                   "Failed to parse syscall:errno, ignoring: %s", word);
+                        continue;
+                }
+                if (!invert && num >= 0) {
+                        log_syntax(unit, LOG_WARNING, filename, line, 0,
+                                   "Allow-listed system calls cannot take error number, ignoring: %s", word);
                         continue;
                 }
 
index 009992cfbfc2a739d0f146c7aeb173fe7ab0f3f8..3354f7bc087b472981b0ae7a579a4c03ef0ceb7a 100644 (file)
@@ -1135,6 +1135,9 @@ int seccomp_parse_syscall_filter(
         assert(name);
         assert(filter);
 
+        if (!FLAGS_SET(flags, SECCOMP_PARSE_INVERT) && errno_num >= 0)
+                return -EINVAL;
+
         if (name[0] == '@') {
                 const SyscallFilterSet *set;
                 const char *i;