Segs / Segs.dev

For segs.io config, scripts, themes, and issues
BSD 3-Clause "New" or "Revised" License
2 stars 0 forks source link

Clang binaries causing exit codes other than 0 #37

Closed ldilley closed 5 years ago

ldilley commented 5 years ago

@dracc and void from Discord reported earlier this morning that web-based account registration was not working properly on blue. Upon inspection, it was found that dbtool compiled with the clang address and undefined behavior sanitizers cause an exit code other than 0 to be returned even upon successful account creation. With leak detection enabled, it returns 1 as noted below.

[segs@blue out]$ ./dbtool adduser -a 1 -l testuser93 -p testpass

Press ENTER to continue...

==23019==LeakSanitizer has encountered a fatal error.
==23019==HINT: For debugging, try setting environment variable LSAN_OPTIONS=verbosity=1:log_threads=1
==23019==HINT: LeakSanitizer does not work under ptrace (strace, gdb, etc)
[segs@blue out]$ $?
-bash: 1: command not found

Leak detection can be disabled as a workaround by setting the following environment variables:

export ASAN_OPTIONS=abort_on_error=1:detect_leaks=0:verbosity=1:log_threads=1
export LSAN_OPTIONS=abort_on_error=1:detect_leaks=0:verbosity=1:log_threads=1

This will likely make dbtool return 0 again. Once #34 is implemented and used instead, the above will no longer be an issue.

ldilley commented 5 years ago

During hardening, the kernel parameter kernel.yama.ptrace_scope was set to a value of 2 which only allows privileged use of ptrace(). I've reset the value to 0 which allows non-privileged use of clang to work when the leak sanitizer is enabled. I've also backed out of the register.cgi workaround of permitting exit code 1 since this is now resolved.