Skip to content

Commit 429f194

Browse files
committed
Fix UAF in is_callable() and allocated trampoline
By nulling out the function_handler, so it will not get used below. Reuse the existing helper for this purpose.
1 parent 4346576 commit 429f194

File tree

2 files changed

+28
-7
lines changed

2 files changed

+28
-7
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
--TEST--
2+
is_callable() with trampoline should not caused UAF
3+
--FILE--
4+
<?php
5+
6+
class B {}
7+
class A extends B {
8+
public function bar($func) {
9+
var_dump(is_callable(array('parent', 'foo')));
10+
}
11+
12+
public function __call($func, $args) {
13+
}
14+
}
15+
16+
class X {
17+
public static function __callStatic($func, $args) {
18+
}
19+
}
20+
21+
$a = new A();
22+
// Extra X::foo() wrapper to force use of allocated trampoline.
23+
X::foo($a->bar('foo'));
24+
25+
?>
26+
--EXPECT--
27+
bool(false)

Zend/zend_API.c

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3154,13 +3154,7 @@ static zend_always_inline int zend_is_callable_check_func(int check_flags, zval
31543154
if (strict_class &&
31553155
(!fcc->function_handler->common.scope ||
31563156
!instanceof_function(ce_org, fcc->function_handler->common.scope))) {
3157-
if (fcc->function_handler->common.fn_flags & ZEND_ACC_CALL_VIA_TRAMPOLINE) {
3158-
if (fcc->function_handler->type != ZEND_OVERLOADED_FUNCTION &&
3159-
fcc->function_handler->common.function_name) {
3160-
zend_string_release_ex(fcc->function_handler->common.function_name, 0);
3161-
}
3162-
zend_free_trampoline(fcc->function_handler);
3163-
}
3157+
zend_release_fcall_info_cache(fcc);
31643158
} else {
31653159
retval = 1;
31663160
call_via_handler = (fcc->function_handler->common.fn_flags & ZEND_ACC_CALL_VIA_TRAMPOLINE) != 0;

0 commit comments

Comments
 (0)