File tree Expand file tree Collapse file tree 1 file changed +35
-0
lines changed Expand file tree Collapse file tree 1 file changed +35
-0
lines changed Original file line number Diff line number Diff line change
1
+ /**
2
+ * @name Missing fd_rwlock Unlock
3
+ * @description Finds functions where a fd_rwlock is returned on some
4
+ * but not all branches. Currently, this query does not model the
5
+ * locked data and has no concept of lock semantics (an fd_rwlock_unread
6
+ * does not unlock a fd_rwlock_write). If we would ever encounter FPs
7
+ * related to this we can later add this more precise modeling.
8
+ * @kind problem
9
+ * @problem.severity warning
10
+ * @precision high
11
+ * @id asymmetric-research/missing-rwlock-unlock
12
+ */
13
+
14
+ import cpp
15
+
16
+ class LockCall extends FunctionCall {
17
+ LockCall ( ) { this .getTarget ( ) .hasName ( [ "fd_rwlock_read" , "fd_rwlock_write" ] ) }
18
+ }
19
+
20
+ class UnlockCall extends FunctionCall {
21
+ UnlockCall ( ) { this .getTarget ( ) .hasName ( [ "fd_rwlock_unread" , "fd_rwlock_unwrite" ] ) }
22
+ }
23
+
24
+ ControlFlowNode nextNoUnlock ( ControlFlowNode n ) {
25
+ not result instanceof UnlockCall and
26
+ result = n .getASuccessor ( )
27
+ }
28
+
29
+ predicate noUnlock ( LockCall l ) { exists ( ReturnStmt r | r = nextNoUnlock * ( l ) ) }
30
+
31
+ from LockCall l
32
+ where
33
+ l .getASuccessor * ( ) instanceof UnlockCall and
34
+ noUnlock ( l )
35
+ select l , "Missing unlock"
You can’t perform that action at this time.
0 commit comments