From: Julio Pintos Date: Fri, 14 Mar 2014 19:47:30 +0000 (-0300) Subject: Fix #66908: php-fpm reload leaks epoll_create() file descriptor X-Git-Tag: php-5.4.29RC1~33 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=49341e992ad7f8eb7f94d4c946fb74f8e33e7e75;p=php Fix #66908: php-fpm reload leaks epoll_create() file descriptor This patch fixes descriptor leak which could lead to DoS once Max open files is reached --- diff --git a/NEWS b/NEWS index d9f0f8a353..7b2b404804 100644 --- a/NEWS +++ b/NEWS @@ -11,6 +11,10 @@ PHP NEWS . Fixed bug #67081 (DOMDocumentType->internalSubset returns entire DOCTYPE tag, not only the subset). (Anatol) +- FPM: + . Fixed bug #66908 (php-fpm reload leaks epoll_create() file descriptor). + (Julio Pintos) + ?? ??? 2014, PHP 5.4.28 - Core: diff --git a/sapi/fpm/fpm/events/epoll.c b/sapi/fpm/fpm/events/epoll.c index 2857ea2a09..b55cb44b15 100644 --- a/sapi/fpm/fpm/events/epoll.c +++ b/sapi/fpm/fpm/events/epoll.c @@ -46,7 +46,7 @@ static struct fpm_event_module_s epoll_module = { static struct epoll_event *epollfds = NULL; static int nepollfds = 0; -static int epollfd = 0; +static int epollfd = -1; #endif /* HAVE_EPOLL */ @@ -103,6 +103,10 @@ static int fpm_event_epoll_clean() /* {{{ */ free(epollfds); epollfds = NULL; } + if (epollfd != -1) { + close(epollfd); + epollfd = -1; + } nepollfds = 0;