You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[analyzer] MIGChecker: Fix an FN when the object is released in a destructor.
When a MIG server routine argument is released in an automatic destructor,
the Static Analyzer thinks that this happens after the return statement, and so
the violation of the MIG convention doesn't happen.
Of course, it doesn't quite work that way, so this is a false negative.
Add a hack that makes the checker double-check at the end of function
that no argument was released when the routine fails with an error.
rdar://problem/35380337
Differential Revision: https://reviews.llvm.org/D58392
llvm-svn: 354642
// expected-note@-1{{MIG callback fails with error after deallocating argument value. This is a use-after-free vulnerability because the caller will try to deallocate it again}}
57
57
}
58
58
59
+
// Make sure we find the bug when the object is destroyed within an
vm_deallocate(port, address, size); // expected-note{{Value passed through parameter 'address' is deallocated}}
69
+
}
70
+
} will_deallocate{port, address, size};
71
+
72
+
if (size > 10) {
73
+
// expected-note@-1{{Assuming 'size' is > 10}}
74
+
// expected-note@-2{{Taking true branch}}
75
+
return KERN_ERROR;
76
+
// expected-note@-1{{Calling '~WillDeallocate'}}
77
+
// expected-note@-2{{Returning from '~WillDeallocate'}}
78
+
// expected-warning@-3{{MIG callback fails with error after deallocating argument value. This is a use-after-free vulnerability because the caller will try to deallocate it again}}
79
+
// expected-note@-4 {{MIG callback fails with error after deallocating argument value. This is a use-after-free vulnerability because the caller will try to deallocate it again}}
80
+
}
81
+
return KERN_SUCCESS;
82
+
}
83
+
59
84
// Check that we work on Objective-C messages and blocks.
0 commit comments