Commit Graph

11 Commits

Author SHA1 Message Date
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
f379ab8766 Add a test for sodium_allocarray(0, x) 2015-03-23 21:47:44 +01:00
Frank Denis
5e364632e0 Make sodium_free() callable even if protection is PROT_NONE.
Reported by @stouset, thanks!
2014-12-07 14:52:44 -08: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
1cf170a90e Test sodium_allocarray(), and sodium_malloc() with a huge size 2014-09-16 15:35:21 -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