-
- Downloads
hashx: allow hashx_compile to fail, avoid segfault without changing API
This is a minimal portion of the fix for tor issue #40794, in which
hashx segfaults due to denial of mprotect() syscalls at runtime.
Prior to this fix, hashx makes the assumption that if the JIT is
supported on the current architecture, it will also be usable at
runtime. This isn't true if mprotect fails on linux, which it may for
various reasons: the tor built-in sandbox, the shadow simulator, or
external security software that implements a syscall filter.
The necessary error propagation was missing internally in hashx,
causing us to obliviously call into code which was never made
executable. With this fix, hashx_make() will instead fail by returning
zero.
A proper fix will require API changes so that callers can discern
between different types of failures. Zero already means that a program
couldn't be constructed, which requires a different response: choosing a
different seed, vs switching implementations. Callers would also benefit
from a way to use one context (with its already-built program) to
run in either compiled or interpreted mode.
Signed-off-by:
Micah Elizabeth Scott <beth@torproject.org>
Showing
- src/ext/equix/hashx/src/compiler.h 3 additions, 3 deletionssrc/ext/equix/hashx/src/compiler.h
- src/ext/equix/hashx/src/compiler_a64.c 6 additions, 3 deletionssrc/ext/equix/hashx/src/compiler_a64.c
- src/ext/equix/hashx/src/compiler_x86.c 4 additions, 3 deletionssrc/ext/equix/hashx/src/compiler_x86.c
- src/ext/equix/hashx/src/hashx.c 3 additions, 1 deletionsrc/ext/equix/hashx/src/hashx.c
- src/ext/equix/hashx/src/virtual_memory.c 15 additions, 13 deletionssrc/ext/equix/hashx/src/virtual_memory.c
- src/ext/equix/hashx/src/virtual_memory.h 3 additions, 2 deletionssrc/ext/equix/hashx/src/virtual_memory.h
Loading
Please register or sign in to comment