Skip to content

Commit 8f574c3

Browse files
committed
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.
1 parent bf6fe8f commit 8f574c3

File tree

3 files changed

+23
-8
lines changed

3 files changed

+23
-8
lines changed

pkg/csource/csource_test.go

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@ func TestGenerate(t *testing.T) {
3838
t.Parallel()
3939
checked := make(map[string]bool)
4040
for _, target := range prog.AllTargets() {
41+
// Auto-generated descriptions currently do not properly mark arch-specific syscalls, see
42+
// https://github.com/google/syzkaller/issues/5410#issuecomment-3570190241.
43+
// Until it's fixed, let's remove these syscalls from csource tests.
44+
ct := target.NoAutoChoiceTable()
4145
sysTarget := targets.Get(target.OS, target.Arch)
4246
if runtime.GOOS != sysTarget.BuildOS {
4347
continue
@@ -50,32 +54,32 @@ func TestGenerate(t *testing.T) {
5054
if full || !testing.Short() {
5155
checked[target.OS] = true
5256
t.Parallel()
53-
testTarget(t, target, full)
57+
testTarget(t, target, full, ct)
5458
}
55-
testPseudoSyscalls(t, target)
59+
testPseudoSyscalls(t, target, ct)
5660
})
5761
}
5862
}
5963

60-
func testPseudoSyscalls(t *testing.T, target *prog.Target) {
64+
func testPseudoSyscalls(t *testing.T, target *prog.Target, ct *prog.ChoiceTable) {
6165
// Use options that are as minimal as possible.
6266
// We want to ensure that the code can always be compiled.
6367
opts := Options{
6468
Slowdown: 1,
6569
}
6670
rs := testutil.RandSource(t)
6771
for _, meta := range target.PseudoSyscalls() {
68-
p := target.GenSampleProg(meta, rs)
72+
p := target.GenSampleProg(meta, rs, ct)
6973
t.Run(fmt.Sprintf("single_%s", meta.CallName), func(t *testing.T) {
7074
t.Parallel()
7175
testOne(t, p, opts)
7276
})
7377
}
7478
}
7579

76-
func testTarget(t *testing.T, target *prog.Target, full bool) {
80+
func testTarget(t *testing.T, target *prog.Target, full bool, ct *prog.ChoiceTable) {
7781
rs := testutil.RandSource(t)
78-
p := target.Generate(rs, 10, target.DefaultChoiceTable())
82+
p := target.Generate(rs, 10, ct)
7983
// Turns out that fully minimized program can trigger new interesting warnings,
8084
// e.g. about NULL arguments for functions that require non-NULL arguments in syz_ functions.
8185
// We could append both AllSyzProg as-is and a minimized version of it,

prog/rand.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -670,9 +670,9 @@ func (target *Target) PseudoSyscalls() []*Syscall {
670670
}
671671

672672
// GenSampleProg generates a single sample program for the call.
673-
func (target *Target) GenSampleProg(meta *Syscall, rs rand.Source) *Prog {
673+
func (target *Target) GenSampleProg(meta *Syscall, rs rand.Source, ct *ChoiceTable) *Prog {
674674
r := newRand(target, rs)
675-
s := newState(target, target.DefaultChoiceTable(), nil)
675+
s := newState(target, ct, nil)
676676
p := &Prog{
677677
Target: target,
678678
}

prog/target.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -370,6 +370,17 @@ func (target *Target) DefaultChoiceTable() *ChoiceTable {
370370
return target.defaultChoiceTable
371371
}
372372

373+
func (target *Target) NoAutoChoiceTable() *ChoiceTable {
374+
calls := map[*Syscall]bool{}
375+
for _, c := range target.Syscalls {
376+
if c.Attrs.Automatic {
377+
continue
378+
}
379+
calls[c] = true
380+
}
381+
return target.BuildChoiceTable(nil, calls)
382+
}
383+
373384
func (target *Target) RequiredGlobs() []string {
374385
globs := make(map[string]bool)
375386
ForeachType(target.Syscalls, func(typ Type, ctx *TypeCtx) {

0 commit comments

Comments
 (0)