From 1e998a434909b6ad5506c4b0084b7ad1ef3da2b1 Mon Sep 17 00:00:00 2001 From: Maria Matejka Date: Wed, 3 May 2023 18:59:52 +0200 Subject: [PATCH] Fixed cold page cache leak The empty_pages pointer wasn't being propagated into the ->next pointer when more empty_pages were to be stored --- sysdep/unix/alloc.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/sysdep/unix/alloc.c b/sysdep/unix/alloc.c index 2205f152..891a0e69 100644 --- a/sysdep/unix/alloc.c +++ b/sysdep/unix/alloc.c @@ -282,10 +282,13 @@ page_cleanup(void *_ UNUSED) if (!empty_pages || (empty_pages->pos == EP_POS_MAX)) { /* There is either no pointer block or the last block is full. We use this block as a pointer block. */ - empty_pages = (struct empty_pages *) fp; - UNPROTECT_PAGE(empty_pages); - *empty_pages = (struct empty_pages) {}; - PROTECT_PAGE(empty_pages); + struct empty_pages *ep = (struct empty_pages *) fp; + UNPROTECT_PAGE(ep); + *ep = (struct empty_pages) { + .next = empty_pages, + }; + PROTECT_PAGE(ep); + empty_pages = ep; } else {