aports/main/varnish/fix-stack-overflow.patch
2016-03-02 11:22:03 +01:00

45 lines
1.2 KiB
Diff

From bc0b56b8703e7e02af745af28bc6fff48ab806ba Mon Sep 17 00:00:00 2001
From: Natanael Copa <ncopa@alpinelinux.org>
Date: Wed, 2 Mar 2016 10:46:49 +0100
Subject: [PATCH] fix stack overflow in epoll waiter
musl libc has a default thread stack of 80k. avoid overflow the stack by
allocating the epol_event array on heap instead of stack.
---
bin/varnishd/waiter/cache_waiter_epoll.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/bin/varnishd/waiter/cache_waiter_epoll.c b/bin/varnishd/waiter/cache_waiter_epoll.c
index f50ae46..65719e5 100644
--- a/bin/varnishd/waiter/cache_waiter_epoll.c
+++ b/bin/varnishd/waiter/cache_waiter_epoll.c
@@ -71,7 +71,7 @@ struct vwe {
static void *
vwe_thread(void *priv)
{
- struct epoll_event ev[NEEV], *ep;
+ struct epoll_event *ev, *ep;
struct waited *wp;
struct waiter *w;
double now, then;
@@ -83,6 +83,8 @@ vwe_thread(void *priv)
w = vwe->waiter;
CHECK_OBJ_NOTNULL(w, WAITER_MAGIC);
THR_SetName("cache-epoll");
+ ev = malloc(NEEV * sizeof(struct epoll_event));
+ assert(ev != NULL);
now = VTIM_real();
while (1) {
@@ -146,6 +148,7 @@ vwe_thread(void *priv)
AZ(close(vwe->pipe[0]));
AZ(close(vwe->pipe[1]));
AZ(close(vwe->epfd));
+ free(ev);
return (NULL);
}
--
2.7.2