[Spice-devel] [PATCH] Abort if mmap of coroutine stack fails
Marc-André Lureau
mlureau at redhat.com
Fri Sep 13 06:09:49 PDT 2013
ack
----- Original Message -----
> From: "Daniel P. Berrange" <berrange at redhat.com>
>
> If we fail to mmap the stack, abort the processs rather
> than returning an error. This is standard practice in
> glib apps, and the caller was not checking the
> coroutine_init() return code leading to memory corruption.
>
> Signed-off-by: Daniel P. Berrange <berrange at redhat.com>
> ---
> gtk/coroutine_ucontext.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/gtk/coroutine_ucontext.c b/gtk/coroutine_ucontext.c
> index af811a7..79e4afe 100644
> --- a/gtk/coroutine_ucontext.c
> +++ b/gtk/coroutine_ucontext.c
> @@ -20,6 +20,7 @@
>
> #include <config.h>
>
> +#include <glib.h>
> #ifdef HAVE_SYS_TYPES_H
> #include <sys/types.h>
> #endif
> @@ -69,7 +70,8 @@ int coroutine_init(struct coroutine *co)
> MAP_PRIVATE | MAP_ANONYMOUS,
> -1, 0);
> if (co->cc.stack == MAP_FAILED)
> - return -1;
> + g_error("Failed to allocate %u bytes for coroutine stack",
> + (unsigned)co->stack_size);
> co->cc.entry = coroutine_trampoline;
> co->cc.release = _coroutine_release;
> co->exited = 0;
> --
> 1.8.3.1
>
> _______________________________________________
> Spice-devel mailing list
> Spice-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/spice-devel
>
More information about the Spice-devel
mailing list