Commit Graph

14 Commits

Author SHA1 Message Date
Frank Denis
7334060f43 Add a workaround for old asan versions (CentOS 7) 2017-06-23 17:30:48 +02:00
Frank Denis
c3045e2cb0 Check that SIGSEGV handlers work
Tools such as ASAN may trap violations instead of our handlers,
making the sodium_utils{2,3} test fail.

This has been documented for a long time, but it's probably better
to detect this and ignore tests depending on working signal handlers.
2017-06-23 11:11:16 +02:00
Frank Denis
cac2dde218 Indent 2017-02-23 11:24:48 +01:00
Frank Denis
7afe93f9a2 Mark test functions as static and __attribute__ ((noreturn)) 2016-03-27 00:32:25 +01:00
Frank Denis
d91adb2cff Avoid implicit sodium_malloc(0) in tests 2016-03-25 10:50:52 +01:00
Frank Denis
a5ca5b1b25 Unused param 2016-03-06 14:00:18 +01:00
Frank Denis
771e32bd18 CompCert compatibility 2015-10-26 16:59:28 +01:00
Frank Denis
eb4e9e48f9 Turn ASAN errors into warnings in sodium_utils{2,3} tests 2015-04-24 15:11:29 +02:00
Frank Denis
d556a56c3c Add extra assert() in tests allocating memory on the heap. 2014-11-25 16:19:20 -08:00
Frank Denis
5437f8974d Don't expect signals to work in Javascript 2014-11-24 17:48:51 -08:00
Frank Denis
5fd91b8f0f SIGSEGV handlers are incompatible with -fsanitize=address 2014-10-16 14:08:43 -07:00
Frank Denis
82bc039d6c Consistent syle for the tests. 2014-09-14 11:32:55 -07:00
Frank Denis
4d276a81e7 Include header files commonly used by the tests to cmptest.h 2014-09-13 14:11:12 -07:00
Frank Denis
473e1718cc Add sodium_{malloc,allocarray,free}() and sodium_mprotect_*()
ptr = sodium_malloc(size) returns a pointer from which exactly "size" bytes
can be accessed.

ptr = sodium_allocarray(count, size) allocates enough storage space for
"count" pointers or scalars of unit size "size".

In both cases, the region is immediately followed by a guard page.
As a result, any attempt to access a memory location after ptr[size - 1] will
immediately trigger a segmentation fault.

The allocated region is mlock()ed and filled with 0xd0 bytes.

A read-only page with the size, a guard page, as well as a canary are
placed before the returned pointer.

The canary is checked by sodium_free(); as a result, altering data right
before ptr is likely to cause sodium_free() to kill the process.

sodium_free() munlock()s the region and fills it with zeros before
actually calling free().

sodium_mprotect_noaccess(), sodium_mprotect_readonly() and
sodium_mprotect_readwrite() can be used to change the protection on the set
of allocated pages.

Reverting the protection to read+write is not required before calling
sodium_free().
2014-08-14 21:41:05 -07:00