Commit graph

78 commits

Author SHA1 Message Date
Niels Dossche
1fe7dc31ef
Fix -Wstrict-prototypes warnings in fuzzer SAPI (#11277) 2023-05-20 11:43:30 +02:00
Alex Dowad
5f2587eb25 php-fuzz-mbstring also tests text encoding validation functions
In 6fc8d014df, pakutoma added specialized validation functions for
ISO-2022-JP, JIS, UTF-7, and UTF7-IMAP text. In the future, it is
possible we might add such functions for more legacy text encodings.
Allowing them to be tested by php-fuzz-mbstring may help to catch
bugs, both now and in the future.
2023-03-27 08:17:49 +02:00
Ilija Tovilo
9d5f2f1343
Use new ZSTR_INIT_LITERAL macro (#10879) 2023-03-20 16:19:05 +01:00
Dmitry Stogov
5c5707d44d Make fuzzer respect ZEND_MMAP_AHEAD
Fixes oss-fuzz #55654
2023-02-07 13:13:05 +03:00
Alex Dowad
d5d9900661 When fuzzing mbstring encoding conversion code, compare output with different intermediate buffer sizes
Currently, php-fuzz-mbstring only confirms that no crashes (including
ASAN violations) occur when converting text from one encoding to
another.

Try performing each conversion operation with two different sizes for
the intermediate buffer which is used to pass data from the decoder to
the encoder. If the encoding conversion code is correct, the size of
that intermediate buffer shouldn't matter; we should always get exactly
the same results.

This is a much stricter test, which is more likely to catch bugs.
2023-02-05 20:04:05 +02:00
Max Kellermann
d53ad4b566 main/SAPI: make "ini_entries" a const string 2023-01-04 12:49:48 +00:00
Nikita Popov
5f0cbcff3a Don't set rpath for fuzzers
We used to use the rpath for loading libonig, but this is both no
longer needed and breaks under SystemSan.
2022-09-17 15:44:58 +02:00
Nikita Popov
828c93bedc Fix unserialize dictionary generation
We now have namespaced classes in here, and need to escape the
backslashes.
2022-07-30 17:14:22 +02:00
Alex Dowad
492021168d php_mb_convert_encoding{,_ex} returns zend_string
That's what all existing callers want anyways. This avoids 2
unnecessary copies of the converted string.
2022-05-28 21:53:39 +02:00
Alex Dowad
0154a5ac9f Use fast text conversion filters to implement php_mb_convert_encoding_ex 2022-05-28 21:53:38 +02:00
Nikita Popov
9e87be4395 Add generate_mbstring_dict.php
Forgot to git add it previously.
2022-05-09 09:13:21 +02:00
Nikita Popov
1584352e19 Add fuzzer for mb_convert_encoding
This uses the php-fuzz-mbstring name, moving the existing fuzzer
to php-fuzz-mbregex.
2022-05-08 22:34:23 +02:00
George Peter Banyard
b5db594fd2
Refacto php_module_startup() (#8303)
It only ever uses at most 1 additional modules
2022-04-27 23:07:11 +01:00
David CARLIER
20d8561ed4
fuzzer support for FreeBSD, getting opcache location
Closes GH-7926.
2022-01-18 15:04:42 +01:00
Tyson Andre
9a59417445
[skip ci] Document how to quickly check if jit .dasc files transpile, how to test the jit in different architectures. (#7768) 2021-12-19 10:12:35 -05:00
Nikita Popov
39a1cab471 Generate tracing jit corpus in generate_all.php
Using same corpus as function jit. To allow oss-fuzz integration.
2021-10-11 14:33:11 +02:00
Nikita Popov
5d05f810d0 Reduce max input size in parser fuzzer
Still seeing stack overflows for $$$$$x style input, let's reduce
the input size limit further...
2021-10-06 19:14:20 +02:00
codinghuang
5bda4cd25a Support specifying start position in compile_string
Add additional zend_compile_position argument, which can be either
AT_SHEBANG, AT_OPEN_TAG or AFTER_OPEN_TAG. The previous behavior
corresponds to AFTER_OPEN_TAG.

Closes GH-7462.
2021-09-30 10:21:33 +02:00
Nikita Popov
83fccc68d7 Consistently set bailed_out flag
It was not set for some of the bailouts, resulting in timeouts
in the function JIT fuzzer.

Fixes oss-fuzz #39293.
2021-09-28 12:16:22 +02:00
Nikita Popov
a12aee5cb3 Fix opcache path determination, again
We shouldn't be appending to the executable path, but rather to
the directory of the executable.
2021-09-24 16:27:44 +02:00
Nikita Popov
b732b6d06f Try to fetch opcache.so path relative to binary
While the cwd-relative lookup worked for the oss-fuzz docker images,
it doesn't seem to work on the cluster infrastructure. Try finding
opcache.so relative to the binary instead.
2021-09-23 16:44:03 +02:00
Nikita Popov
40aa6b63d1 Further limit max input size in parser fuzzer
It's easy to cause stack overflows with degenerate cases like
"$$$$$x" repeated thousands of times. We have no interest in
addressing these.

Make the input size smaller to hopefully avoid these stack
overflows.
2021-09-23 13:11:21 +02:00
Nikita Popov
b7409d3a63 Disable chdir in execute fuzzers
We don't want the current working directory to change during
fuzzing, as that breaks corpus access unless an absolute path is
used. I'm not sure why this issue never came up before.
2021-09-22 12:58:20 +02:00
Nikita Popov
831a2b3c3d Disable custom execute_ex during function JIT fuzzing as well
Having zend_execute_ex set is normally not a problem for the
function JIT, but there is an edge case leak due to special
RELEASE_THIS handling during generator creation. As this is an
unsupported mode of operation, reset to the original handler
for the function jit fuzzer as well.
2021-09-22 12:48:52 +02:00
Nikita Popov
b3d37e9c91 Generate function-jit corpus in generate_all.php
For use by oss-fuzz.
2021-09-22 11:06:22 +02:00
Nikita Popov
9d0c018668 Make sure dummy file for fuzzing exists 2021-09-22 10:58:25 +02:00
Nikita Popov
06a25c774d Add fuzzer for tracing jit 2021-09-22 10:32:46 +02:00
Nikita Popov
cd4243dde9 Add fuzzer for function JIT
This is a basic fuzzer for the function JIT, which looks for
crashes and sanitizer violations only, and does not try to detect
differing behavior yet.
2021-09-15 17:12:39 +02:00
Nikita Popov
74033b2cc6 Don't hardcode used sanitizers in fuzzer
Now that we have generic --enable-address|undefined|memory-sanitizer
options, let the user pick one of these instead of making the fuzzer
enable one implicitly.
2021-09-15 16:07:26 +02:00
Nikita Popov
0f926815ca Fix strict-prototypes warning 2021-08-30 10:43:21 +02:00
Nikita Popov
93a88a1d4c Limit internal function args during fuzzing
Restrict the size of string arguments in the hope of avoiding some
very common timeouts with pcre. If this doesn't work, the functions
need to be disabled entirely.
2021-08-26 15:08:23 +02:00
Nikita Popov
cae80ef552 Limit internal function calls in execute fuzzer
Infinite recursion might occur purely through internal functions,
without reentering the executor.
2021-08-26 14:42:45 +02:00
Nikita Popov
600dc57f24 Add ext/reflection to execute parser corpus 2021-07-04 12:31:14 +02:00
Nikita Popov
ef938d5ee4 Revert "Disable destructors on fuzzer bailout"
This reverts commit ed33262dbb.

With adjusted bailout handling in fibers, this should no longer
be necessary.
2021-05-07 23:06:20 +02:00
Nikita Popov
ed33262dbb Disable destructors on fuzzer bailout
This is what we normally do for fatal errors. The reason why this
became necessary now, is that a bailout can switch from a fiber
back to the main stack. In that case we do not want to try
destroying the fiber.

Fixes oss-fuzz #33917.
2021-05-06 18:42:38 +02:00
KsaR
01b3fc03c3
Update http->https in license (#6945)
1. Update: http://www.php.net/license/3_01.txt to https, as there is anyway server header "Location:" to https.
2. Update few license 3.0 to 3.01 as 3.0 states "php 5.1.1, 4.1.1, and earlier".
3. In some license comments is "at through the world-wide-web" while most is without "at", so deleted.
4. fixed indentation in some files before |
2021-05-06 12:16:35 +02:00
Nikita Popov
dfe8dbdc0d Destroy file handle earlier in execute fuzzer
I'm not quite sure why this is relevant, but if matches what other
code does and fixes oss-fuzz #32517.
2021-04-15 12:55:58 +02:00
Josh Soref
462da6e09c Fix spelling and grammar mistakes
This PR corrects misspellings identified by the check-spelling action.

The misspellings have been reported at jsoref@b6ba3e2#commitcomment-48946465

The action reports that the changes in this PR would make it happy: jsoref@602417c

Closes GH-6822.
2021-04-13 12:09:37 +02:00
Nikita Popov
5da23eb46c Free static variables in execute fuzzer
Fixes a leak in the seed corpus.
2021-03-26 11:59:14 +01:00
Dmitry Stogov
c732ab400a Change Zend Stream API to use zend_string* instead of char*.
This allows to eliminate re-calculation of string lenght and hash value.
See the detailed list of changes in UPGRADING.INTERNALS.
2021-03-16 20:31:36 +03:00
Nikita Popov
3e01f5afb1 Replace zend_bool uses with bool
We're starting to see a mix between uses of zend_bool and bool.
Replace all usages with the standard bool type everywhere.

Of course, zend_bool is retained as an alias.
2021-01-15 12:33:06 +01:00
Nikita Popov
3b542021e4 Fuzzer: Gracefully handle hashes that cannot be serialized 2021-01-11 15:45:43 +01:00
Nikita Popov
4643c0aac5 Add additional entries to unserialize corpus
These are useful to seed typed property fuzzing.
2020-11-30 14:32:07 +01:00
Nikita Popov
99a68775bf Fix mbstring fuzzer
mb_ereg can throw now, so we need a dummy frame and need to
free the exception afterwards.
2020-09-11 18:35:16 +02:00
Nikita Popov
af0ba0b2d3 Reduce input size limit in execute fuzzer
We only have 4 Zend test cases > 8k. Large inputs tend to just
make things slower.
2020-09-07 22:58:34 +02:00
Nikita Popov
9475bcbef7 Avoid large eval inputs in fuzzer
While we limit the size of the main compilation input, the size
of eval inputs was not limited. This could result in stack
overflows, e.g. oss-fuzz #25464.
2020-09-07 11:53:01 +02:00
Nikita Popov
2f95af996f Disable InfiniteIterator class while fuzzing
The combination of LimitIterator and InfiniteIterator can cause
effectively infinite loops that bypass the executor step limit.
2020-09-04 10:59:55 +02:00
Nikita Popov
05cd31ef64 Extend function blacklist in execute fuzzer
Add pfsockopen and stream_socket_server.
2020-09-02 17:30:19 +02:00
Nikita Popov
f0dfdca0ae Fix execute fuzzer on i386
Opcode handlers use the FASTCALL calling convention...
2020-08-28 17:03:54 +02:00
Nikita Popov
bb1d0319d7 Fix typo
This was supposed to include the header, not the C file...
2020-08-27 16:57:09 +02:00