]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
DEBUG: add a tainted flag when ha_panic() is called
authorWilly Tarreau <w@1wt.eu>
Wed, 25 Oct 2023 12:34:08 +0000 (14:34 +0200)
committerWilly Tarreau <w@1wt.eu>
Wed, 25 Oct 2023 13:48:02 +0000 (15:48 +0200)
This will make it easier to know that the panic function was called,
for the occasional case where the dump crashes and/or the stack is
corrupted and not much exploitable. Now at least it will be sufficient
to check the tainted value to know that someone called ha_panic(), and
it will also be usable to condition extra analysis.

include/haproxy/bug.h
src/debug.c

index d34744869139a32ed9c0e86eb06606b22a0ce172..a716568f90219effa6bdbf734e6f2aa6483420bd 100644 (file)
@@ -248,6 +248,7 @@ enum tainted_flags {
        TAINTED_SHARED_LIBS            = 0x00000040, /* a shared library was loaded */
        TAINTED_REDEFINITION           = 0x00000080, /* symbol redefinition detected */
        TAINTED_REPLACED_MEM_ALLOCATOR = 0x00000100, /* memory allocator was replaced using LD_PRELOAD */
+       TAINTED_PANIC                  = 0x00000200, /* a panic dump has started */
 };
 
 /* this is a bit field made of TAINTED_*, and is declared in haproxy.c */
index a7e3dfd1013a182161dff6e48cac419b692f59d4..5598d212d2160e65bf6f363c977ef93aba7222b6 100644 (file)
@@ -415,6 +415,8 @@ void ha_panic()
        struct buffer *old;
        unsigned int thr;
 
+       mark_tainted(TAINTED_PANIC);
+
        old = NULL;
        if (!HA_ATOMIC_CAS(&thread_dump_buffer, &old, get_trash_chunk())) {
                /* a panic dump is already in progress, let's not disturb it,