aboutsummaryrefslogtreecommitdiffstats
path: root/syz-verifier
diff options
context:
space:
mode:
authorMara Mihali <maramihali@google.com>2021-07-16 13:46:09 +0000
committermaramihali <maramihali@google.com>2021-07-19 14:47:11 +0300
commit64cf57a6b334e2af959a3bbcfb51211b45d23cd5 (patch)
tree6178f1d2dd86bf63a0245a423d66887e7bf538c5 /syz-verifier
parentb8e37dc1fbe8fe39f929cb3157a2ed2edee335e3 (diff)
syz-verifier: only record states that produced mismatches in stats.CallStats.States
Diffstat (limited to 'syz-verifier')
-rw-r--r--syz-verifier/main_test.go20
-rw-r--r--syz-verifier/stats/stats.go3
-rw-r--r--syz-verifier/stats/stats_test.go2
-rw-r--r--syz-verifier/verf/verifier.go2
-rw-r--r--syz-verifier/verf/verifier_test.go10
5 files changed, 18 insertions, 19 deletions
diff --git a/syz-verifier/main_test.go b/syz-verifier/main_test.go
index 9ba08c955..84574b452 100644
--- a/syz-verifier/main_test.go
+++ b/syz-verifier/main_test.go
@@ -418,9 +418,9 @@ func TestProcessResults(t *testing.T) {
wantStats: &stats.Stats{
TotalMismatches: 1,
Calls: map[string]*stats.CallStats{
- "breaks_returns": makeCallStats("breaks_returns", 1, 0, map[int]bool{1: true}),
+ "breaks_returns": makeCallStats("breaks_returns", 1, 0, map[int]bool{}),
"test$res0": makeCallStats("test$res0", 1, 1, map[int]bool{2: true, 5: true}),
- "minimize$0": makeCallStats("minimize$0", 1, 0, map[int]bool{3: true}),
+ "minimize$0": makeCallStats("minimize$0", 1, 0, map[int]bool{}),
},
},
},
@@ -432,9 +432,9 @@ func TestProcessResults(t *testing.T) {
},
wantStats: &stats.Stats{
Calls: map[string]*stats.CallStats{
- "breaks_returns": makeCallStats("breaks_returns", 1, 0, map[int]bool{11: true}),
- "minimize$0": makeCallStats("minimize$0", 1, 0, map[int]bool{33: true}),
- "test$res0": makeCallStats("test$res0", 1, 0, map[int]bool{22: true}),
+ "breaks_returns": makeCallStats("breaks_returns", 1, 0, map[int]bool{}),
+ "minimize$0": makeCallStats("minimize$0", 1, 0, map[int]bool{}),
+ "test$res0": makeCallStats("test$res0", 1, 0, map[int]bool{}),
},
},
},
@@ -530,9 +530,9 @@ func TestCleanup(t *testing.T) {
}},
wantStats: &stats.Stats{
Calls: map[string]*stats.CallStats{
- "breaks_returns": makeCallStats("breaks_returns", 1, 0, map[int]bool{11: true}),
- "minimize$0": makeCallStats("minimize$0", 1, 0, map[int]bool{33: true}),
- "test$res0": makeCallStats("test$res0", 1, 0, map[int]bool{22: true}),
+ "breaks_returns": makeCallStats("breaks_returns", 1, 0, map[int]bool{}),
+ "minimize$0": makeCallStats("minimize$0", 1, 0, map[int]bool{}),
+ "test$res0": makeCallStats("test$res0", 1, 0, map[int]bool{}),
},
},
fileExists: false,
@@ -552,8 +552,8 @@ func TestCleanup(t *testing.T) {
wantStats: &stats.Stats{
TotalMismatches: 1,
Calls: map[string]*stats.CallStats{
- "breaks_returns": makeCallStats("breaks_returns", 1, 0, map[int]bool{11: true}),
- "minimize$0": makeCallStats("minimize$0", 1, 0, map[int]bool{33: true}),
+ "breaks_returns": makeCallStats("breaks_returns", 1, 0, map[int]bool{}),
+ "minimize$0": makeCallStats("minimize$0", 1, 0, map[int]bool{}),
"test$res0": makeCallStats("test$res0", 1, 1, map[int]bool{22: true, 44: true}),
},
},
diff --git a/syz-verifier/stats/stats.go b/syz-verifier/stats/stats.go
index 46a94dfb6..4f004f385 100644
--- a/syz-verifier/stats/stats.go
+++ b/syz-verifier/stats/stats.go
@@ -34,8 +34,7 @@ type CallStats struct {
// Occurrences is the number of times the system call appeared in a
// verified program.
Occurrences int
- // States stores all possible kernel return values identified for the
- // system call.
+ // States stores the kernel return values that caused mismatches.
States map[int]bool
}
diff --git a/syz-verifier/stats/stats_test.go b/syz-verifier/stats/stats_test.go
index 765c7ac51..e82fd5d4c 100644
--- a/syz-verifier/stats/stats_test.go
+++ b/syz-verifier/stats/stats_test.go
@@ -17,7 +17,7 @@ func getTestStats() *Stats {
"foo": {"foo", 2, 8, map[int]bool{11: true, 3: true}},
"bar": {"bar", 5, 6, map[int]bool{10: true, 22: true}},
"tar": {"tar", 3, 4, map[int]bool{31: true, 100: true, 101: true}},
- "biz": {"biz", 0, 2, map[int]bool{4: true}},
+ "biz": {"biz", 0, 2, map[int]bool{}},
},
}
}
diff --git a/syz-verifier/verf/verifier.go b/syz-verifier/verf/verifier.go
index 1dea156ad..be948b862 100644
--- a/syz-verifier/verf/verifier.go
+++ b/syz-verifier/verf/verifier.go
@@ -59,7 +59,6 @@ func Verify(res []*Result, prog *prog.Prog, s *stats.Stats) *ResultReport {
rr.Reports = append(rr.Reports, cr)
cs := s.Calls[call]
cs.Occurrences++
- cs.States[c.Errno] = true
}
var send bool
@@ -76,6 +75,7 @@ func Verify(res []*Result, prog *prog.Prog, s *stats.Stats) *ResultReport {
s.TotalMismatches++
cs.Mismatches++
cs.States[c.Errno] = true
+ cs.States[c0[idx].Errno] = true
}
cr.Errnos[resi.Pool] = c.Errno
diff --git a/syz-verifier/verf/verifier_test.go b/syz-verifier/verf/verifier_test.go
index 6494c32b4..abca505d4 100644
--- a/syz-verifier/verf/verifier_test.go
+++ b/syz-verifier/verf/verifier_test.go
@@ -47,9 +47,9 @@ func TestVerify(t *testing.T) {
wantReport: nil,
wantStats: &stats.Stats{
Calls: map[string]*stats.CallStats{
- "breaks_returns": {Name: "breaks_returns", Occurrences: 1, States: map[int]bool{11: true}},
- "minimize$0": {Name: "minimize$0", Occurrences: 1, States: map[int]bool{33: true}},
- "test$res0": {Name: "test$res0", Occurrences: 1, States: map[int]bool{22: true}},
+ "breaks_returns": {Name: "breaks_returns", Occurrences: 1, States: map[int]bool{}},
+ "minimize$0": {Name: "minimize$0", Occurrences: 1, States: map[int]bool{}},
+ "test$res0": {Name: "test$res0", Occurrences: 1, States: map[int]bool{}},
},
},
},
@@ -73,8 +73,8 @@ func TestVerify(t *testing.T) {
wantStats: &stats.Stats{
TotalMismatches: 1,
Calls: map[string]*stats.CallStats{
- "breaks_returns": {Name: "breaks_returns", Occurrences: 1, States: map[int]bool{1: true}},
- "minimize$0": {Name: "minimize$0", Occurrences: 1, States: map[int]bool{3: true}},
+ "breaks_returns": {Name: "breaks_returns", Occurrences: 1, States: map[int]bool{}},
+ "minimize$0": {Name: "minimize$0", Occurrences: 1, States: map[int]bool{}},
"test$res0": {Name: "test$res0", Occurrences: 1, Mismatches: 1, States: map[int]bool{2: true, 5: true}},
},
},