2 * lxc: linux Container library
4 * (C) Copyright Canonical, Inc. 2012
7 * Serge Hallyn <serge.hallyn@canonical.com>
9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public
11 * License as published by the Free Software Foundation; either
12 * version 2.1 of the License, or (at your option) any later version.
14 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with this library; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
31 #include <sys/mount.h>
32 #include <sys/utsname.h>
38 #include "lxccontainer.h"
39 #include "lxcseccomp.h"
41 #include "memory_utils.h"
45 #define MIPS_ARCH_O32 lxc_seccomp_arch_mipsel
46 #define MIPS_ARCH_N64 lxc_seccomp_arch_mipsel64
48 #define MIPS_ARCH_O32 lxc_seccomp_arch_mips
49 #define MIPS_ARCH_N64 lxc_seccomp_arch_mips64
52 #ifndef SECCOMP_GET_NOTIF_SIZES
53 #define SECCOMP_GET_NOTIF_SIZES 3
56 lxc_log_define(seccomp
, lxc
);
58 #if HAVE_DECL_SECCOMP_NOTIFY_FD
59 static inline int __seccomp(unsigned int operation
, unsigned int flags
,
63 return syscall(__NR_seccomp
, operation
, flags
, args
);
71 static int parse_config_v1(FILE *f
, char *line
, size_t *line_bufsz
, struct lxc_conf
*conf
)
75 while (getline(&line
, line_bufsz
, f
) != -1) {
78 ret
= sscanf(line
, "%d", &nr
);
84 #if HAVE_SCMP_FILTER_CTX
85 ret
= seccomp_rule_add(conf
->seccomp
.seccomp_ctx
, SCMP_ACT_ALLOW
, nr
, 0);
87 ret
= seccomp_rule_add(SCMP_ACT_ALLOW
, nr
, 0);
90 ERROR("Failed loading allow rule for %d", nr
);
99 #if HAVE_DECL_SECCOMP_SYSCALL_RESOLVE_NAME_ARCH
100 static const char *get_action_name(uint32_t action
)
102 /* The upper 16 bits indicate the type of the seccomp action. */
103 switch (action
& 0xffff0000) {
110 case SCMP_ACT_ERRNO(0):
112 #if HAVE_DECL_SECCOMP_NOTIFY_FD
113 case SCMP_ACT_NOTIFY
:
118 return "invalid action";
121 static uint32_t get_v2_default_action(char *line
)
123 uint32_t ret_action
= -1;
128 /* After 'whitelist' or 'blacklist' comes default behavior. */
129 if (strncmp(line
, "kill", 4) == 0) {
130 ret_action
= SCMP_ACT_KILL
;
131 } else if (strncmp(line
, "errno", 5) == 0) {
134 ret
= sscanf(line
+ 5, "%d", &e
);
136 ERROR("Failed to parse errno value from %s", line
);
140 ret_action
= SCMP_ACT_ERRNO(e
);
141 } else if (strncmp(line
, "allow", 5) == 0) {
142 ret_action
= SCMP_ACT_ALLOW
;
143 } else if (strncmp(line
, "trap", 4) == 0) {
144 ret_action
= SCMP_ACT_TRAP
;
145 #if HAVE_DECL_SECCOMP_NOTIFY_FD
146 } else if (strncmp(line
, "notify", 6) == 0) {
147 ret_action
= SCMP_ACT_NOTIFY
;
149 } else if (line
[0]) {
150 ERROR("Unrecognized seccomp action \"%s\"", line
);
157 static uint32_t get_v2_action(char *line
, uint32_t def_action
)
162 p
= strchr(line
, ' ');
170 if (!*p
|| *p
== '#')
173 ret
= get_v2_default_action(p
);
184 struct seccomp_v2_rule_args
{
188 enum scmp_compare op
;
191 struct seccomp_v2_rule
{
194 struct seccomp_v2_rule_args args_value
[6];
197 static enum scmp_compare
parse_v2_rule_op(char *s
)
199 if (strcmp(s
, "SCMP_CMP_NE") == 0 || strcmp(s
, "!=") == 0)
201 else if (strcmp(s
, "SCMP_CMP_LT") == 0 || strcmp(s
, "<") == 0)
203 else if (strcmp(s
, "SCMP_CMP_LE") == 0 || strcmp(s
, "<=") == 0)
205 else if (strcmp(s
, "SCMP_CMP_EQ") == 0 || strcmp(s
, "==") == 0)
207 else if (strcmp(s
, "SCMP_CMP_GE") == 0 || strcmp(s
, ">=") == 0)
209 else if (strcmp(s
, "SCMP_CMP_GT") == 0 || strcmp(s
, ">") == 0)
211 else if (strcmp(s
, "SCMP_CMP_MASKED_EQ") == 0 || strcmp(s
, "&=") == 0)
212 return SCMP_CMP_MASKED_EQ
;
214 return _SCMP_CMP_MAX
;
218 * This function is used to parse the args string into the structure.
219 * args string format:[index,value,op,mask] or [index,value,op]
220 * index: the index for syscall arguments (type uint)
221 * value: the value for syscall arguments (type uint64)
222 * op: the operator for syscall arguments(string),
223 a valid list of constants as of libseccomp v2.3.2 is
224 SCMP_CMP_NE,SCMP_CMP_LE,SCMP_CMP_LE, SCMP_CMP_EQ, SCMP_CMP_GE,
225 SCMP_CMP_GT, SCMP_CMP_MASKED_EQ, or !=,<=,==,>=,>,&=
226 * mask: the mask to apply on "value" for SCMP_CMP_MASKED_EQ (type uint64, optional)
227 * Returns 0 on success, < 0 otherwise.
229 static int get_seccomp_arg_value(char *key
, struct seccomp_v2_rule_args
*rule_args
)
233 uint64_t mask
= 0, value
= 0;
234 enum scmp_compare op
= 0;
236 char s
[31] = {0}, v
[24] = {0}, m
[24] = {'0'};
238 tmp
= strchr(key
, '[');
240 ERROR("Failed to interpret args");
244 ret
= sscanf(tmp
, "[%i,%23[^,],%30[^0-9^,],%23[^,]", &index
, v
, s
, m
);
245 if ((ret
!= 3 && ret
!= 4) || index
>= 6) {
246 ERROR("Failed to interpret args value");
250 ret
= lxc_safe_uint64(v
, &value
, 0);
252 ERROR("Invalid argument value");
256 ret
= lxc_safe_uint64(m
, &mask
, 0);
258 ERROR("Invalid argument mask");
262 op
= parse_v2_rule_op(s
);
263 if (op
== _SCMP_CMP_MAX
) {
264 ERROR("Failed to interpret args operator value");
268 rule_args
->index
= index
;
269 rule_args
->value
= value
;
270 rule_args
->mask
= mask
;
275 /* This function is used to parse the seccomp rule entry.
276 * @line : seccomp rule entry string.
277 * @def_action : default action used in the case if the 'line' contain non valid action.
278 * @rules : output struct.
279 * Returns 0 on success, < 0 otherwise.
281 static int parse_v2_rules(char *line
, uint32_t def_action
,
282 struct seccomp_v2_rule
*rules
)
285 char *key
= NULL
, *saveptr
= NULL
, *tmp
= NULL
;
291 /* read optional action which follows the syscall */
292 rules
->action
= get_v2_action(tmp
, def_action
);
293 if (rules
->action
== -1) {
294 ERROR("Failed to interpret action");
301 if (!strchr(tmp
, '['))
305 for ((key
= strtok_r(tmp
, "]", &saveptr
)), i
= 0; key
&& i
< 6;
306 (key
= strtok_r(NULL
, "]", &saveptr
)), i
++) {
307 ret
= get_seccomp_arg_value(key
, &rules
->args_value
[i
]);
323 #if HAVE_DECL_SECCOMP_SYSCALL_RESOLVE_NAME_ARCH
324 enum lxc_hostarch_t
{
325 lxc_seccomp_arch_all
= 0,
326 lxc_seccomp_arch_native
,
327 lxc_seccomp_arch_i386
,
328 lxc_seccomp_arch_x32
,
329 lxc_seccomp_arch_amd64
,
330 lxc_seccomp_arch_arm
,
331 lxc_seccomp_arch_arm64
,
332 lxc_seccomp_arch_ppc64
,
333 lxc_seccomp_arch_ppc64le
,
334 lxc_seccomp_arch_ppc
,
335 lxc_seccomp_arch_mips
,
336 lxc_seccomp_arch_mips64
,
337 lxc_seccomp_arch_mips64n32
,
338 lxc_seccomp_arch_mipsel
,
339 lxc_seccomp_arch_mipsel64
,
340 lxc_seccomp_arch_mipsel64n32
,
341 lxc_seccomp_arch_s390x
,
342 lxc_seccomp_arch_unknown
= 999,
345 int get_hostarch(void)
348 if (uname(&uts
) < 0) {
349 SYSERROR("Failed to read host arch");
353 if (strcmp(uts
.machine
, "i686") == 0)
354 return lxc_seccomp_arch_i386
;
356 else if (strcmp(uts
.machine
, "x86_64") == 0)
357 return lxc_seccomp_arch_amd64
;
358 else if (strncmp(uts
.machine
, "armv7", 5) == 0)
359 return lxc_seccomp_arch_arm
;
360 else if (strncmp(uts
.machine
, "aarch64", 7) == 0)
361 return lxc_seccomp_arch_arm64
;
362 else if (strncmp(uts
.machine
, "ppc64le", 7) == 0)
363 return lxc_seccomp_arch_ppc64le
;
364 else if (strncmp(uts
.machine
, "ppc64", 5) == 0)
365 return lxc_seccomp_arch_ppc64
;
366 else if (strncmp(uts
.machine
, "ppc", 3) == 0)
367 return lxc_seccomp_arch_ppc
;
368 else if (strncmp(uts
.machine
, "mips64", 6) == 0)
369 return MIPS_ARCH_N64
;
370 else if (strncmp(uts
.machine
, "mips", 4) == 0)
371 return MIPS_ARCH_O32
;
372 else if (strncmp(uts
.machine
, "s390x", 5) == 0)
373 return lxc_seccomp_arch_s390x
;
375 return lxc_seccomp_arch_unknown
;
378 scmp_filter_ctx
get_new_ctx(enum lxc_hostarch_t n_arch
,
379 uint32_t default_policy_action
, bool *needs_merge
)
386 case lxc_seccomp_arch_i386
:
387 arch
= SCMP_ARCH_X86
;
389 case lxc_seccomp_arch_x32
:
390 arch
= SCMP_ARCH_X32
;
392 case lxc_seccomp_arch_amd64
:
393 arch
= SCMP_ARCH_X86_64
;
395 case lxc_seccomp_arch_arm
:
396 arch
= SCMP_ARCH_ARM
;
398 #ifdef SCMP_ARCH_AARCH64
399 case lxc_seccomp_arch_arm64
:
400 arch
= SCMP_ARCH_AARCH64
;
403 #ifdef SCMP_ARCH_PPC64LE
404 case lxc_seccomp_arch_ppc64le
:
405 arch
= SCMP_ARCH_PPC64LE
;
408 #ifdef SCMP_ARCH_PPC64
409 case lxc_seccomp_arch_ppc64
:
410 arch
= SCMP_ARCH_PPC64
;
414 case lxc_seccomp_arch_ppc
:
415 arch
= SCMP_ARCH_PPC
;
418 #ifdef SCMP_ARCH_MIPS
419 case lxc_seccomp_arch_mips
:
420 arch
= SCMP_ARCH_MIPS
;
422 case lxc_seccomp_arch_mips64
:
423 arch
= SCMP_ARCH_MIPS64
;
425 case lxc_seccomp_arch_mips64n32
:
426 arch
= SCMP_ARCH_MIPS64N32
;
428 case lxc_seccomp_arch_mipsel
:
429 arch
= SCMP_ARCH_MIPSEL
;
431 case lxc_seccomp_arch_mipsel64
:
432 arch
= SCMP_ARCH_MIPSEL64
;
434 case lxc_seccomp_arch_mipsel64n32
:
435 arch
= SCMP_ARCH_MIPSEL64N32
;
438 #ifdef SCMP_ARCH_S390X
439 case lxc_seccomp_arch_s390x
:
440 arch
= SCMP_ARCH_S390X
;
447 ctx
= seccomp_init(default_policy_action
);
449 ERROR("Error initializing seccomp context");
453 ret
= seccomp_attr_set(ctx
, SCMP_FLTATR_CTL_NNP
, 0);
456 SYSERROR("Failed to turn off no-new-privs");
457 seccomp_release(ctx
);
461 #ifdef SCMP_FLTATR_ATL_TSKIP
462 ret
= seccomp_attr_set(ctx
, SCMP_FLTATR_ATL_TSKIP
, 1);
465 SYSWARN("Failed to turn on seccomp nop-skip, continuing");
469 ret
= seccomp_arch_exist(ctx
, arch
);
471 if (ret
!= -EEXIST
) {
473 SYSERROR("Failed to determine whether arch %d is "
474 "already present in the main seccomp context",
476 seccomp_release(ctx
);
480 ret
= seccomp_arch_add(ctx
, arch
);
483 SYSERROR("Failed to add arch %d to main seccomp context",
485 seccomp_release(ctx
);
488 TRACE("Added arch %d to main seccomp context", (int)n_arch
);
490 ret
= seccomp_arch_remove(ctx
, SCMP_ARCH_NATIVE
);
492 ERROR("Failed to remove native arch from main seccomp context");
493 seccomp_release(ctx
);
496 TRACE("Removed native arch from main seccomp context");
500 *needs_merge
= false;
501 TRACE("Arch %d already present in main seccomp context", (int)n_arch
);
507 bool do_resolve_add_rule(uint32_t arch
, char *line
, scmp_filter_ctx ctx
,
508 struct seccomp_v2_rule
*rule
)
511 struct scmp_arg_cmp arg_cmp
[6];
513 ret
= seccomp_arch_exist(ctx
, arch
);
514 if (arch
&& ret
!= 0) {
516 SYSERROR("Seccomp: rule and context arch do not match (arch %d)", arch
);
520 /*get the syscall name*/
521 char *p
= strchr(line
, ' ');
525 if (strncmp(line
, "reject_force_umount", 19) == 0) {
526 ret
= seccomp_rule_add_exact(ctx
, SCMP_ACT_ERRNO(EACCES
),
527 SCMP_SYS(umount2
), 1,
528 SCMP_A1(SCMP_CMP_MASKED_EQ
, MNT_FORCE
, MNT_FORCE
));
531 SYSERROR("Failed loading rule to reject force umount");
535 INFO("Set seccomp rule to reject force umounts");
539 nr
= seccomp_syscall_resolve_name(line
);
540 if (nr
== __NR_SCMP_ERROR
) {
541 WARN("Failed to resolve syscall \"%s\"", line
);
542 WARN("This syscall will NOT be handled by seccomp");
547 WARN("Got negative return value %d for syscall \"%s\"", nr
, line
);
548 WARN("This syscall will NOT be handled by seccomp");
552 memset(&arg_cmp
, 0, sizeof(arg_cmp
));
553 for (i
= 0; i
< rule
->args_num
; i
++) {
554 INFO("arg_cmp[%d]: SCMP_CMP(%u, %llu, %llu, %llu)", i
,
555 rule
->args_value
[i
].index
,
556 (long long unsigned int)rule
->args_value
[i
].op
,
557 (long long unsigned int)rule
->args_value
[i
].mask
,
558 (long long unsigned int)rule
->args_value
[i
].value
);
560 if (SCMP_CMP_MASKED_EQ
== rule
->args_value
[i
].op
)
561 arg_cmp
[i
] = SCMP_CMP(rule
->args_value
[i
].index
,
562 rule
->args_value
[i
].op
,
563 rule
->args_value
[i
].mask
,
564 rule
->args_value
[i
].value
);
566 arg_cmp
[i
] = SCMP_CMP(rule
->args_value
[i
].index
,
567 rule
->args_value
[i
].op
,
568 rule
->args_value
[i
].value
);
571 ret
= seccomp_rule_add_exact_array(ctx
, rule
->action
, nr
,
572 rule
->args_num
, arg_cmp
);
575 SYSERROR("Failed loading rule for %s (nr %d action %d (%s))",
576 line
, nr
, rule
->action
, get_action_name(rule
->action
));
597 static int parse_config_v2(FILE *f
, char *line
, size_t *line_bufsz
, struct lxc_conf
*conf
)
601 enum lxc_hostarch_t cur_rule_arch
, native_arch
;
602 bool blacklist
= false;
603 uint32_t default_policy_action
= -1, default_rule_action
= -1;
604 struct seccomp_v2_rule rule
;
605 struct scmp_ctx_info
{
606 uint32_t architectures
[3];
607 scmp_filter_ctx contexts
[3];
611 if (strncmp(line
, "blacklist", 9) == 0)
613 else if (strncmp(line
, "whitelist", 9) != 0) {
614 ERROR("Bad seccomp policy style \"%s\"", line
);
618 p
= strchr(line
, ' ');
620 default_policy_action
= get_v2_default_action(p
+ 1);
621 if (default_policy_action
== -2)
625 /* for blacklist, allow any syscall which has no rule */
627 if (default_policy_action
== -1)
628 default_policy_action
= SCMP_ACT_ALLOW
;
630 if (default_rule_action
== -1)
631 default_rule_action
= SCMP_ACT_KILL
;
633 if (default_policy_action
== -1)
634 default_policy_action
= SCMP_ACT_KILL
;
636 if (default_rule_action
== -1)
637 default_rule_action
= SCMP_ACT_ALLOW
;
640 memset(&ctx
, 0, sizeof(ctx
));
641 ctx
.architectures
[0] = SCMP_ARCH_NATIVE
;
642 ctx
.architectures
[1] = SCMP_ARCH_NATIVE
;
643 ctx
.architectures
[2] = SCMP_ARCH_NATIVE
;
644 native_arch
= get_hostarch();
645 cur_rule_arch
= native_arch
;
646 if (native_arch
== lxc_seccomp_arch_amd64
) {
647 cur_rule_arch
= lxc_seccomp_arch_all
;
649 ctx
.architectures
[0] = SCMP_ARCH_X86
;
650 ctx
.contexts
[0] = get_new_ctx(lxc_seccomp_arch_i386
,
651 default_policy_action
,
652 &ctx
.needs_merge
[0]);
653 if (!ctx
.contexts
[0])
656 ctx
.architectures
[1] = SCMP_ARCH_X32
;
657 ctx
.contexts
[1] = get_new_ctx(lxc_seccomp_arch_x32
,
658 default_policy_action
,
659 &ctx
.needs_merge
[1]);
660 if (!ctx
.contexts
[1])
663 ctx
.architectures
[2] = SCMP_ARCH_X86_64
;
664 ctx
.contexts
[2] = get_new_ctx(lxc_seccomp_arch_amd64
,
665 default_policy_action
,
666 &ctx
.needs_merge
[2]);
667 if (!ctx
.contexts
[2])
670 } else if (native_arch
== lxc_seccomp_arch_ppc64
) {
671 cur_rule_arch
= lxc_seccomp_arch_all
;
673 ctx
.architectures
[0] = SCMP_ARCH_PPC
;
674 ctx
.contexts
[0] = get_new_ctx(lxc_seccomp_arch_ppc
,
675 default_policy_action
,
676 &ctx
.needs_merge
[0]);
677 if (!ctx
.contexts
[0])
680 ctx
.architectures
[2] = SCMP_ARCH_PPC64
;
681 ctx
.contexts
[2] = get_new_ctx(lxc_seccomp_arch_ppc64
,
682 default_policy_action
,
683 &ctx
.needs_merge
[2]);
684 if (!ctx
.contexts
[2])
688 } else if (native_arch
== lxc_seccomp_arch_arm64
) {
689 cur_rule_arch
= lxc_seccomp_arch_all
;
691 ctx
.architectures
[0] = SCMP_ARCH_ARM
;
692 ctx
.contexts
[0] = get_new_ctx(lxc_seccomp_arch_arm
,
693 default_policy_action
,
694 &ctx
.needs_merge
[0]);
695 if (!ctx
.contexts
[0])
698 #ifdef SCMP_ARCH_AARCH64
699 ctx
.architectures
[2] = SCMP_ARCH_AARCH64
;
700 ctx
.contexts
[2] = get_new_ctx(lxc_seccomp_arch_arm64
,
701 default_policy_action
,
702 &ctx
.needs_merge
[2]);
703 if (!ctx
.contexts
[2])
707 #ifdef SCMP_ARCH_MIPS
708 } else if (native_arch
== lxc_seccomp_arch_mips64
) {
709 cur_rule_arch
= lxc_seccomp_arch_all
;
711 ctx
.architectures
[0] = SCMP_ARCH_MIPS
;
712 ctx
.contexts
[0] = get_new_ctx(lxc_seccomp_arch_mips
,
713 default_policy_action
,
714 &ctx
.needs_merge
[0]);
715 if (!ctx
.contexts
[0])
718 ctx
.architectures
[1] = SCMP_ARCH_MIPS64N32
;
719 ctx
.contexts
[1] = get_new_ctx(lxc_seccomp_arch_mips64n32
,
720 default_policy_action
,
721 &ctx
.needs_merge
[1]);
722 if (!ctx
.contexts
[1])
725 ctx
.architectures
[2] = SCMP_ARCH_MIPS64
;
726 ctx
.contexts
[2] = get_new_ctx(lxc_seccomp_arch_mips64
,
727 default_policy_action
,
728 &ctx
.needs_merge
[2]);
729 if (!ctx
.contexts
[2])
731 } else if (native_arch
== lxc_seccomp_arch_mipsel64
) {
732 cur_rule_arch
= lxc_seccomp_arch_all
;
734 ctx
.architectures
[0] = SCMP_ARCH_MIPSEL
;
735 ctx
.contexts
[0] = get_new_ctx(lxc_seccomp_arch_mipsel
,
736 default_policy_action
,
737 &ctx
.needs_merge
[0]);
738 if (!ctx
.contexts
[0])
741 ctx
.architectures
[1] = SCMP_ARCH_MIPSEL64N32
;
742 ctx
.contexts
[1] = get_new_ctx(lxc_seccomp_arch_mipsel64n32
,
743 default_policy_action
,
744 &ctx
.needs_merge
[1]);
745 if (!ctx
.contexts
[1])
748 ctx
.architectures
[2] = SCMP_ARCH_MIPSEL64
;
749 ctx
.contexts
[2] = get_new_ctx(lxc_seccomp_arch_mipsel64
,
750 default_policy_action
,
751 &ctx
.needs_merge
[2]);
752 if (!ctx
.contexts
[2])
757 if (default_policy_action
!= SCMP_ACT_KILL
) {
758 ret
= seccomp_reset(conf
->seccomp
.seccomp_ctx
, default_policy_action
);
760 ERROR("Error re-initializing Seccomp");
764 ret
= seccomp_attr_set(conf
->seccomp
.seccomp_ctx
, SCMP_FLTATR_CTL_NNP
, 0);
767 SYSERROR("Failed to turn off no-new-privs");
771 #ifdef SCMP_FLTATR_ATL_TSKIP
772 ret
= seccomp_attr_set(conf
->seccomp
.seccomp_ctx
, SCMP_FLTATR_ATL_TSKIP
, 1);
775 SYSWARN("Failed to turn on seccomp nop-skip, continuing");
780 while (getline(&line
, line_bufsz
, f
) != -1) {
787 remove_trailing_newlines(line
);
789 INFO("Processing \"%s\"", line
);
790 if (line
[0] == '[') {
791 /* Read the architecture for next set of rules. */
792 if (strcmp(line
, "[x86]") == 0 ||
793 strcmp(line
, "[X86]") == 0) {
794 if (native_arch
!= lxc_seccomp_arch_i386
&&
795 native_arch
!= lxc_seccomp_arch_amd64
) {
796 cur_rule_arch
= lxc_seccomp_arch_unknown
;
800 cur_rule_arch
= lxc_seccomp_arch_i386
;
801 } else if (strcmp(line
, "[x32]") == 0 ||
802 strcmp(line
, "[X32]") == 0) {
803 if (native_arch
!= lxc_seccomp_arch_amd64
) {
804 cur_rule_arch
= lxc_seccomp_arch_unknown
;
808 cur_rule_arch
= lxc_seccomp_arch_x32
;
809 } else if (strcmp(line
, "[X86_64]") == 0 ||
810 strcmp(line
, "[x86_64]") == 0) {
811 if (native_arch
!= lxc_seccomp_arch_amd64
) {
812 cur_rule_arch
= lxc_seccomp_arch_unknown
;
816 cur_rule_arch
= lxc_seccomp_arch_amd64
;
817 } else if (strcmp(line
, "[all]") == 0 ||
818 strcmp(line
, "[ALL]") == 0) {
819 cur_rule_arch
= lxc_seccomp_arch_all
;
822 else if (strcmp(line
, "[arm]") == 0 ||
823 strcmp(line
, "[ARM]") == 0) {
824 if (native_arch
!= lxc_seccomp_arch_arm
&&
825 native_arch
!= lxc_seccomp_arch_arm64
) {
826 cur_rule_arch
= lxc_seccomp_arch_unknown
;
830 cur_rule_arch
= lxc_seccomp_arch_arm
;
833 #ifdef SCMP_ARCH_AARCH64
834 else if (strcmp(line
, "[arm64]") == 0 ||
835 strcmp(line
, "[ARM64]") == 0) {
836 if (native_arch
!= lxc_seccomp_arch_arm64
) {
837 cur_rule_arch
= lxc_seccomp_arch_unknown
;
841 cur_rule_arch
= lxc_seccomp_arch_arm64
;
844 #ifdef SCMP_ARCH_PPC64LE
845 else if (strcmp(line
, "[ppc64le]") == 0 ||
846 strcmp(line
, "[PPC64LE]") == 0) {
847 if (native_arch
!= lxc_seccomp_arch_ppc64le
) {
848 cur_rule_arch
= lxc_seccomp_arch_unknown
;
852 cur_rule_arch
= lxc_seccomp_arch_ppc64le
;
855 #ifdef SCMP_ARCH_PPC64
856 else if (strcmp(line
, "[ppc64]") == 0 ||
857 strcmp(line
, "[PPC64]") == 0) {
858 if (native_arch
!= lxc_seccomp_arch_ppc64
) {
859 cur_rule_arch
= lxc_seccomp_arch_unknown
;
863 cur_rule_arch
= lxc_seccomp_arch_ppc64
;
867 else if (strcmp(line
, "[ppc]") == 0 ||
868 strcmp(line
, "[PPC]") == 0) {
869 if (native_arch
!= lxc_seccomp_arch_ppc
&&
870 native_arch
!= lxc_seccomp_arch_ppc64
) {
871 cur_rule_arch
= lxc_seccomp_arch_unknown
;
875 cur_rule_arch
= lxc_seccomp_arch_ppc
;
878 #ifdef SCMP_ARCH_MIPS
879 else if (strcmp(line
, "[mips64]") == 0 ||
880 strcmp(line
, "[MIPS64]") == 0) {
881 if (native_arch
!= lxc_seccomp_arch_mips64
) {
882 cur_rule_arch
= lxc_seccomp_arch_unknown
;
886 cur_rule_arch
= lxc_seccomp_arch_mips64
;
887 } else if (strcmp(line
, "[mips64n32]") == 0 ||
888 strcmp(line
, "[MIPS64N32]") == 0) {
889 if (native_arch
!= lxc_seccomp_arch_mips64
) {
890 cur_rule_arch
= lxc_seccomp_arch_unknown
;
894 cur_rule_arch
= lxc_seccomp_arch_mips64n32
;
895 } else if (strcmp(line
, "[mips]") == 0 ||
896 strcmp(line
, "[MIPS]") == 0) {
897 if (native_arch
!= lxc_seccomp_arch_mips
&&
898 native_arch
!= lxc_seccomp_arch_mips64
) {
899 cur_rule_arch
= lxc_seccomp_arch_unknown
;
903 cur_rule_arch
= lxc_seccomp_arch_mips
;
904 } else if (strcmp(line
, "[mipsel64]") == 0 ||
905 strcmp(line
, "[MIPSEL64]") == 0) {
906 if (native_arch
!= lxc_seccomp_arch_mipsel64
) {
907 cur_rule_arch
= lxc_seccomp_arch_unknown
;
911 cur_rule_arch
= lxc_seccomp_arch_mipsel64
;
912 } else if (strcmp(line
, "[mipsel64n32]") == 0 ||
913 strcmp(line
, "[MIPSEL64N32]") == 0) {
914 if (native_arch
!= lxc_seccomp_arch_mipsel64
) {
915 cur_rule_arch
= lxc_seccomp_arch_unknown
;
919 cur_rule_arch
= lxc_seccomp_arch_mipsel64n32
;
920 } else if (strcmp(line
, "[mipsel]") == 0 ||
921 strcmp(line
, "[MIPSEL]") == 0) {
922 if (native_arch
!= lxc_seccomp_arch_mipsel
&&
923 native_arch
!= lxc_seccomp_arch_mipsel64
) {
924 cur_rule_arch
= lxc_seccomp_arch_unknown
;
928 cur_rule_arch
= lxc_seccomp_arch_mipsel
;
931 #ifdef SCMP_ARCH_S390X
932 else if (strcmp(line
, "[s390x]") == 0 ||
933 strcmp(line
, "[S390X]") == 0) {
934 if (native_arch
!= lxc_seccomp_arch_s390x
) {
935 cur_rule_arch
= lxc_seccomp_arch_unknown
;
939 cur_rule_arch
= lxc_seccomp_arch_s390x
;
949 /* irrelevant arch - i.e. arm on i386 */
950 if (cur_rule_arch
== lxc_seccomp_arch_unknown
)
953 memset(&rule
, 0, sizeof(rule
));
954 /* read optional action which follows the syscall */
955 ret
= parse_v2_rules(line
, default_rule_action
, &rule
);
957 ERROR("Failed to interpret seccomp rule");
961 #if HAVE_DECL_SECCOMP_NOTIFY_FD
962 if ((rule
.action
== SCMP_ACT_NOTIFY
) &&
963 !conf
->seccomp
.notifier
.wants_supervision
) {
964 conf
->seccomp
.notifier
.wants_supervision
= true;
965 TRACE("Set SECCOMP_FILTER_FLAG_NEW_LISTENER attribute");
969 if (!do_resolve_add_rule(SCMP_ARCH_NATIVE
, line
,
970 conf
->seccomp
.seccomp_ctx
, &rule
))
973 INFO("Added native rule for arch %d for %s action %d(%s)",
974 SCMP_ARCH_NATIVE
, line
, rule
.action
,
975 get_action_name(rule
.action
));
977 if (ctx
.architectures
[0] != SCMP_ARCH_NATIVE
) {
978 if (!do_resolve_add_rule(ctx
.architectures
[0], line
,
979 ctx
.contexts
[0], &rule
))
982 INFO("Added compat rule for arch %d for %s action %d(%s)",
983 ctx
.architectures
[0], line
, rule
.action
,
984 get_action_name(rule
.action
));
987 if (ctx
.architectures
[1] != SCMP_ARCH_NATIVE
) {
988 if (!do_resolve_add_rule(ctx
.architectures
[1], line
,
989 ctx
.contexts
[1], &rule
))
992 INFO("Added compat rule for arch %d for %s action %d(%s)",
993 ctx
.architectures
[1], line
, rule
.action
,
994 get_action_name(rule
.action
));
997 if (ctx
.architectures
[2] != SCMP_ARCH_NATIVE
) {
998 if (!do_resolve_add_rule(ctx
.architectures
[2], line
,
999 ctx
.contexts
[2], &rule
))
1002 INFO("Added native rule for arch %d for %s action %d(%s)",
1003 ctx
.architectures
[2], line
, rule
.action
,
1004 get_action_name(rule
.action
));
1008 INFO("Merging compat seccomp contexts into main context");
1009 if (ctx
.contexts
[0]) {
1010 if (ctx
.needs_merge
[0]) {
1011 ret
= seccomp_merge(conf
->seccomp
.seccomp_ctx
, ctx
.contexts
[0]);
1013 ERROR("Failed to merge first compat seccomp "
1014 "context into main context");
1018 TRACE("Merged first compat seccomp context into main context");
1020 seccomp_release(ctx
.contexts
[0]);
1021 ctx
.contexts
[0] = NULL
;
1025 if (ctx
.contexts
[1]) {
1026 if (ctx
.needs_merge
[1]) {
1027 ret
= seccomp_merge(conf
->seccomp
.seccomp_ctx
, ctx
.contexts
[1]);
1029 ERROR("Failed to merge first compat seccomp "
1030 "context into main context");
1034 TRACE("Merged second compat seccomp context into main context");
1036 seccomp_release(ctx
.contexts
[1]);
1037 ctx
.contexts
[1] = NULL
;
1041 if (ctx
.contexts
[2]) {
1042 if (ctx
.needs_merge
[2]) {
1043 ret
= seccomp_merge(conf
->seccomp
.seccomp_ctx
, ctx
.contexts
[2]);
1045 ERROR("Failed to merge third compat seccomp "
1046 "context into main context");
1050 TRACE("Merged third compat seccomp context into main context");
1052 seccomp_release(ctx
.contexts
[2]);
1053 ctx
.contexts
[2] = NULL
;
1061 ERROR("Unsupported architecture \"%s\"", line
);
1065 if (ctx
.contexts
[0])
1066 seccomp_release(ctx
.contexts
[0]);
1068 if (ctx
.contexts
[1])
1069 seccomp_release(ctx
.contexts
[1]);
1071 if (ctx
.contexts
[2])
1072 seccomp_release(ctx
.contexts
[2]);
1078 #else /* HAVE_DECL_SECCOMP_SYSCALL_RESOLVE_NAME_ARCH */
1079 static int parse_config_v2(FILE *f
, char *line
, struct lxc_conf
*conf
)
1083 #endif /* HAVE_DECL_SECCOMP_SYSCALL_RESOLVE_NAME_ARCH */
1086 * The first line of the config file has a policy language version
1087 * the second line has some directives
1088 * then comes policy subject to the directives
1089 * right now version must be '1' or '2'
1090 * the directives must include 'whitelist'(version == 1 or 2) or 'blacklist'
1091 * (version == 2) and can include 'debug' (though debug is not yet supported).
1093 static int parse_config(FILE *f
, struct lxc_conf
*conf
)
1096 size_t line_bufsz
= 0;
1099 ret
= fscanf(f
, "%d\n", &version
);
1100 if (ret
!= 1 || (version
!= 1 && version
!= 2)) {
1101 ERROR("Invalid version");
1105 if (getline(&line
, &line_bufsz
, f
) == -1) {
1106 ERROR("Invalid config file");
1110 if (version
== 1 && !strstr(line
, "whitelist")) {
1111 ERROR("Only whitelist policy is supported");
1115 if (strstr(line
, "debug")) {
1116 ERROR("Debug not yet implemented");
1121 return parse_config_v1(f
, line
, &line_bufsz
, conf
);
1123 return parse_config_v2(f
, line
, &line_bufsz
, conf
);
1131 * use_seccomp: return true if we should try and apply a seccomp policy
1132 * if defined for the container.
1133 * This will return false if
1134 * 1. seccomp is not enabled in the kernel
1135 * 2. a seccomp policy is already enabled for this task
1137 static bool use_seccomp(const struct lxc_conf
*conf
)
1141 size_t line_bufsz
= 0;
1143 bool already_enabled
= false, found
= false;
1145 if (conf
->seccomp
.allow_nesting
> 0)
1148 f
= fopen("/proc/self/status", "r");
1152 while (getline(&line
, &line_bufsz
, f
) != -1) {
1153 if (strncmp(line
, "Seccomp:", 8) == 0) {
1156 ret
= sscanf(line
+ 8, "%d", &v
);
1157 if (ret
== 1 && v
!= 0)
1158 already_enabled
= true;
1167 INFO("Seccomp is not enabled in the kernel");
1171 if (already_enabled
) {
1172 INFO("Already seccomp-confined, not loading new policy");
1179 int lxc_read_seccomp_config(struct lxc_conf
*conf
)
1184 if (!conf
->seccomp
.seccomp
)
1187 if (!use_seccomp(conf
))
1190 #if HAVE_SCMP_FILTER_CTX
1191 /* XXX for debug, pass in SCMP_ACT_TRAP */
1192 conf
->seccomp
.seccomp_ctx
= seccomp_init(SCMP_ACT_KILL
);
1193 ret
= !conf
->seccomp
.seccomp_ctx
;
1195 ret
= seccomp_init(SCMP_ACT_KILL
) < 0;
1198 ERROR("Failed initializing seccomp");
1202 /* turn off no-new-privs. We don't want it in lxc, and it breaks
1204 #if HAVE_SCMP_FILTER_CTX
1205 ret
= seccomp_attr_set(conf
->seccomp
.seccomp_ctx
, SCMP_FLTATR_CTL_NNP
, 0);
1207 ret
= seccomp_attr_set(SCMP_FLTATR_CTL_NNP
, 0);
1211 SYSERROR("Failed to turn off no-new-privs");
1215 #ifdef SCMP_FLTATR_ATL_TSKIP
1216 ret
= seccomp_attr_set(conf
->seccomp
.seccomp_ctx
, SCMP_FLTATR_ATL_TSKIP
, 1);
1219 SYSWARN("Failed to turn on seccomp nop-skip, continuing");
1223 f
= fopen(conf
->seccomp
.seccomp
, "r");
1225 SYSERROR("Failed to open seccomp policy file %s", conf
->seccomp
.seccomp
);
1229 ret
= parse_config(f
, conf
);
1235 int lxc_seccomp_load(struct lxc_conf
*conf
)
1239 if (!conf
->seccomp
.seccomp
)
1242 if (!use_seccomp(conf
))
1245 #if HAVE_SCMP_FILTER_CTX
1246 ret
= seccomp_load(conf
->seccomp
.seccomp_ctx
);
1248 ret
= seccomp_load();
1252 SYSERROR("Error loading the seccomp policy");
1256 /* After load seccomp filter into the kernel successfully, export the current seccomp
1257 * filter to log file */
1258 #if HAVE_SCMP_FILTER_CTX
1259 if ((lxc_log_get_level() <= LXC_LOG_LEVEL_TRACE
||
1260 conf
->loglevel
<= LXC_LOG_LEVEL_TRACE
) &&
1262 ret
= seccomp_export_pfc(conf
->seccomp
.seccomp_ctx
, lxc_log_fd
);
1263 /* Just give an warning when export error */
1266 SYSWARN("Failed to export seccomp filter to log file");
1271 #if HAVE_DECL_SECCOMP_NOTIFY_FD
1272 if (conf
->seccomp
.notifier
.wants_supervision
) {
1273 ret
= seccomp_notify_fd(conf
->seccomp
.seccomp_ctx
);
1279 conf
->seccomp
.notifier
.notify_fd
= ret
;
1280 TRACE("Retrieved new seccomp listener fd %d", ret
);
1287 void lxc_seccomp_free(struct lxc_seccomp
*seccomp
)
1289 free_disarm(seccomp
->seccomp
);
1291 #if HAVE_SCMP_FILTER_CTX
1292 if (seccomp
->seccomp_ctx
) {
1293 seccomp_release(seccomp
->seccomp_ctx
);
1294 seccomp
->seccomp_ctx
= NULL
;
1298 #if HAVE_DECL_SECCOMP_NOTIFY_FD
1299 close_prot_errno_disarm(seccomp
->notifier
.notify_fd
);
1300 close_prot_errno_disarm(seccomp
->notifier
.proxy_fd
);
1301 seccomp_notify_free(seccomp
->notifier
.req_buf
, seccomp
->notifier
.rsp_buf
);
1302 seccomp
->notifier
.req_buf
= NULL
;
1303 seccomp
->notifier
.rsp_buf
= NULL
;
1307 #if HAVE_DECL_SECCOMP_NOTIFY_FD
1308 static int seccomp_notify_reconnect(struct lxc_handler
*handler
)
1310 __do_close_prot_errno
int notify_fd
= -EBADF
;
1312 close_prot_errno_disarm(handler
->conf
->seccomp
.notifier
.proxy_fd
);
1314 notify_fd
= lxc_unix_connect_type(
1315 &handler
->conf
->seccomp
.notifier
.proxy_addr
, SOCK_SEQPACKET
);
1316 if (notify_fd
< 0) {
1317 SYSERROR("Failed to reconnect to seccomp proxy");
1321 /* 30 second timeout */
1322 if (lxc_socket_set_timeout(notify_fd
, 30, 30)) {
1323 SYSERROR("Failed to set socket timeout");
1326 handler
->conf
->seccomp
.notifier
.proxy_fd
= move_fd(notify_fd
);
1331 #if HAVE_DECL_SECCOMP_NOTIFY_FD
1332 static int seccomp_notify_default_answer(int fd
, struct seccomp_notif
*req
,
1333 struct seccomp_notif_resp
*resp
,
1334 struct lxc_handler
*handler
)
1337 resp
->error
= -ENOSYS
;
1339 if (seccomp_notify_respond(fd
, resp
))
1340 SYSERROR("Failed to send default message to seccomp");
1342 return seccomp_notify_reconnect(handler
);
1346 int seccomp_notify_handler(int fd
, uint32_t events
, void *data
,
1347 struct lxc_epoll_descr
*descr
)
1350 #if HAVE_DECL_SECCOMP_NOTIFY_FD
1351 __do_close_prot_errno
int fd_mem
= -EBADF
;
1352 int reconnect_count
, ret
;
1354 struct iovec iov
[4];
1355 size_t iov_len
, msg_base_size
, msg_full_size
;
1356 char mem_path
[6 /* /proc/ */
1357 + INTTYPE_TO_STRLEN(int64_t)
1360 struct lxc_handler
*hdlr
= data
;
1361 struct lxc_conf
*conf
= hdlr
->conf
;
1362 struct seccomp_notif
*req
= conf
->seccomp
.notifier
.req_buf
;
1363 struct seccomp_notif_resp
*resp
= conf
->seccomp
.notifier
.rsp_buf
;
1364 int listener_proxy_fd
= conf
->seccomp
.notifier
.proxy_fd
;
1365 struct seccomp_notify_proxy_msg msg
= {0};
1366 char *cookie
= conf
->seccomp
.notifier
.cookie
;
1369 if (listener_proxy_fd
< 0) {
1370 ERROR("No seccomp proxy registered");
1371 return minus_one_set_errno(EINVAL
);
1374 ret
= seccomp_notify_receive(fd
, req
);
1376 SYSERROR("Failed to read seccomp notification");
1380 /* remember the ID in case we receive garbage from the proxy */
1381 resp
->id
= req_id
= req
->id
;
1383 snprintf(mem_path
, sizeof(mem_path
), "/proc/%d/mem", req
->pid
);
1384 fd_mem
= open(mem_path
, O_RDONLY
| O_CLOEXEC
);
1386 (void)seccomp_notify_default_answer(fd
, req
, resp
, hdlr
);
1387 SYSERROR("Failed to open process memory for seccomp notify request");
1392 * Make sure that the fd for /proc/<pid>/mem we just opened still
1393 * refers to the correct process's memory.
1395 ret
= seccomp_notify_id_valid(fd
, req
->id
);
1397 (void)seccomp_notify_default_answer(fd
, req
, resp
, hdlr
);
1398 SYSERROR("Invalid seccomp notify request id");
1402 msg
.monitor_pid
= hdlr
->monitor_pid
;
1403 msg
.init_pid
= hdlr
->pid
;
1404 memcpy(&msg
.sizes
, &conf
->seccomp
.notifier
.sizes
, sizeof(msg
.sizes
));
1407 iov
[0].iov_base
= &msg
;
1408 msg_base_size
+= (iov
[0].iov_len
= sizeof(msg
));
1409 iov
[1].iov_base
= req
;
1410 msg_base_size
+= (iov
[1].iov_len
= msg
.sizes
.seccomp_notif
);
1411 iov
[2].iov_base
= resp
;
1412 msg_base_size
+= (iov
[2].iov_len
= msg
.sizes
.seccomp_notif_resp
);
1413 msg_full_size
= msg_base_size
;
1416 size_t len
= strlen(cookie
);
1418 msg
.cookie_len
= (uint64_t)len
;
1420 iov
[3].iov_base
= cookie
;
1421 msg_full_size
+= (iov
[3].iov_len
= len
);
1428 reconnect_count
= 0;
1430 bytes
= lxc_abstract_unix_send_fds_iov(listener_proxy_fd
,
1433 if (bytes
!= (ssize_t
)msg_full_size
) {
1434 SYSERROR("Failed to forward message to seccomp proxy");
1435 if (seccomp_notify_default_answer(fd
, req
, resp
, hdlr
))
1438 } while (reconnect_count
++);
1440 close_prot_errno_disarm(fd_mem
);
1442 if (msg
.__reserved
!= 0) {
1443 ERROR("Proxy filled reserved data in response");
1444 seccomp_notify_default_answer(fd
, req
, resp
, hdlr
);
1448 if (resp
->id
!= req_id
) {
1450 ERROR("Proxy returned response with illegal id");
1451 (void)seccomp_notify_default_answer(fd
, req
, resp
, hdlr
);
1455 reconnect_count
= 0;
1457 bytes
= lxc_recvmsg_nointr_iov(listener_proxy_fd
, iov
,iov_len
,
1459 if (bytes
!= (ssize_t
)msg_base_size
) {
1460 SYSERROR("Failed to receive message from seccomp proxy");
1461 if (seccomp_notify_default_answer(fd
, req
, resp
, hdlr
))
1464 } while (reconnect_count
++);
1466 ret
= seccomp_notify_respond(fd
, resp
);
1468 SYSERROR("Failed to send seccomp notification");
1477 void seccomp_conf_init(struct lxc_conf
*conf
)
1479 conf
->seccomp
.seccomp
= NULL
;
1480 #if HAVE_SCMP_FILTER_CTX
1481 conf
->seccomp
.allow_nesting
= 0;
1482 memset(&conf
->seccomp
.seccomp_ctx
, 0, sizeof(conf
->seccomp
.seccomp_ctx
));
1483 #endif /* HAVE_SCMP_FILTER_CTX */
1484 #if HAVE_DECL_SECCOMP_NOTIFY_FD
1485 conf
->seccomp
.notifier
.wants_supervision
= false;
1486 conf
->seccomp
.notifier
.notify_fd
= -EBADF
;
1487 conf
->seccomp
.notifier
.proxy_fd
= -EBADF
;
1488 memset(&conf
->seccomp
.notifier
.proxy_addr
, 0,
1489 sizeof(conf
->seccomp
.notifier
.proxy_addr
));
1490 conf
->seccomp
.notifier
.req_buf
= NULL
;
1491 conf
->seccomp
.notifier
.rsp_buf
= NULL
;
1495 int lxc_seccomp_setup_proxy(struct lxc_seccomp
*seccomp
,
1496 struct lxc_epoll_descr
*descr
,
1497 struct lxc_handler
*handler
)
1499 #if HAVE_DECL_SECCOMP_NOTIFY_FD
1500 if (seccomp
->notifier
.wants_supervision
&&
1501 seccomp
->notifier
.proxy_addr
.sun_path
[1] != '\0') {
1502 __do_close_prot_errno
int notify_fd
= -EBADF
;
1505 notify_fd
= lxc_unix_connect_type(&seccomp
->notifier
.proxy_addr
,
1507 if (notify_fd
< 0) {
1508 SYSERROR("Failed to connect to seccomp proxy");
1512 /* 30 second timeout */
1513 ret
= lxc_socket_set_timeout(notify_fd
, 30, 30);
1515 SYSERROR("Failed to set timeouts for seccomp proxy");
1519 ret
= __seccomp(SECCOMP_GET_NOTIF_SIZES
, 0,
1520 &seccomp
->notifier
.sizes
);
1522 SYSERROR("Failed to query seccomp notify struct sizes");
1526 ret
= seccomp_notify_alloc(&seccomp
->notifier
.req_buf
,
1527 &seccomp
->notifier
.rsp_buf
);
1529 ERROR("Failed to allocate seccomp notify request and response buffers");
1534 ret
= lxc_mainloop_add_handler(descr
,
1535 seccomp
->notifier
.notify_fd
,
1536 seccomp_notify_handler
, handler
);
1538 ERROR("Failed to add seccomp notify handler for %d to mainloop",
1543 seccomp
->notifier
.proxy_fd
= move_fd(notify_fd
);
1549 int lxc_seccomp_send_notifier_fd(struct lxc_seccomp
*seccomp
, int socket_fd
)
1551 #if HAVE_DECL_SECCOMP_NOTIFY_FD
1552 if (seccomp
->notifier
.wants_supervision
) {
1553 if (lxc_abstract_unix_send_fds(socket_fd
,
1554 &seccomp
->notifier
.notify_fd
, 1,
1557 close_prot_errno_disarm(seccomp
->notifier
.notify_fd
);
1563 int lxc_seccomp_recv_notifier_fd(struct lxc_seccomp
*seccomp
, int socket_fd
)
1565 #if HAVE_DECL_SECCOMP_NOTIFY_FD
1566 if (seccomp
->notifier
.wants_supervision
) {
1569 ret
= lxc_abstract_unix_recv_fds(socket_fd
,
1570 &seccomp
->notifier
.notify_fd
,
1579 int lxc_seccomp_add_notifier(const char *name
, const char *lxcpath
,
1580 struct lxc_seccomp
*seccomp
)
1583 #if HAVE_DECL_SECCOMP_NOTIFY_FD
1584 if (seccomp
->notifier
.wants_supervision
) {
1587 ret
= lxc_cmd_seccomp_notify_add_listener(name
, lxcpath
,
1588 seccomp
->notifier
.notify_fd
,
1590 close_prot_errno_disarm(seccomp
->notifier
.notify_fd
);