@@ -43,7 +43,7 @@ func (e VersionError) Error() string {
4343 if e .minimum != "" {
4444 format += e .minimum + ": "
4545 } else {
46- format += "2.1 .0: "
46+ format += "2.2 .0: "
4747 }
4848 format += "detected %d.%d.%d"
4949 return fmt .Sprintf (format , verMajor , verMinor , verMicro )
@@ -76,8 +76,8 @@ type ScmpSyscall int32
7676
7777const (
7878 // Valid architectures recognized by libseccomp
79- // ARM64 and all MIPS architectures are unsupported by versions of the
80- // library before v2.2 and will return errors if used
79+ // PowerPC and S390(x) architectures are unavailable below library version
80+ // v2.3.0 and will returns errors if used with incompatible libraries
8181
8282 // ArchInvalid is a placeholder to ensure uninitialized ScmpArch
8383 // variables are invalid
@@ -494,6 +494,13 @@ func NewFilter(defaultAction ScmpAction) (*ScmpFilter, error) {
494494 filter .valid = true
495495 runtime .SetFinalizer (filter , filterFinalizer )
496496
497+ // Enable TSync so all goroutines will receive the same rules
498+ // If the kernel does not support TSYNC, allow us to continue without error
499+ if err := filter .setFilterAttr (filterAttrTsync , 0x1 ); err != nil && err != syscall .ENOTSUP {
500+ filter .Release ()
501+ return nil , fmt .Errorf ("could not create filter - error setting tsync bit: %v" , err )
502+ }
503+
497504 return filter , nil
498505}
499506
@@ -550,7 +557,7 @@ func (f *ScmpFilter) Release() {
550557// The source filter src will be released as part of the process, and will no
551558// longer be usable or valid after this call.
552559// To be merged, filters must NOT share any architectures, and all their
553- // attributes (Default Action, Bad Arch Action, No New Privs and TSync bools)
560+ // attributes (Default Action, Bad Arch Action, and No New Privs bools)
554561// must match.
555562// The filter src will be merged into the filter this is called on.
556563// The architectures of the src filter not present in the destination, and all
@@ -723,30 +730,6 @@ func (f *ScmpFilter) GetNoNewPrivsBit() (bool, error) {
723730 return true , nil
724731}
725732
726- // GetTsyncBit returns whether Thread Synchronization will be enabled on the
727- // filter being loaded, or an error if an issue was encountered retrieving the
728- // value.
729- // Thread Sync ensures that all members of the thread group of the calling
730- // process will share the same Seccomp filter set.
731- // Tsync is a fairly recent addition to the Linux kernel and older kernels
732- // lack support. If the running kernel does not support Tsync and it is
733- // requested in a filter, Libseccomp will not enable TSync support and will
734- // proceed as normal.
735- // This function is unavailable before v2.2 of libseccomp and will return an
736- // error.
737- func (f * ScmpFilter ) GetTsyncBit () (bool , error ) {
738- tSync , err := f .getFilterAttr (filterAttrTsync )
739- if err != nil {
740- return false , err
741- }
742-
743- if tSync == 0 {
744- return false , nil
745- }
746-
747- return true , nil
748- }
749-
750733// SetBadArchAction sets the default action taken on a syscall for an
751734// architecture not in the filter, or an error if an issue was encountered
752735// setting the value.
@@ -773,27 +756,6 @@ func (f *ScmpFilter) SetNoNewPrivsBit(state bool) error {
773756 return f .setFilterAttr (filterAttrNNP , toSet )
774757}
775758
776- // SetTsync sets whether Thread Synchronization will be enabled on the filter
777- // being loaded. Returns an error if setting Tsync failed, or the filter is
778- // invalid.
779- // Thread Sync ensures that all members of the thread group of the calling
780- // process will share the same Seccomp filter set.
781- // Tsync is a fairly recent addition to the Linux kernel and older kernels
782- // lack support. If the running kernel does not support Tsync and it is
783- // requested in a filter, Libseccomp will not enable TSync support and will
784- // proceed as normal.
785- // This function is unavailable before v2.2 of libseccomp and will return an
786- // error.
787- func (f * ScmpFilter ) SetTsync (enable bool ) error {
788- var toSet C.uint32_t = 0x0
789-
790- if enable {
791- toSet = 0x1
792- }
793-
794- return f .setFilterAttr (filterAttrTsync , toSet )
795- }
796-
797759// SetSyscallPriority sets a syscall's priority.
798760// This provides a hint to the filter generator in libseccomp about the
799761// importance of this syscall. High-priority syscalls are placed
0 commit comments