packages/net/haproxy/patches/0030-BUG-MEDIUM-pools-Fix-the-usage-of-mmap-with-DEBUG_UAF.patch
Christian Lachner ca39a1b787 haproxy: Update all patches for HAProxy v1.8.14
- Add new patches (see https://www.haproxy.org/bugs/bugs-1.8.14.html)
- Raise PKG_RELEASE to 4

Signed-off-by: Christian Lachner <gladiac@gmail.com>
2018-11-02 10:35:38 +01:00

33 lines
1.3 KiB
Diff

commit 7e751a3c24a7021075fb298025c4a1ce98a5b049
Author: Olivier Houchard <cognet@ci0.org>
Date: Sun Oct 21 01:33:11 2018 +0200
BUG/MEDIUM: pools: Fix the usage of mmap()) with DEBUG_UAF.
When mapping memory with mmap(), we should use a fd of -1, not 0. 0 may
work on linux, but it doesn't work on FreeBSD, and probably other OSes.
It would be nice to backport this to 1.8 to help debugging there.
(cherry picked from commit 62975a7740cba4bdaf1c096dd246feba854d2410)
Signed-off-by: Willy Tarreau <w@1wt.eu>
diff --git a/include/common/memory.h b/include/common/memory.h
index a2237da5..da0641de 100644
--- a/include/common/memory.h
+++ b/include/common/memory.h
@@ -186,12 +186,13 @@ static inline void pool_free_area(void *area, size_t __maybe_unused size)
* some padding is added, the area's start address is copied at the end of the
* padding to help detect underflows.
*/
+#include <errno.h>
static inline void *pool_alloc_area(size_t size)
{
size_t pad = (4096 - size) & 0xFF0;
void *ret;
- ret = mmap(NULL, (size + 4095) & -4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, 0, 0);
+ ret = mmap(NULL, (size + 4095) & -4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0);
if (ret == MAP_FAILED)
return NULL;
if (pad >= sizeof(void *))