Blame SOURCES/0001-Abort-if-mmap-of-coroutine-stack-fails.patch

09badb
From 18d452c1b5229198aa04d4a04f7acce9bc662c8f Mon Sep 17 00:00:00 2001
09badb
From: "Daniel P. Berrange" <berrange@redhat.com>
09badb
Date: Fri, 13 Sep 2013 12:05:55 +0100
09badb
Subject: [PATCH] Abort if mmap of coroutine stack fails
09badb
09badb
For
09badb
09badb
  https://bugzilla.redhat.com/show_bug.cgi?id=1007837
09badb
09badb
If we fail to mmap the stack, abort the processs rather
09badb
than returning an error. This is standard practice in
09badb
glib apps, and the caller was not checking the
09badb
coroutine_init() return code leading to memory corruption.
09badb
09badb
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
09badb
(cherry picked from commit b3963416e22382a1fa0ef2d4196f421ef6aee56d)
09badb
---
09badb
 src/coroutine_ucontext.c | 4 +++-
09badb
 1 file changed, 3 insertions(+), 1 deletion(-)
09badb
09badb
diff --git a/src/coroutine_ucontext.c b/src/coroutine_ucontext.c
09badb
index a97e2b1..848016e 100644
09badb
--- a/src/coroutine_ucontext.c
09badb
+++ b/src/coroutine_ucontext.c
09badb
@@ -20,6 +20,7 @@
09badb
 
09badb
 #include <config.h>
09badb
 
09badb
+#include <glib.h>
09badb
 #include <sys/types.h>
09badb
 #include <sys/mman.h>
09badb
 #include <stdio.h>
09badb
@@ -63,7 +64,8 @@ int coroutine_init(struct coroutine *co)
09badb
                         MAP_PRIVATE | MAP_ANONYMOUS,
09badb
                         -1, 0);
09badb
     if (co->cc.stack == MAP_FAILED)
09badb
-        return -1;
09badb
+        g_error("Failed to allocate %u bytes for coroutine stack",
09badb
+                (unsigned)co->stack_size);
09badb
     co->cc.entry = coroutine_trampoline;
09badb
     co->cc.release = _coroutine_release;
09badb
     co->exited = 0;