1
mirror of https://github.com/jedisct1/libsodium.git synced 2024-12-24 04:25:10 -07:00

Handle SIGPROT, CHERI's in-address space security exception

This commit is contained in:
Frank Denis 2023-09-12 19:07:25 +02:00
parent b6bcb3dc22
commit a589d64b42
6 changed files with 670 additions and 596 deletions

1243
build-aux/config.guess vendored

File diff suppressed because it is too large Load Diff

3
configure vendored
View File

@ -10271,6 +10271,9 @@ main (void)
volatile unsigned char * volatile x = (volatile unsigned char *) malloc(8); volatile unsigned char * volatile x = (volatile unsigned char *) malloc(8);
size_t i; size_t i;
#ifdef SIGPROT
signal(SIGPROT, sig);
#endif
signal(SIGSEGV, sig); signal(SIGSEGV, sig);
signal(SIGBUS, sig); signal(SIGBUS, sig);
#if !defined(__SANITIZE_ADDRESS__) && !defined(__EMSCRIPTEN__) #if !defined(__SANITIZE_ADDRESS__) && !defined(__EMSCRIPTEN__)

View File

@ -21,6 +21,9 @@ static void sig(int _) { exit(0); }
volatile unsigned char * volatile x = (volatile unsigned char *) malloc(8); volatile unsigned char * volatile x = (volatile unsigned char *) malloc(8);
size_t i; size_t i;
#ifdef SIGPROT
signal(SIGPROT, sig);
#endif
signal(SIGSEGV, sig); signal(SIGSEGV, sig);
signal(SIGBUS, sig); signal(SIGBUS, sig);
#if !defined(__SANITIZE_ADDRESS__) && !defined(__EMSCRIPTEN__) #if !defined(__SANITIZE_ADDRESS__) && !defined(__EMSCRIPTEN__)

View File

@ -79,6 +79,7 @@ void *alloca (size_t);
defined(HAVE_POSIX_MEMALIGN) defined(HAVE_POSIX_MEMALIGN)
# define HAVE_ALIGNED_MALLOC # define HAVE_ALIGNED_MALLOC
#endif #endif
#if defined(HAVE_MPROTECT) && \ #if defined(HAVE_MPROTECT) && \
!(defined(PROT_NONE) && defined(PROT_READ) && defined(PROT_WRITE)) !(defined(PROT_NONE) && defined(PROT_READ) && defined(PROT_WRITE))
# undef HAVE_MPROTECT # undef HAVE_MPROTECT
@ -507,7 +508,9 @@ __attribute__((noreturn)) static void
_out_of_bounds(void) _out_of_bounds(void)
{ {
# if defined(HAVE_RAISE) && !defined(__wasm__) # if defined(HAVE_RAISE) && !defined(__wasm__)
# ifdef SIGSEGV # ifdef SIGPROT
raise(SIGPROT);
# elif defined(SIGSEGV)
raise(SIGSEGV); raise(SIGSEGV);
# elif defined(SIGKILL) # elif defined(SIGKILL)
raise(SIGKILL); raise(SIGKILL);

View File

@ -29,6 +29,9 @@ segv_handler(int sig)
printf("Intentional segfault / bus error caught\n"); printf("Intentional segfault / bus error caught\n");
printf("OK\n"); printf("OK\n");
#ifdef SIG_DFL #ifdef SIG_DFL
# ifdef SIGPROT
signal(SIGPROT, SIG_DFL);
# endif
# ifdef SIGSEGV # ifdef SIGSEGV
signal(SIGSEGV, SIG_DFL); signal(SIGSEGV, SIG_DFL);
# endif # endif
@ -82,6 +85,9 @@ main(void)
} }
printf("OK\n"); printf("OK\n");
#ifdef SIG_DFL #ifdef SIG_DFL
# ifdef SIGPROT
signal(SIGPROT, segv_handler);
# endif
# ifdef SIGSEGV # ifdef SIGSEGV
signal(SIGSEGV, segv_handler); signal(SIGSEGV, segv_handler);
# endif # endif

View File

@ -25,6 +25,9 @@ segv_handler(int sig)
printf("Intentional segfault / bus error caught\n"); printf("Intentional segfault / bus error caught\n");
printf("OK\n"); printf("OK\n");
#ifdef SIG_DFL #ifdef SIG_DFL
# ifdef SIGPROT
signal(SIGPROT, SIG_DFL);
# endif
# ifdef SIGSEGV # ifdef SIGSEGV
signal(SIGSEGV, SIG_DFL); signal(SIGSEGV, SIG_DFL);
# endif # endif
@ -49,6 +52,9 @@ main(void)
#endif #endif
#ifdef SIG_DFL #ifdef SIG_DFL
# ifdef SIGPROT
signal(SIGPROT, segv_handler);
# endif
# ifdef SIGSEGV # ifdef SIGSEGV
signal(SIGSEGV, segv_handler); signal(SIGSEGV, segv_handler);
# endif # endif