File tree Expand file tree Collapse file tree 4 files changed +25
-4
lines changed
rules/guardaccesstobitfields
test/rules/guardaccesstobitfields Expand file tree Collapse file tree 4 files changed +25
-4
lines changed Original file line number Diff line number Diff line change 1
1
- ` CON53-CPP ` - ` DeadlockByLockingInPredefinedOrder.ql `
2
2
- Optimized performance and expanded coverage to include cases where locking
3
- order is not serialized
3
+ order is not serialized
4
+ - ` CON52-CPP ` - ` PreventBitFieldAccessFromMultipleThreads.ql `
5
+ - Fixed an issue with RAII-style locks and scope causing locks to not be
6
+ correctly identified.
Original file line number Diff line number Diff line change @@ -318,7 +318,7 @@ class RAIIStyleLock extends LockingOperation {
318
318
*/
319
319
override predicate isLock ( ) {
320
320
this instanceof ConstructorCall and
321
- lock = getArgument ( 0 ) .getAChild ( ) and
321
+ lock = getArgument ( 0 ) .getAChild * ( ) and
322
322
// defer_locks don't cause a lock
323
323
not exists ( Expr exp |
324
324
exp = getArgument ( 1 ) and
Original file line number Diff line number Diff line change @@ -42,6 +42,24 @@ ControlFlowNode getAReachableLockCFN(MutexFunctionCall mfc) {
42
42
query predicate problems ( BitFieldAccess ba , string message ) {
43
43
not isExcluded ( ba , getQuery ( ) ) and
44
44
ba instanceof ThreadedCFN and
45
- not ba instanceof LockProtectedControlFlowNode and
45
+ // to be a valid bit field access there must be
46
+ // a RAII-style lock before this access
47
+ not exists ( RAIIStyleLock lock |
48
+ // A lock came before this node
49
+ lock = ba .getAPredecessor * ( ) and
50
+ lock .isLock ( ) and
51
+ // But wasn't followed by an unlock
52
+ not exists ( RAIIStyleLock unlock |
53
+ // That worked on the same underlying lock variable
54
+ unlock .isUnlock ( ) and
55
+ unlock .getLock ( ) = lock .getLock ( ) and
56
+ // such that the unlock came after the lock
57
+ unlock .getAPredecessor * ( ) = lock and
58
+ // and after before the access
59
+ ba .getAPredecessor * ( ) = unlock
60
+ )
61
+ ) and
62
+ // or the bit field access must be protected by a lock region
63
+ not exists ( MutexFunctionCall mfc | ba = getAReachableLockCFN ( mfc ) ) and
46
64
message = "Access to a bit-field without a concurrency guard."
47
65
}
Original file line number Diff line number Diff line change 1
1
| test.cpp:67:7:67:8 | f2 | Access to a bit-field without a concurrency guard. |
2
2
| test.cpp:91:7:91:8 | f2 | Access to a bit-field without a concurrency guard. |
3
- | test.cpp:97 :7:97 :8 | f2 | Access to a bit-field without a concurrency guard. |
3
+ | test.cpp:102 :7:102 :8 | f2 | Access to a bit-field without a concurrency guard. |
You can’t perform that action at this time.
0 commit comments