Dynamically Inferring Temporal Properties for Daisy

Download Report

Transcript Dynamically Inferring Temporal Properties for Daisy

Dynamically Inferring Temporal
Properties for Daisy
Jinlin Yang and David Evans
[jinlin, evans]@cs.virginia.edu
Department of Computer Science
University of Virginia
Joint ISSTA/CAV special event
07/14/2004
Outline
• Overview of our approach
• Experiment on Daisy
Jinlin Yang
Joint ISSTA/CAV special event
07/14/2004
2
Temporal Properties
• Example: lock/unlock
• Essential for program’s correctness
• Hard for humans to document correctly
[Holzmann, FSE ’02 keynote]
• Can we infer them automatically?
Yes!
Jinlin Yang
Joint ISSTA/CAV special event
07/14/2004
3
Our Approach
[Yang and Evans, Paste04]
Test Suite
Jinlin Yang
Execution
Traces
Inference
Instrumented
Program
Testing
Instrumentation
Program
Inferred
Properties
Candidate
Property
Patterns
Joint ISSTA/CAV special event
07/14/2004
4
Program Verification
Satisfaction or
Counterexamples
Report Generation
Validation
Dynamic Inference
Program
Inferred
Properties
Derived
Properties
Report
Model
Jinlin Yang
Joint ISSTA/CAV special event
07/14/2004
5
Program Evolution
[Yang and Evans, ISSRE04]
Jinlin Yang
Inferred
Properties 1
Inferred
Properties 2
Joint ISSTA/CAV special event
07/14/2004
Difference Analyzer
Program
Version 2
Dynamic Inference
Program
Version 1
Shared
Properties
Different
Properties
6
Implementation
Test Suite
•
•
•
•
Execution
Traces
Inference
Instrumented
Program
Testing
Instrumentation
Program
Inferred
Properties
Candidate
Property
Patterns
Automated testing and inference
Instrumentation and properties diff by hand
900 lines of Perl code
93 different events, 100 traces, each has 222 events on average:
less than an hour
Jinlin Yang
Joint ISSTA/CAV special event
07/14/2004
7
Previous Results
• OpenSSL [Yang and Evans, ISSRE04]
• Widely used implementation of the Secure
Socket Layer protocol
• 6 versions [0.9.6, 0.9.7, 0.9.7a-d]
• We focus on the handshake protocol
• Highlight of results
– Two previously detected bugs
– One infinite loop
– One documented improvement
Jinlin Yang
Joint ISSTA/CAV special event
07/14/2004
8
Outline
• Overview of our approach
• Experiment on Daisy
Jinlin Yang
Joint ISSTA/CAV special event
07/14/2004
9
Test Driver
• Input
– X: Number of files (fixed)
– Y: Number of threads (fixed)
– Z: Seed (0 to 99)
• Thread
– Executing N operations and then stop (N=10)
– Randomly chosen from read, write, set_attr, get_attr
performed on randomly chosen files
• Experimented up to 2 files, and 3 threads
• One interesting race condition
Jinlin Yang
Joint ISSTA/CAV special event
07/14/2004
10
Locking Mechanism
Multiple threads accessing one file
Works
Two threads accessing two different
files
Doesn’t work!!
Jinlin Yang
Joint ISSTA/CAV special event
07/14/2004
11
Disk Abstraction
• Disk (Petal class)
– RandomAccessFile
– Shared by all threads
byte read(n){
}
Jinlin Yang
void write(n, b){
……
……
RAF.seek(n);
RAF.read();
RAF.seek(n);
RAF.write(b);
……
……
}
Joint ISSTA/CAV special event
07/14/2004
12
Race Condition
……
RAF.seek(n);
RAF.seek(m);
RAF.read();
……
Race condition!!
Jinlin Yang
Joint ISSTA/CAV special event
07/14/2004
13
Fix
• Synchronized access to RandomAccessFile
byte synchronized
read(n){
void synchronized
write(n, b){
……
……
RAF.seek(n);
RAF.read();
RAF.seek(n);
RAF.write(b);
……
……
}
Jinlin Yang
}
Joint ISSTA/CAV special event
07/14/2004
14
Inference Results
• Didn’t infer very interesting properties
– Inferred properties can be inferred by static
analysis
• Possible ways to improve?
– Finer-grained events
– Track object values
– Including create, unlink, lookup operations
– Including some faulty behaviors
– New patterns
Jinlin Yang
Joint ISSTA/CAV special event
07/14/2004
15
Conclusion
• Bounded Exhaustive Testing is powerful
• Need to identify more interesting events
– Can we automatically identify interesting events?
• Identifying more useful patterns
– Combine data-flow with events
– More expressive, more events
Jinlin Yang
Joint ISSTA/CAV special event
07/14/2004
16
Thank You!
[email protected]
http://www.cs.virginia.edu/jinlin
http://www.cs.virginia.edu/ipa
Jinlin Yang
Joint ISSTA/CAV special event
07/14/2004
17