-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathbad_init_calls.ql
More file actions
27 lines (25 loc) · 971 Bytes
/
bad_init_calls.ql
File metadata and controls
27 lines (25 loc) · 971 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
/**
* Find functions not annotated with __init (or similar) which call
* __init-annotated functions. These instances are potential bugs.
*
* Examples:
* - https://stackoverflow.com/a/70823863/3889449
* - https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=45967ffb9e50aa3472cc6c69a769ef0f09cced5d
* - https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=5f117033243488a0080f837540c27999aa31870e
*/
import cpp
import utils
from KernelFunc func, KernelFunc caller, FunctionCall call
where
(func.isInSection(".init.text") or func.isInSection(".head.text"))
and call = func.getACallToThisFunction()
and caller = call.getEnclosingFunction()
and not caller.isInline()
and not caller.isInSection(".init.text")
and not caller.isInSection(".ref.text")
and not caller.isInSection(".head.text")
select
func as InitFunc,
caller as Caller,
call.getEnclosingStmt() as Statement,
call.getLocation() as Location