aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAleksandr Nogikh <nogikh@google.com>2025-11-24 12:25:46 +0100
committerAleksandr Nogikh <nogikh@google.com>2025-11-24 14:34:18 +0000
commit8f574c3487990421d80fb1a248f5d9f8b27654bb (patch)
tree0bb7ee3207c989294782d713324d135724648c7c
parentbf6fe8fef08f3e0d8c066121c66eaf37681e0de9 (diff)
pkg/csource: exclude auto-generated syscalls from tests
Auto-generated syscall descriptions currently do not properly mark arch-specific syscalls like socketcall (which is only available on 32 bit systems), which leads to TestGenerate breakages. Until the syz-declextract tool is fixed and descriptions are re-generated, don't use such calls in TestGenerate tests. It has recently caused numerous syzkaller update erorrs on syzbot. Cc #5410. Closes #6468.
-rw-r--r--pkg/csource/csource_test.go16
-rw-r--r--prog/rand.go4
-rw-r--r--prog/target.go11
3 files changed, 23 insertions, 8 deletions
diff --git a/pkg/csource/csource_test.go b/pkg/csource/csource_test.go
index 1dae0202d..9e9dadf86 100644
--- a/pkg/csource/csource_test.go
+++ b/pkg/csource/csource_test.go
@@ -38,6 +38,10 @@ func TestGenerate(t *testing.T) {
t.Parallel()
checked := make(map[string]bool)
for _, target := range prog.AllTargets() {
+ // Auto-generated descriptions currently do not properly mark arch-specific syscalls, see
+ // https://github.com/google/syzkaller/issues/5410#issuecomment-3570190241.
+ // Until it's fixed, let's remove these syscalls from csource tests.
+ ct := target.NoAutoChoiceTable()
sysTarget := targets.Get(target.OS, target.Arch)
if runtime.GOOS != sysTarget.BuildOS {
continue
@@ -50,14 +54,14 @@ func TestGenerate(t *testing.T) {
if full || !testing.Short() {
checked[target.OS] = true
t.Parallel()
- testTarget(t, target, full)
+ testTarget(t, target, full, ct)
}
- testPseudoSyscalls(t, target)
+ testPseudoSyscalls(t, target, ct)
})
}
}
-func testPseudoSyscalls(t *testing.T, target *prog.Target) {
+func testPseudoSyscalls(t *testing.T, target *prog.Target, ct *prog.ChoiceTable) {
// Use options that are as minimal as possible.
// We want to ensure that the code can always be compiled.
opts := Options{
@@ -65,7 +69,7 @@ func testPseudoSyscalls(t *testing.T, target *prog.Target) {
}
rs := testutil.RandSource(t)
for _, meta := range target.PseudoSyscalls() {
- p := target.GenSampleProg(meta, rs)
+ p := target.GenSampleProg(meta, rs, ct)
t.Run(fmt.Sprintf("single_%s", meta.CallName), func(t *testing.T) {
t.Parallel()
testOne(t, p, opts)
@@ -73,9 +77,9 @@ func testPseudoSyscalls(t *testing.T, target *prog.Target) {
}
}
-func testTarget(t *testing.T, target *prog.Target, full bool) {
+func testTarget(t *testing.T, target *prog.Target, full bool, ct *prog.ChoiceTable) {
rs := testutil.RandSource(t)
- p := target.Generate(rs, 10, target.DefaultChoiceTable())
+ p := target.Generate(rs, 10, ct)
// Turns out that fully minimized program can trigger new interesting warnings,
// e.g. about NULL arguments for functions that require non-NULL arguments in syz_ functions.
// We could append both AllSyzProg as-is and a minimized version of it,
diff --git a/prog/rand.go b/prog/rand.go
index d54ef0dfe..834003914 100644
--- a/prog/rand.go
+++ b/prog/rand.go
@@ -670,9 +670,9 @@ func (target *Target) PseudoSyscalls() []*Syscall {
}
// GenSampleProg generates a single sample program for the call.
-func (target *Target) GenSampleProg(meta *Syscall, rs rand.Source) *Prog {
+func (target *Target) GenSampleProg(meta *Syscall, rs rand.Source, ct *ChoiceTable) *Prog {
r := newRand(target, rs)
- s := newState(target, target.DefaultChoiceTable(), nil)
+ s := newState(target, ct, nil)
p := &Prog{
Target: target,
}
diff --git a/prog/target.go b/prog/target.go
index 300a86a32..b5d198f27 100644
--- a/prog/target.go
+++ b/prog/target.go
@@ -370,6 +370,17 @@ func (target *Target) DefaultChoiceTable() *ChoiceTable {
return target.defaultChoiceTable
}
+func (target *Target) NoAutoChoiceTable() *ChoiceTable {
+ calls := map[*Syscall]bool{}
+ for _, c := range target.Syscalls {
+ if c.Attrs.Automatic {
+ continue
+ }
+ calls[c] = true
+ }
+ return target.BuildChoiceTable(nil, calls)
+}
+
func (target *Target) RequiredGlobs() []string {
globs := make(map[string]bool)
ForeachType(target.Syscalls, func(typ Type, ctx *TypeCtx) {