fragattacks/src
Nick Kralevich d447cd596f Updates for stricter automatic memcpy bounds checking
Both Android's libc and glibc support _FORTIFY_SOURCE, a compiler
and libc feature which inserts automatic bounds checking into
common C functions such as memcpy() and strcpy(). If a buffer
overflow occurs when calling a hardened libc function, the
automatic bounds checking will safely shutdown the program and
prevent memory corruption.

Android is experimenting with _FORTIFY_SOURCE=3, a new fortify
level which enhances memcpy() to prevent overflowing an element
of a struct. Under the enhancements, code such as

  struct foo {
    char empty[0];
    char one[1];
    char a[10];
    char b[10];
  };

  int main() {
    foo myfoo;
    int n = atoi("11");
    memcpy(myfoo.a, "01234567890123456789", n);
    return 0;
  }

will cleanly crash when the memcpy() call is made.

Fixup hostap code to support the new level. Specifically:

* Fixup sha1_transform so it works with the enhanced bounds checking.
The old memcpy() code was attempting to write to context.h0, but that
structure element is too small and the write was extending (by design)
into h1, h2, h3, and h4. Use explicit assignments instead of
overflowing the struct element.

* Modify most of the structures in ieee802_11_defs.h to use ISO C99
flexible array members (https://gcc.gnu.org/onlinedocs/gcc/Zero-Length.html)
instead of a zero length array. Zero length arrays have zero length,
and any attempt to call memcpy() on such elements will always overflow.
Flexible array members have no such limitation. The only element not
adjusted is probe_req, since doing so will generate a compile time error,
and it's not obvious to me how to fix it.

Signed-off-by: Nick Kralevich <nnk@google.com>
2015-04-13 14:01:40 +03:00
..
ap AP: Enable multicast snooping on bridge if ProxyARP IPv6 is in use 2015-04-13 14:00:32 +03:00
common Updates for stricter automatic memcpy bounds checking 2015-04-13 14:01:40 +03:00
crypto Updates for stricter automatic memcpy bounds checking 2015-04-13 14:01:40 +03:00
drivers AP: Enable multicast snooping on bridge if ProxyARP IPv6 is in use 2015-04-13 14:00:32 +03:00
eap_common Make tls_connection_get_keyblock_size() internal to tls_*.c 2015-04-01 12:56:54 +03:00
eap_peer EAP peer: Use 32-bit EAP method type for Phase 2 processing 2015-04-01 12:57:11 +03:00
eap_server EAP-PEAP server: Add support for negotiating vendor for Phase 2 2015-04-01 12:57:11 +03:00
eapol_auth Check os_snprintf() result more consistently - automatic 1 2014-12-08 11:42:07 +02:00
eapol_supp eap_proxy: Callback to notify any updates from eap_proxy 2015-03-02 12:47:20 +02:00
l2_packet Fix Linux packet socket workaround to not close the socket too easily 2015-02-22 16:06:13 +02:00
p2p P2PS: Delete ASP advertisements on wpas_p2p_service_flush 2015-03-20 15:56:59 +02:00
pae MACsec: Update protect frames and replay on reauthentication 2014-12-09 16:56:10 +02:00
radius Improve error messages related to EAP DB 2015-03-28 13:16:26 +02:00
rsn_supp Show OSEN key management properly in scan results 2015-03-25 16:04:03 +02:00
tls Remove master key extraction from tls_connection_get_keys() 2015-03-31 15:52:40 +03:00
utils Add wpa_snprintf_hex_sep() 2015-03-29 22:27:43 +03:00
wps P2PS: WPS changes needed for P2PS default PIN 2015-02-02 16:55:45 +02:00
lib.rules Add QUIET=1 option for make 2014-12-29 15:49:05 +02:00
Makefile MACsec: Add PAE implementation 2014-05-09 20:42:44 +03:00