@@ -10,13 +10,22 @@ import (
1010 "github.com/google/syzkaller/pkg/aflow/tool/codesearcher"
1111)
1212
13- type KCSANOutputs struct {
13+ type kcsanInputs struct {
14+ CrashReport string
15+ KernelRepo string
16+ KernelCommit string
17+ KernelConfig string
18+ CodesearchToolBin string
19+ }
20+
21+ type kcsanOutputs struct {
22+ Confident bool
1423 Benign bool
1524 Explanation string
1625}
1726
1827func init () {
19- aflow .Register [Inputs , KCSANOutputs ](
28+ aflow .Register [kcsanInputs , kcsanOutputs ](
2029 ai .WorkflowAssessmentKCSAN ,
2130 "assess if a KCSAN report is about a benign race that only needs annotations or not" ,
2231 & aflow.Flow {
@@ -29,11 +38,12 @@ func init() {
2938 Name : "expert" ,
3039 Reply : "Explanation" ,
3140 Outputs : aflow .LLMOutputs [struct {
32- Benign bool `jsonschema:"If the data race is benign or not."`
41+ Confident bool `jsonschema:"If you are confident in the verdict of the analysis or not."`
42+ Benign bool `jsonschema:"If the data race is benign or not."`
3343 }](),
3444 Temperature : 1 ,
35- Instruction : instruction ,
36- Prompt : prompt ,
45+ Instruction : kcsanInstruction ,
46+ Prompt : kcsanPrompt ,
3747 Tools : codesearcher .Tools ,
3848 },
3949 },
@@ -42,35 +52,33 @@ func init() {
4252 )
4353}
4454
45- const instruction = `
46- You are an experienced Linux kernel developer tasked with determining if the given kernel bug
47- report is actionable or not. Actionable means that it contains enough info to root cause
48- the underlying bug, and that the report is self-consistent and makes sense, rather than
49- a one-off nonsensical crash induced by a previous memory corruption.
50-
51- Use the provided tools to confirm any assumptions, what variables/fields being accessed, etc.
52- In particular, don't make assumptions about the kernel source code,
53- use codesearch tools to read the actual source code.
54-
55- The bug report is a data race report from KCSAN tool.
55+ const kcsanInstruction = `
56+ You are an experienced Linux kernel developer tasked with determining if the given kernel
57+ data race is benign or not. The data race report is from KCSAN tool.
5658It contains 2 stack traces of the memory accesses that constitute a data race.
57- The report would be inconsistent, if the stacks point to different subsystems,
58- or if they access different fields.
59- The report would be non-actionable, if the underlysing data race is "benign".
60- That is, the race is on a simple int/bool or similar field, and the accesses
61- are not supposed to be protected by any mutual exclusion primitives.
59+
60+ A "benign" data races are on a simple int/bool variable or similar field,
61+ and the accesses are not supposed to be protected by any mutual exclusion primitives.
6262Common examples of such "benign" data races are accesses to various flags fields,
63- statistics counters, and similar.
64- An actionable race is "harmful", that is can lead to corruption/crash even with
63+ statistics counters, and similar. A "benign" data race does not lead to memory corruption/crash
64+ with a conservative compiler that compiles memory accesses to primitive types
65+ effectively as atomic.
66+
67+ A non-benign (or "harmful" data race) can lead to corruption/crash even with
6568a conservative compiler that compiles memory accesses to primitive types
6669effectively as atomic. A common example of a "harmful" data races is race on
6770a complex container (list/hashmap/etc), where accesses are supposed to be protected
6871by a mutual exclusion primitive.
69- In the final reply explain why you think the report is consistent and the data race is harmful.
72+
73+ In the final reply explain why you think the given data race is benign or is harmful.
74+
75+ Use the provided tools to confirm any assumptions, variables/fields being accessed, etc.
76+ In particular, don't make assumptions about the kernel source code,
77+ use codesearch tools to read the actual source code.
7078`
7179
72- const prompt = `
73- The bug report is:
80+ const kcsanPrompt = `
81+ The data race report is:
7482
7583{{.CrashReport}}
7684`
0 commit comments