]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: debug: properly mark the entire libs archive read-only
authorWilly Tarreau <w@1wt.eu>
Thu, 23 Apr 2026 11:52:33 +0000 (13:52 +0200)
committerWilly Tarreau <w@1wt.eu>
Thu, 23 Apr 2026 11:52:33 +0000 (13:52 +0200)
In 3.4-dev7, commit e1738b665d ("MINOR: debug: read all libs in memory
when set-dumpable=libs") reads dependencies into memory to store them as
a tar archive for later debugging. There was an attempt to mark the whole
archive read-only, except that the size passed in argument to mprotect()
is wrong: lib_size is only assigned after the operation and is still zero
at the moment this is done. new_size ought to be used instead.

This needs to be backported wherever the commit above is backported, at
least 3.2.

src/tools.c

index 12481ce1eecf75f1e531e5d9ce44ac56c6908a9d..f5b14d75a485d813a8fc9ba197d5b9ea2518f901 100644 (file)
@@ -6137,7 +6137,7 @@ void collect_libs(void)
                page += pagesize;
                /* copy and make read-only */
                memcpy(page, ctx.storage, ctx.size);
-               mprotect(page, lib_size, PROT_READ);
+               mprotect(page, new_size, PROT_READ);
                vma_set_name(page, new_size, "archive", "boot-libs");
 
                lib_storage = page;