SlideShare a Scribd company logo
Institute for System Programming of the Russian Academy of Sciences
Predicate Abstraction Based
Configurable Method for Data Race
Detection in Linux Kernel
Pavel Andrianov, Vadim Mutilin,
Alexey Khoroshilov
2
int global;
Race Condition
Thread 1
{
...
global = 1;
...
}
Thread 2
{
...
global = 2;
...
}
A situation, in which
simultaneous accesses
to the same memory
location take place from
several threads, one of
the accesses is write
3
Real Data Race
drivers/net/wireless/marvell/libertas/libertas.ko
disconnect:
…
kfree_skb(priv->currenttxskb);
priv->currenttxskb = NULL;
priv->tx_pending_len = 0;
...
transmit:
spin_lock(&priv->driver_lock, flags)
if (priv->currenttxskb == NULL)
return;
…
priv->currenttxskb->protocol =
eth_type_trans(priv->currenttxskb,
priv->dev);
netif_rx(priv->currenttxskb);
…
spin_unlock(&priv->driver_lock,
flags)
4
Commit
5
Motivation
●
Concurrency bugs make up 20% of all
across the file systems (A Study of Linux
File System Evolution, FAST'13)
●
Data race conditions make up 17% of all
errors in the Linux kernel (Analysis of
typical faults in Linux operating system
drivers, Proceedings ISP RAN)
6
Other Tools
Fast and imprecise Precise, but slow
Example: RELAY Example: Threader
Difficult to adjust a tool to a particular task
Adjustable analysis?
7
Lockset Algorithm
Potential data race is a situation, when
accesses to the same shared data occur
with disjoint sets of locks from two parallel
threads, one access is write.
8
Potential Race Condition
…
*a = 1;
...
…
mutex_lock();
*a = 1;
mutex_unlock();
...
●
A disjoint set of synchronization primitives
●
The same shared data
●
Accesses from different threads, which can be
executed simultaneously
●
Real (reachable) paths
9
Lightweight core algorithm
Method overview
A set of warnings
Lockset
algorithm
Shared
analysis
Heavyweight extensions
CEGAR
Thread
analysis
Precise warnings Imprecise warnings
10
Counter Example Guided Abstraction
Refinement
Error? Safe
Counterexample
Feasible?
Abstraction Refinement
Unsafe
No
Yes
YesNo
Solver
Analysis
Interpolation
11
Reachability analysis
based on predicate abstraction
{},[]
{},[]
{lock}, []
{}, []
{lock},[]
{}, []
{}, []
{}, []
{lock}, []
{lock}, []
{lock}, []
{}, []
{}, []
{}, []
int global;
int func(int var) {
if (var) {
lock();
}
global++;
if (var) {
unlock();
}
}
{}, []
12
Reachability analysis
based on predicate abstraction
{}
{}
{lock}, [var != 0]
{}, [var == 0]
{lock}
{}, [var != 0]
{}, [var == 0]
{}
{lock}, [var != 0]
{lock}, [var != 0]
{lock}, [var != 0]
{}, [var == 0]
{}, [var == 0]
{}, [var != 0]
int global;
int func(int var) {
if (var) {
lock();
}
global++;
if (var) {
unlock();
}
}
13
Two Ways of Refinement
Analysis
Refinement
Analysis
Refinement
14
Example of False Alarm
adm8211_start(dev)
adm8211_init_rings(dev)
request_irq(adm8211_interrupt)
dev->priv->tx_buffers[entry]->skb
adm8211_interrupt(dev)
dev->priv->tx_buffers[entry]->skb
15
Example of False Alarm
adm8211_start(dev)
adm8211_interrupt(dev)request_irq(adm8211_interrupt)
dev->priv->tx_buffers[entry]->skb
dev->priv->tx_buffers[entry]->skb
16
Example of Linux Driver
module_init()
catc_probe()
catc_open()
module_exit()
usb_register_driver()
register_netdev()
catc_close()
catc_disconnect()
unregister_netdev()
usb_deregister()
usb_driver net_device
17
Example of Model
entry_point usb_driver
handlers
usb_register_driver
usb_deregister()
net_device
handlers
register_netdev()
unregister_netdev()
18
Анализ разделяемых данных
struct my_struct {
int *b;
} *А;
int func() {
int *a;
a = malloc();
If
(undef_value) {
A->b = a;
}
*a = 1;
}
Доступ к разделяемым данным – потенциальная
гонка
{}
{a → local}
{a → local}
{a → shared}
{a → shared}
[undef_value !
= 0]
[undef_value
== 0]
19
Анализ примитивов
синхронизации
int global;
int func(int var) {
if (var) {
lock();
}
global++;
if (var) {
unlock();
}
}
{}
{}
{lock}
{} {lock}
{} {lock}
{} {lock}
{lock}
{}
{}
{}
{}
20
Thread Analysis
int global;
Int start() {
global = 0;
pthread_create(&thread, .., worker, ..);
pthread_join(&thread);
result = global;
}
{1.1}
{1.1}
{1.1, 2.1}{1.1}
{1.1, 2.1}{1.1, 2.0}
{1.1, 2.1}{1.1}
{1.1}
int worker() {
global++;
}
21
Method Overview
22
Results
Unsafes Unknowns Safes Time, h Memory, Gb
+ Threads,
+ Refinement
5 61 51 3.2 8.1
- Threads,
+ Refinement
6 67 44 4.1 4.0
+ Threads,
- Refinement
27 57 49 2.3 8.2
- Threads,
- Refinement
186 54 43 2.1 3.5
113 modules of OS Linux 4.5-rc1 subsystem drivers/net/wireless/
23
2219 warnings at drivers/
●
2219 warnings = 270 unsafe drivers
●
55% - imprecision of environment model
●
10% - simple memory model
●
10% - operations with lists
●
10% - other inaccuracies in our analysis
●
15% - true races
●
290 true warnings = 32 bugs
24
Conclusion
●
Flexible adjustment of the balance
between resources and accuracy
●
Applicable to industry projects
●
Real race conditions are found
25
Thank you!
Questions?

More Related Content

What's hot (20)

PPTX
Pro typescript.ch03.Object Orientation in TypeScript
Seok-joon Yun
 
PDF
Welcome to Modern C++
Seok-joon Yun
 
PDF
The mighty js_function
timotheeg
 
PPTX
How to add an optimization for C# to RyuJIT
Egor Bogatov
 
PDF
Qt Rest Server
Vasiliy Sorokin
 
PDF
OpenFOAM Programming Tips
Fumiya Nozaki
 
PDF
Rainer Grimm, “Functional Programming in C++11”
Platonov Sergey
 
PDF
Spatial Interpolation Schemes in OpenFOAM
Fumiya Nozaki
 
PDF
Joel Falcou, Boost.SIMD
Sergey Platonov
 
PDF
[FT-11][suhorng] “Poor Man's” Undergraduate Compilers
Functional Thursday
 
PDF
Limited Gradient Schemes in OpenFOAM
Fumiya Nozaki
 
ODP
Bluespec @waseda
Takefumi MIYOSHI
 
PPT
为什么 rust-lang 吸引我?
勇浩 赖
 
PDF
Коварный code type ITGM #9
Andrey Zakharevich
 
PPTX
Modeling FSMs
Mohamed Samy
 
PDF
Антон Нонко, Классические строки в C++
Sergey Platonov
 
PDF
第二回CTF勉強会資料
Asuka Nakajima
 
PDF
[ROOTCON13] Pilot Study on Semi-Automated Patch Diffing by Applying Machine-L...
Asuka Nakajima
 
PDF
CFD for Rotating Machinery using OpenFOAM
Fumiya Nozaki
 
PDF
Reverse Engineering Dojo: Enhancing Assembly Reading Skills
Asuka Nakajima
 
Pro typescript.ch03.Object Orientation in TypeScript
Seok-joon Yun
 
Welcome to Modern C++
Seok-joon Yun
 
The mighty js_function
timotheeg
 
How to add an optimization for C# to RyuJIT
Egor Bogatov
 
Qt Rest Server
Vasiliy Sorokin
 
OpenFOAM Programming Tips
Fumiya Nozaki
 
Rainer Grimm, “Functional Programming in C++11”
Platonov Sergey
 
Spatial Interpolation Schemes in OpenFOAM
Fumiya Nozaki
 
Joel Falcou, Boost.SIMD
Sergey Platonov
 
[FT-11][suhorng] “Poor Man's” Undergraduate Compilers
Functional Thursday
 
Limited Gradient Schemes in OpenFOAM
Fumiya Nozaki
 
Bluespec @waseda
Takefumi MIYOSHI
 
为什么 rust-lang 吸引我?
勇浩 赖
 
Коварный code type ITGM #9
Andrey Zakharevich
 
Modeling FSMs
Mohamed Samy
 
Антон Нонко, Классические строки в C++
Sergey Platonov
 
第二回CTF勉強会資料
Asuka Nakajima
 
[ROOTCON13] Pilot Study on Semi-Automated Patch Diffing by Applying Machine-L...
Asuka Nakajima
 
CFD for Rotating Machinery using OpenFOAM
Fumiya Nozaki
 
Reverse Engineering Dojo: Enhancing Assembly Reading Skills
Asuka Nakajima
 

Viewers also liked (20)

PDF
TMPA-2017: A Survey of High-Performance Computing for Software Verification
Iosif Itkin
 
PDF
TMPA-2017: Regression Testing with Semiautomatic Test Selection for Auditing ...
Iosif Itkin
 
PDF
TMPA-2017: Dl-Check: Dynamic Potential Deadlock Detection Tool for Java Programs
Iosif Itkin
 
PDF
TMPA-2017: Stemming Architectural Decay in Software Systems
Iosif Itkin
 
PDF
TMPA-2017: Modeling of PLC-programs by High-level Coloured Petri Nets
Iosif Itkin
 
PDF
TMPA-2017: Functional Parser of Markdown Language Based on Monad Combining an...
Iosif Itkin
 
PDF
TMPA-2017: Layered Layouts for Software Systems Visualization
Iosif Itkin
 
PDF
TMPA-2017: Extended Context-Free Grammars Parsing with Generalized LL
Iosif Itkin
 
PDF
TMPA-2017: Evolutionary Algorithms in Test Generation for digital systems
Iosif Itkin
 
PDF
TMPA-2017: Conference Opening
Iosif Itkin
 
PDF
TMPA-2017: Using Functional Directives to Analyze Code Complexity and Communi...
Iosif Itkin
 
PDF
TMPA-2017: Technology and Tools for Developing Industrial Software Test Suite...
Iosif Itkin
 
PDF
TMPA-2017: Static Checking of Array Objects in JavaScript
Iosif Itkin
 
PDF
TMPA-2017: 5W+1H Static Analysis Report Quality Measure
Iosif Itkin
 
PDF
TMPA-2017: Vellvm - Verifying the LLVM
Iosif Itkin
 
PDF
TMPA-2017: Defect Report Classification in Accordance with Areas of Testing
Iosif Itkin
 
PDF
TMPA-2017: Compositional Process Model Synthesis based on Interface Patterns
Iosif Itkin
 
PDF
TMPA-2017: Generating Cost Aware Covering Arrays For Free
Iosif Itkin
 
PDF
TMPA-2017: Live testing distributed system fault tolerance with fault injecti...
Iosif Itkin
 
PDF
TMPA-2017: Distributed Analysis of the BMC Kind: Making It Fit the Tornado Su...
Iosif Itkin
 
TMPA-2017: A Survey of High-Performance Computing for Software Verification
Iosif Itkin
 
TMPA-2017: Regression Testing with Semiautomatic Test Selection for Auditing ...
Iosif Itkin
 
TMPA-2017: Dl-Check: Dynamic Potential Deadlock Detection Tool for Java Programs
Iosif Itkin
 
TMPA-2017: Stemming Architectural Decay in Software Systems
Iosif Itkin
 
TMPA-2017: Modeling of PLC-programs by High-level Coloured Petri Nets
Iosif Itkin
 
TMPA-2017: Functional Parser of Markdown Language Based on Monad Combining an...
Iosif Itkin
 
TMPA-2017: Layered Layouts for Software Systems Visualization
Iosif Itkin
 
TMPA-2017: Extended Context-Free Grammars Parsing with Generalized LL
Iosif Itkin
 
TMPA-2017: Evolutionary Algorithms in Test Generation for digital systems
Iosif Itkin
 
TMPA-2017: Conference Opening
Iosif Itkin
 
TMPA-2017: Using Functional Directives to Analyze Code Complexity and Communi...
Iosif Itkin
 
TMPA-2017: Technology and Tools for Developing Industrial Software Test Suite...
Iosif Itkin
 
TMPA-2017: Static Checking of Array Objects in JavaScript
Iosif Itkin
 
TMPA-2017: 5W+1H Static Analysis Report Quality Measure
Iosif Itkin
 
TMPA-2017: Vellvm - Verifying the LLVM
Iosif Itkin
 
TMPA-2017: Defect Report Classification in Accordance with Areas of Testing
Iosif Itkin
 
TMPA-2017: Compositional Process Model Synthesis based on Interface Patterns
Iosif Itkin
 
TMPA-2017: Generating Cost Aware Covering Arrays For Free
Iosif Itkin
 
TMPA-2017: Live testing distributed system fault tolerance with fault injecti...
Iosif Itkin
 
TMPA-2017: Distributed Analysis of the BMC Kind: Making It Fit the Tornado Su...
Iosif Itkin
 
Ad

Similar to TMPA-2017: Predicate Abstraction Based Configurable Method for Data Race Detection in Linux Kernel (20)

PDF
Fast and Precise Symbolic Analysis of Concurrency Bugs in Device Drivers
Pantazis Deligiannis
 
PPT
Detecting and Preventing Memory Attacks#
gwarloki1
 
PDF
Describe synchronization techniques used by programmers who develop .pdf
excellentmobiles
 
PPT
the windows opereting system
Юсуф Сатторов
 
PPT
Earhart
siam hossain
 
PDF
Faults inside System Software
National Cheng Kung University
 
PDF
Linux Kernel Security Overview - KCA 2009
James Morris
 
PPTX
Ice Age melting down: Intel features considered usefull!
Peter Hlavaty
 
PDF
[USENIX-WOOT] Introduction to Procedural Debugging through Binary Libification
Moabi.com
 
PDF
Análise de malware com suporte de hardware
Marcus Botacin
 
PDF
Memory Barriers in the Linux Kernel
Davidlohr Bueso
 
PDF
Resilient IoT Security: The end of flat security models
Milosch Meriac
 
PDF
AOS Lab 4: If you liked it, then you should have put a “lock” on it
Zubair Nabi
 
PDF
Seminar
Aditya Ramaraju
 
PPSX
linux kernel overview 2013
Rohit Pratap Singh
 
PPT
Synchronization linux
Susant Sahani
 
PDF
Implementing a Security strategy in IoT, Practical example Automotive Grade L...
LibreCon
 
PDF
Linux Device Driver parallelism using SMP and Kernel Pre-emption
Hemanth Venkatesh
 
PDF
Never Trust Your Inputs
Alexander Bolshev
 
PDF
[Ruxcon 2011] Post Memory Corruption Memory Analysis
Moabi.com
 
Fast and Precise Symbolic Analysis of Concurrency Bugs in Device Drivers
Pantazis Deligiannis
 
Detecting and Preventing Memory Attacks#
gwarloki1
 
Describe synchronization techniques used by programmers who develop .pdf
excellentmobiles
 
the windows opereting system
Юсуф Сатторов
 
Earhart
siam hossain
 
Faults inside System Software
National Cheng Kung University
 
Linux Kernel Security Overview - KCA 2009
James Morris
 
Ice Age melting down: Intel features considered usefull!
Peter Hlavaty
 
[USENIX-WOOT] Introduction to Procedural Debugging through Binary Libification
Moabi.com
 
Análise de malware com suporte de hardware
Marcus Botacin
 
Memory Barriers in the Linux Kernel
Davidlohr Bueso
 
Resilient IoT Security: The end of flat security models
Milosch Meriac
 
AOS Lab 4: If you liked it, then you should have put a “lock” on it
Zubair Nabi
 
linux kernel overview 2013
Rohit Pratap Singh
 
Synchronization linux
Susant Sahani
 
Implementing a Security strategy in IoT, Practical example Automotive Grade L...
LibreCon
 
Linux Device Driver parallelism using SMP and Kernel Pre-emption
Hemanth Venkatesh
 
Never Trust Your Inputs
Alexander Bolshev
 
[Ruxcon 2011] Post Memory Corruption Memory Analysis
Moabi.com
 
Ad

More from Iosif Itkin (20)

PDF
Foundations of Software Testing Lecture 4
Iosif Itkin
 
PPTX
QA Financial Forum London 2021 - Automation in Software Testing. Humans and C...
Iosif Itkin
 
PDF
Exactpro FinTech Webinar - Global Exchanges Test Oracles
Iosif Itkin
 
PDF
Exactpro FinTech Webinar - Global Exchanges FIX Protocol
Iosif Itkin
 
PDF
Operational Resilience in Financial Market Infrastructures
Iosif Itkin
 
PDF
20 Simple Questions from Exactpro for Your Enjoyment This Holiday Season
Iosif Itkin
 
PDF
Testing the Intelligence of your AI
Iosif Itkin
 
PDF
EXTENT 2019: Exactpro Quality Assurance for Financial Market Infrastructures
Iosif Itkin
 
PDF
ClearTH Test Automation Framework: Case Study in IRS & CDS Swaps Lifecycle Mo...
Iosif Itkin
 
PPTX
EXTENT Talks 2019 Tbilisi: Failover and Recovery Test Automation - Ivan Shamrai
Iosif Itkin
 
PDF
EXTENT Talks QA Community Tbilisi 20 April 2019 - Conference Open
Iosif Itkin
 
PDF
User-Assisted Log Analysis for Quality Control of Distributed Fintech Applica...
Iosif Itkin
 
PPTX
QAFF Chicago 2019 - Complex Post-Trade Systems, Requirements Traceability and...
Iosif Itkin
 
PDF
QA Community Saratov: Past, Present, Future (2019-02-08)
Iosif Itkin
 
PDF
Machine Learning and RoboCop Testing
Iosif Itkin
 
PDF
Behaviour Driven Development: Oltre i limiti del possibile
Iosif Itkin
 
PDF
2018 - Exactpro Year in Review
Iosif Itkin
 
PPTX
Exactpro Discussion about Joy and Strategy
Iosif Itkin
 
PPTX
FIX EMEA Conference 2018 - Post Trade Software Testing Challenges
Iosif Itkin
 
PDF
BDD. The Outer Limits. Iosif Itkin at Youcon (in Russian)
Iosif Itkin
 
Foundations of Software Testing Lecture 4
Iosif Itkin
 
QA Financial Forum London 2021 - Automation in Software Testing. Humans and C...
Iosif Itkin
 
Exactpro FinTech Webinar - Global Exchanges Test Oracles
Iosif Itkin
 
Exactpro FinTech Webinar - Global Exchanges FIX Protocol
Iosif Itkin
 
Operational Resilience in Financial Market Infrastructures
Iosif Itkin
 
20 Simple Questions from Exactpro for Your Enjoyment This Holiday Season
Iosif Itkin
 
Testing the Intelligence of your AI
Iosif Itkin
 
EXTENT 2019: Exactpro Quality Assurance for Financial Market Infrastructures
Iosif Itkin
 
ClearTH Test Automation Framework: Case Study in IRS & CDS Swaps Lifecycle Mo...
Iosif Itkin
 
EXTENT Talks 2019 Tbilisi: Failover and Recovery Test Automation - Ivan Shamrai
Iosif Itkin
 
EXTENT Talks QA Community Tbilisi 20 April 2019 - Conference Open
Iosif Itkin
 
User-Assisted Log Analysis for Quality Control of Distributed Fintech Applica...
Iosif Itkin
 
QAFF Chicago 2019 - Complex Post-Trade Systems, Requirements Traceability and...
Iosif Itkin
 
QA Community Saratov: Past, Present, Future (2019-02-08)
Iosif Itkin
 
Machine Learning and RoboCop Testing
Iosif Itkin
 
Behaviour Driven Development: Oltre i limiti del possibile
Iosif Itkin
 
2018 - Exactpro Year in Review
Iosif Itkin
 
Exactpro Discussion about Joy and Strategy
Iosif Itkin
 
FIX EMEA Conference 2018 - Post Trade Software Testing Challenges
Iosif Itkin
 
BDD. The Outer Limits. Iosif Itkin at Youcon (in Russian)
Iosif Itkin
 

Recently uploaded (20)

PDF
The Growing Value and Application of FME & GenAI
Safe Software
 
PDF
Automating the Geo-Referencing of Historic Aerial Photography in Flanders
Safe Software
 
PPTX
Smarter Governance with AI: What Every Board Needs to Know
OnBoard
 
PDF
Hyderabad MuleSoft In-Person Meetup (June 21, 2025) Slides
Ravi Tamada
 
PDF
Salesforce Summer '25 Release Frenchgathering.pptx.pdf
yosra Saidani
 
PDF
ArcGIS Utility Network Migration - The Hunter Water Story
Safe Software
 
PDF
How to Visualize the ​Spatio-Temporal Data Using CesiumJS​
SANGHEE SHIN
 
PDF
Cracking the Code - Unveiling Synergies Between Open Source Security and AI.pdf
Priyanka Aash
 
PPTX
Curietech AI in action - Accelerate MuleSoft development
shyamraj55
 
PDF
Database Benchmarking for Performance Masterclass: Session 1 - Benchmarking F...
ScyllaDB
 
PPTX
Simplifica la seguridad en la nube y la detección de amenazas con FortiCNAPP
Cristian Garcia G.
 
PPTX
Paycifi - Programmable Trust_Breakfast_PPTXT
FinTech Belgium
 
PPTX
New ThousandEyes Product Innovations: Cisco Live June 2025
ThousandEyes
 
PDF
UiPath Agentic AI ile Akıllı Otomasyonun Yeni Çağı
UiPathCommunity
 
PPTX
Practical Applications of AI in Local Government
OnBoard
 
PDF
The Future of Product Management in AI ERA.pdf
Alyona Owens
 
PDF
LLM Search Readiness Audit - Dentsu x SEO Square - June 2025.pdf
Nick Samuel
 
PPTX
reInforce 2025 Lightning Talk - Scott Francis.pptx
ScottFrancis51
 
PDF
Why aren't you using FME Flow's CPU Time?
Safe Software
 
PPTX
Enabling the Digital Artisan – keynote at ICOCI 2025
Alan Dix
 
The Growing Value and Application of FME & GenAI
Safe Software
 
Automating the Geo-Referencing of Historic Aerial Photography in Flanders
Safe Software
 
Smarter Governance with AI: What Every Board Needs to Know
OnBoard
 
Hyderabad MuleSoft In-Person Meetup (June 21, 2025) Slides
Ravi Tamada
 
Salesforce Summer '25 Release Frenchgathering.pptx.pdf
yosra Saidani
 
ArcGIS Utility Network Migration - The Hunter Water Story
Safe Software
 
How to Visualize the ​Spatio-Temporal Data Using CesiumJS​
SANGHEE SHIN
 
Cracking the Code - Unveiling Synergies Between Open Source Security and AI.pdf
Priyanka Aash
 
Curietech AI in action - Accelerate MuleSoft development
shyamraj55
 
Database Benchmarking for Performance Masterclass: Session 1 - Benchmarking F...
ScyllaDB
 
Simplifica la seguridad en la nube y la detección de amenazas con FortiCNAPP
Cristian Garcia G.
 
Paycifi - Programmable Trust_Breakfast_PPTXT
FinTech Belgium
 
New ThousandEyes Product Innovations: Cisco Live June 2025
ThousandEyes
 
UiPath Agentic AI ile Akıllı Otomasyonun Yeni Çağı
UiPathCommunity
 
Practical Applications of AI in Local Government
OnBoard
 
The Future of Product Management in AI ERA.pdf
Alyona Owens
 
LLM Search Readiness Audit - Dentsu x SEO Square - June 2025.pdf
Nick Samuel
 
reInforce 2025 Lightning Talk - Scott Francis.pptx
ScottFrancis51
 
Why aren't you using FME Flow's CPU Time?
Safe Software
 
Enabling the Digital Artisan – keynote at ICOCI 2025
Alan Dix
 

TMPA-2017: Predicate Abstraction Based Configurable Method for Data Race Detection in Linux Kernel

  • 1. Institute for System Programming of the Russian Academy of Sciences Predicate Abstraction Based Configurable Method for Data Race Detection in Linux Kernel Pavel Andrianov, Vadim Mutilin, Alexey Khoroshilov
  • 2. 2 int global; Race Condition Thread 1 { ... global = 1; ... } Thread 2 { ... global = 2; ... } A situation, in which simultaneous accesses to the same memory location take place from several threads, one of the accesses is write
  • 3. 3 Real Data Race drivers/net/wireless/marvell/libertas/libertas.ko disconnect: … kfree_skb(priv->currenttxskb); priv->currenttxskb = NULL; priv->tx_pending_len = 0; ... transmit: spin_lock(&priv->driver_lock, flags) if (priv->currenttxskb == NULL) return; … priv->currenttxskb->protocol = eth_type_trans(priv->currenttxskb, priv->dev); netif_rx(priv->currenttxskb); … spin_unlock(&priv->driver_lock, flags)
  • 5. 5 Motivation ● Concurrency bugs make up 20% of all across the file systems (A Study of Linux File System Evolution, FAST'13) ● Data race conditions make up 17% of all errors in the Linux kernel (Analysis of typical faults in Linux operating system drivers, Proceedings ISP RAN)
  • 6. 6 Other Tools Fast and imprecise Precise, but slow Example: RELAY Example: Threader Difficult to adjust a tool to a particular task Adjustable analysis?
  • 7. 7 Lockset Algorithm Potential data race is a situation, when accesses to the same shared data occur with disjoint sets of locks from two parallel threads, one access is write.
  • 8. 8 Potential Race Condition … *a = 1; ... … mutex_lock(); *a = 1; mutex_unlock(); ... ● A disjoint set of synchronization primitives ● The same shared data ● Accesses from different threads, which can be executed simultaneously ● Real (reachable) paths
  • 9. 9 Lightweight core algorithm Method overview A set of warnings Lockset algorithm Shared analysis Heavyweight extensions CEGAR Thread analysis Precise warnings Imprecise warnings
  • 10. 10 Counter Example Guided Abstraction Refinement Error? Safe Counterexample Feasible? Abstraction Refinement Unsafe No Yes YesNo Solver Analysis Interpolation
  • 11. 11 Reachability analysis based on predicate abstraction {},[] {},[] {lock}, [] {}, [] {lock},[] {}, [] {}, [] {}, [] {lock}, [] {lock}, [] {lock}, [] {}, [] {}, [] {}, [] int global; int func(int var) { if (var) { lock(); } global++; if (var) { unlock(); } } {}, []
  • 12. 12 Reachability analysis based on predicate abstraction {} {} {lock}, [var != 0] {}, [var == 0] {lock} {}, [var != 0] {}, [var == 0] {} {lock}, [var != 0] {lock}, [var != 0] {lock}, [var != 0] {}, [var == 0] {}, [var == 0] {}, [var != 0] int global; int func(int var) { if (var) { lock(); } global++; if (var) { unlock(); } }
  • 13. 13 Two Ways of Refinement Analysis Refinement Analysis Refinement
  • 14. 14 Example of False Alarm adm8211_start(dev) adm8211_init_rings(dev) request_irq(adm8211_interrupt) dev->priv->tx_buffers[entry]->skb adm8211_interrupt(dev) dev->priv->tx_buffers[entry]->skb
  • 15. 15 Example of False Alarm adm8211_start(dev) adm8211_interrupt(dev)request_irq(adm8211_interrupt) dev->priv->tx_buffers[entry]->skb dev->priv->tx_buffers[entry]->skb
  • 16. 16 Example of Linux Driver module_init() catc_probe() catc_open() module_exit() usb_register_driver() register_netdev() catc_close() catc_disconnect() unregister_netdev() usb_deregister() usb_driver net_device
  • 17. 17 Example of Model entry_point usb_driver handlers usb_register_driver usb_deregister() net_device handlers register_netdev() unregister_netdev()
  • 18. 18 Анализ разделяемых данных struct my_struct { int *b; } *А; int func() { int *a; a = malloc(); If (undef_value) { A->b = a; } *a = 1; } Доступ к разделяемым данным – потенциальная гонка {} {a → local} {a → local} {a → shared} {a → shared} [undef_value ! = 0] [undef_value == 0]
  • 19. 19 Анализ примитивов синхронизации int global; int func(int var) { if (var) { lock(); } global++; if (var) { unlock(); } } {} {} {lock} {} {lock} {} {lock} {} {lock} {lock} {} {} {} {}
  • 20. 20 Thread Analysis int global; Int start() { global = 0; pthread_create(&thread, .., worker, ..); pthread_join(&thread); result = global; } {1.1} {1.1} {1.1, 2.1}{1.1} {1.1, 2.1}{1.1, 2.0} {1.1, 2.1}{1.1} {1.1} int worker() { global++; }
  • 22. 22 Results Unsafes Unknowns Safes Time, h Memory, Gb + Threads, + Refinement 5 61 51 3.2 8.1 - Threads, + Refinement 6 67 44 4.1 4.0 + Threads, - Refinement 27 57 49 2.3 8.2 - Threads, - Refinement 186 54 43 2.1 3.5 113 modules of OS Linux 4.5-rc1 subsystem drivers/net/wireless/
  • 23. 23 2219 warnings at drivers/ ● 2219 warnings = 270 unsafe drivers ● 55% - imprecision of environment model ● 10% - simple memory model ● 10% - operations with lists ● 10% - other inaccuracies in our analysis ● 15% - true races ● 290 true warnings = 32 bugs
  • 24. 24 Conclusion ● Flexible adjustment of the balance between resources and accuracy ● Applicable to industry projects ● Real race conditions are found