bind9/fuzz
Tony Finch 599c1d2a6b Avoid using C99 variable length arrays
From an attacker's point of view, a VLA declaration is essentially a
primitive for performing arbitrary arithmetic on the stack pointer. If
the attacker can control the size of a VLA they have a very powerful
tool for causing memory corruption.

To mitigate this kind of attack, and the more general class of stack
clash vulnerabilities, C compilers insert extra code when allocating a
VLA to probe the growing stack one page at a time. If these probes hit
the stack guard page, the program will crash.

From the point of view of a C programmer, there are a few things to
consider about VLAs:

  * If it is important to handle allocation failures in a controlled
    manner, don't use VLAs. You can use VLAs if it is OK for
    unreasonable inputs to cause an uncontrolled crash.

  * If the VLA is known to be smaller than some known fixed size,
    use a fixed size array and a run-time check to ensure it is large
    enough. This will be more efficient than the compiler's stack
    probes that need to cope with arbitrary-size VLAs.

  * If the VLA might be large, allocate it on the heap. The heap
    allocator can allocate multiple pages in one shot, whereas the
    stack clash probes work one page at a time.

Most of the existing uses of VLAs in BIND are in test code where they
are benign, but there was one instance in `named`, in the GSS-TSIG
verification code, which has now been removed.

This commit adjusts the style guide and the C compiler flags to allow
VLAs in test code but not elsewhere.
2022-03-18 15:11:48 +00:00
..
dns_master_load.in Add dns_master_loadbuffer() fuzzer 2022-02-24 10:02:56 +01:00
dns_message_parse.in Add packet from issue #4189 2020-09-30 13:24:29 +00:00
dns_name_fromtext_target.in oss-fuzz: Improve interaction with fuzzing tools and add new tests in fuzz/ directory 2018-08-23 10:07:28 +02:00
dns_rdata_fromtext.in Add seed that demonstrated INSIST triggered in isc_lex_gettoken 2022-03-01 16:05:39 -08:00
dns_rdata_fromwire_text.in add svcb fuzzing seed 2021-08-18 13:49:48 +10:00
isc_lex_getmastertoken.in Update the copyright information in all files in the repository 2022-01-11 09:05:02 +01:00
isc_lex_gettoken.in Update the copyright information in all files in the repository 2022-01-11 09:05:02 +01:00
.gitignore Add dns_rdata_fromtext() fuzzer 2022-02-24 11:12:06 +01:00
afl.sh Update the copyright information in all files in the repository 2022-01-11 09:05:02 +01:00
dns_master_load.c Add dns_master_loadbuffer() fuzzer 2022-02-24 10:02:56 +01:00
dns_message_parse.c Update the copyright information in all files in the repository 2022-01-11 09:05:02 +01:00
dns_name_fromtext_target.c Add dns_rdata_fromtext() fuzzer 2022-02-24 11:12:06 +01:00
dns_rdata_fromtext.c Add dns_rdata_fromtext() fuzzer 2022-02-24 11:12:06 +01:00
dns_rdata_fromwire_text.c Add dns_rdata_fromtext() fuzzer 2022-02-24 11:12:06 +01:00
fuzz.h Update the copyright information in all files in the repository 2022-01-11 09:05:02 +01:00
FUZZING.md Fix configure options in FUZZING.md 2022-02-24 11:12:02 +01:00
isc_lex_getmastertoken.c Update the copyright information in all files in the repository 2022-01-11 09:05:02 +01:00
isc_lex_gettoken.c Update the copyright information in all files in the repository 2022-01-11 09:05:02 +01:00
libfuzzer.sh Update the copyright information in all files in the repository 2022-01-11 09:05:02 +01:00
main.c Update the copyright information in all files in the repository 2022-01-11 09:05:02 +01:00
Makefile.am Avoid using C99 variable length arrays 2022-03-18 15:11:48 +00:00