diff --git a/pkg/csource/csource_test.go b/pkg/csource/csource_test.go index 1dae0202d1ee..9e9dadf86526 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 d54ef0dfee9e..834003914fe0 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 300a86a32656..b5d198f27e27 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) {