Skip to content

Commit b44b590

Browse files
committed
libct/seccomp/patchbpf: support SPEC_ALLOW
Commit 58ea21d added support for seccomp flags such as SPEC_ALLOW, but it does not work as expected, because since commit 7a8d716 we do not use libseccomp-golang's Load(), but handle flags separately in patchbfp. This fixes setting SPEC_ALLOW flag. Add a comment to not forget to amend filterFlags when adding new flags. Signed-off-by: Kir Kolyshkin <[email protected]> (cherry picked from commit c7dc8b1) Signed-off-by: Kir Kolyshkin <[email protected]>
1 parent a8e4cf3 commit b44b590

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

libcontainer/seccomp/patchbpf/enosys_linux.go

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,11 @@ const uintptr_t C_SET_MODE_FILTER = SECCOMP_SET_MODE_FILTER;
4343
#endif
4444
const uintptr_t C_FILTER_FLAG_LOG = SECCOMP_FILTER_FLAG_LOG;
4545
46+
#ifndef SECCOMP_FILTER_FLAG_SPEC_ALLOW
47+
# define SECCOMP_FILTER_FLAG_SPEC_ALLOW (1UL << 2)
48+
#endif
49+
const uintptr_t C_FILTER_FLAG_SPEC_ALLOW = SECCOMP_FILTER_FLAG_SPEC_ALLOW;
50+
4651
#ifndef SECCOMP_FILTER_FLAG_NEW_LISTENER
4752
# define SECCOMP_FILTER_FLAG_NEW_LISTENER (1UL << 3)
4853
#endif
@@ -629,8 +634,13 @@ func filterFlags(config *configs.Seccomp, filter *libseccomp.ScmpFilter) (flags
629634
flags |= uint(C.C_FILTER_FLAG_LOG)
630635
}
631636
}
632-
633-
// TODO: Support seccomp flags not yet added to libseccomp-golang...
637+
if apiLevel >= 4 {
638+
if ssb, err := filter.GetSSB(); err != nil {
639+
return 0, false, fmt.Errorf("unable to fetch SECCOMP_FILTER_FLAG_SPEC_ALLOW bit: %w", err)
640+
} else if ssb {
641+
flags |= uint(C.C_FILTER_FLAG_SPEC_ALLOW)
642+
}
643+
}
634644

635645
for _, call := range config.Syscalls {
636646
if call.Action == configs.Notify {

libcontainer/seccomp/seccomp_linux.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ func InitSeccomp(config *configs.Seccomp) (int, error) {
105105
if err := filter.SetSSB(true); err != nil {
106106
return -1, fmt.Errorf("error adding SSB flag to seccomp filter: %w", err)
107107
}
108+
// NOTE when adding more flags, make sure to also modify filterFlags in patchbpf.
108109
default:
109110
return -1, fmt.Errorf("seccomp flags %q not yet supported by runc", flag)
110111
}

0 commit comments

Comments
 (0)