88 "fmt"
99 "os"
1010 "os/exec"
11- "runtime"
1211 "strings"
1312 "syscall"
1413 "testing"
@@ -843,7 +842,7 @@ func TestNotif(t *testing.T) {
843842 execInSubprocess (t , subprocessNotif )
844843}
845844func subprocessNotif (t * testing.T ) {
846- // seccomp notification requires API level >= 5
845+ // seccomp notification requires API level >= 6
847846 api , err := GetAPI ()
848847 if err != nil {
849848 if ! APILevelIsSupported () {
@@ -853,10 +852,10 @@ func subprocessNotif(t *testing.T) {
853852 t .Errorf ("Error getting API level: %s" , err )
854853 } else {
855854 t .Logf ("Got API level %v" , api )
856- if api < 5 {
857- err = SetAPI (5 )
855+ if api < 6 {
856+ err = SetAPI (6 )
858857 if err != nil {
859- t .Skipf ("Skipping test: API level %d is less than 5 and could not set it to 5 " , api )
858+ t .Skipf ("Skipping test: API level %d is less than 6 and could not set it to 6 " , api )
860859 return
861860 }
862861 }
@@ -874,18 +873,16 @@ func subprocessNotif(t *testing.T) {
874873 return
875874 }
876875
876+ // Create a filter that only notifies on chdir. This way, while the
877+ // seccomp filter applies to all threads, we can run the target and
878+ // handling in different go routines with no problem as only the target
879+ // goroutine uses chdir.
877880 filter , err := NewFilter (ActAllow )
878881 if err != nil {
879882 t .Errorf ("Error creating filter: %s" , err )
880883 }
881884 defer filter .Release ()
882885
883- // Seccomp notification is only supported on single-thread filters
884- err = filter .SetTsync (false )
885- if err != nil {
886- t .Errorf ("Error setting tsync on filter: %s" , err )
887- }
888-
889886 call , err := GetSyscallFromName ("chdir" )
890887 if err != nil {
891888 t .Errorf ("Error getting syscall number: %s" , err )
@@ -954,11 +951,6 @@ func subprocessNotif(t *testing.T) {
954951 done := make (chan struct {})
955952
956953 go func () {
957- // Lock this goroutine to it's current kernel thread; otherwise the go runtime may
958- // switch us to a different OS thread, bypassing the seccomp notification filter.
959- runtime .LockOSThread ()
960- defer runtime .UnlockOSThread ()
961-
962954 err = filter .Load ()
963955 if err != nil {
964956 t .Errorf ("Error loading filter: %s" , err )
@@ -1017,14 +1009,14 @@ func TestNotifUnsupported(t *testing.T) {
10171009 execInSubprocess (t , subprocessNotifUnsupported )
10181010}
10191011func subprocessNotifUnsupported (t * testing.T ) {
1020- // seccomp notification requires API level >= 5
1012+ // seccomp notification requires API level >= 6
10211013 api := 0
10221014 if APILevelIsSupported () {
10231015 api , err := GetAPI ()
10241016 if err != nil {
10251017 t .Errorf ("Error getting API level: %s" , err )
1026- } else if api >= 5 {
1027- t .Skipf ("Skipping test for old libseccomp support: API level %d is >= 5 " , api )
1018+ } else if api >= 6 {
1019+ t .Skipf ("Skipping test for old libseccomp support: API level %d is >= 6 " , api )
10281020 }
10291021 }
10301022
0 commit comments