@@ -4,10 +4,6 @@ import bindings
44import field
55import callbacks
66
7- /**
8- * Dataflow library for tracking unretained or retained types in a callback.
9- */
10-
117/**
128 * An assignment to a callback field.
139 */
@@ -26,26 +22,30 @@ predicate runCallbackSink(DataFlow::Node sink) {
2622 * An expression that posts a callback to a task runner.
2723 */
2824predicate postTaskSink ( DataFlow:: Node sink ) {
29- exists ( FunctionCall postTask | postTask .getTarget ( ) .getName ( ) .matches ( "PostTask%" ) or
30- postTask .getTarget ( ) .getName ( ) = "PostDelayedTask" |
25+ exists ( FunctionCall postTask |
26+ postTask .getTarget ( ) .getName ( ) .matches ( "PostTask%" ) or
27+ postTask .getTarget ( ) .getName ( ) = "PostDelayedTask"
28+ |
3129 postTask .getAnArgument ( ) = sink .asExpr ( )
3230 )
3331}
3432
3533/**
3634 * Callback gets passed inside an interface pointer function. The idea is that such a
37- * callback may then be called from the renderer. (A bit like
35+ * callback may then be called from the renderer. (A bit like
3836 * https://bugs.chromium.org/p/project-zero/issues/detail?id=1755
3937 * )
4038 */
4139predicate interfacePtrCallSink ( DataFlow:: Node sink ) {
42- exists ( FunctionCall mojom , InterfacePtr iPtr , Function interfaceFunc |
40+ exists ( FunctionCall mojom , InterfacePtr iPtr , Function interfaceFunc |
4341 overrides * ( mojom .getTarget ( ) , interfaceFunc ) and
4442 interfaceFunc .getDeclaringType ( ) = iPtr .getInterfaceType ( ) and
4543 sink .asExpr ( ) = mojom .getAnArgument ( )
46- ) or
47- exists ( BindCall bc , InterfacePtr iPtr , Function interfaceFunc |
48- overrides * ( bc .getFunction ( ) , interfaceFunc ) and interfaceFunc .getDeclaringType ( ) = iPtr .getInterfaceType ( ) and
44+ )
45+ or
46+ exists ( BindCall bc , InterfacePtr iPtr , Function interfaceFunc |
47+ overrides * ( bc .getFunction ( ) , interfaceFunc ) and
48+ interfaceFunc .getDeclaringType ( ) = iPtr .getInterfaceType ( ) and
4949 sink .asExpr ( ) = bc .getAnArgument ( ) and
5050 sink .asExpr ( ) != bc .getArgument ( 0 )
5151 )
@@ -59,25 +59,20 @@ predicate callbackArgSink(DataFlow::Node sink) {
5959}
6060
6161class CallbackConfig extends DataFlow:: Configuration {
62- CallbackConfig ( ) {
63- this = "callbackconfig"
64- }
65-
62+ CallbackConfig ( ) { this = "callbackconfig" }
63+
6664 override predicate isSource ( DataFlow:: Node source ) {
6765 (
68- exists ( GeneralCallback fc |
69- source .asExpr ( ) = fc
70- )
66+ exists ( GeneralCallback fc | source .asExpr ( ) = fc )
7167 or
7268 exists ( CallbackField f | source .asExpr ( ) = f .getAnAccess ( ) )
73- )
74- and
69+ ) and
7570 not source .asExpr ( ) .getFile ( ) .getBaseName ( ) = "bind.h" and
76- not source .asExpr ( ) .getFile ( ) .getBaseName ( ) = "callback_helpers.h" // and
71+ not source .asExpr ( ) .getFile ( ) .getBaseName ( ) = "callback_helpers.h" // and
7772 }
78-
73+
7974 override predicate isSink ( DataFlow:: Node sink ) {
80- (
75+ (
8176 isCallbackFieldSink ( sink )
8277 or
8378 runCallbackSink ( sink )
@@ -87,7 +82,7 @@ class CallbackConfig extends DataFlow::Configuration {
8782 interfacePtrCallSink ( sink )
8883 or
8984 callbackArgSink ( sink )
90- ) and
85+ ) and
9186 (
9287 //Exclude sinks that are in uninteresting files.
9388 not sink .asExpr ( ) .getFile ( ) .getBaseName ( ) = "bind_internal.h" and
@@ -103,15 +98,21 @@ class CallbackConfig extends DataFlow::Configuration {
10398 sink .asExpr ( ) .fromSource ( )
10499 )
105100 }
106-
101+
107102 override predicate isAdditionalFlowStep ( DataFlow:: Node node1 , DataFlow:: Node node2 ) {
108- callbackStep ( node1 , node2 ) or
109- collectionsEdge ( node1 , node2 ) or
110- getEdge ( node1 , node2 ) or
111- generalAssignEdge ( node1 , node2 ) or
112- exists ( Parameter p | p = node1 .asParameter ( ) and
103+ callbackStep ( node1 , node2 )
104+ or
105+ collectionsEdge ( node1 , node2 )
106+ or
107+ getEdge ( node1 , node2 )
108+ or
109+ generalAssignEdge ( node1 , node2 )
110+ or
111+ exists ( Parameter p |
112+ p = node1 .asParameter ( ) and
113113 node2 .asExpr ( ) = p .getAnAccess ( )
114- ) or
114+ )
115+ or
115116 copyConstructorEdge ( node1 , node2 )
116117 or
117118 pointerTransferEdge ( node1 , node2 )
@@ -134,4 +135,4 @@ class CallbackConfig extends DataFlow::Configuration {
134135 or
135136 forRangeEdge ( node1 , node2 )
136137 }
137- }
138+ }
0 commit comments