Skip to content

Commit baf1c8d

Browse files
authored
Create cve-2016-6480.ql
1 parent 597603a commit baf1c8d

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import cpp
2+
3+
class CopyFromUserFunctionCall extends FunctionCall{
4+
CopyFromUserFunctionCall(){
5+
this.getTarget().getName() = "copy_from_user"
6+
and not this.getArgument(1) instanceof AddressOfExpr
7+
}
8+
9+
predicate hasSameArguments(CopyFromUserFunctionCall another){
10+
this.getArgument(0).toString() = another.getArgument(0).toString()
11+
and this.getArgument(1).toString() = another.getArgument(1).toString()
12+
}
13+
14+
}
15+
16+
from CopyFromUserFunctionCall p1, CopyFromUserFunctionCall p2
17+
where
18+
not p1 = p2
19+
and p1.hasSameArguments(p2)
20+
and exists(IfStmt ifStmt|
21+
p1.getBasicBlock().getAFalseSuccessor*() = ifStmt.getBasicBlock()
22+
and ifStmt.getBasicBlock().getAFalseSuccessor*() = p2.getBasicBlock()
23+
)
24+
and not exists(AssignPointerAddExpr assignPtrAdd |
25+
p1.getArgument(1).toString() = assignPtrAdd.getLValue().toString()
26+
and p1.getBasicBlock().getAFalseSuccessor*() = assignPtrAdd.getBasicBlock()
27+
)
28+
select
29+
"first fetch", p1, "double fetch", p2
30+
31+
32+
33+
34+

0 commit comments

Comments
 (0)