From 6c785d14b92ad5f8198c9d9c77252d468dee071e Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Mon, 1 Jun 2020 02:09:31 +0000 Subject: [PATCH] usr/fileio/fileio: Fix align_alloc() User space code must not use PAGE_SIZE but must use sysconf(_SC_PAGESIZE) instead to obtain the page size. git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@8997 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- usr/fileio/fileio.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/usr/fileio/fileio.c b/usr/fileio/fileio.c index 56962bcd1..a6a0f904d 100644 --- a/usr/fileio/fileio.c +++ b/usr/fileio/fileio.c @@ -28,6 +28,7 @@ #include #include #include +#include #include #include #include @@ -199,8 +200,13 @@ out: static void *align_alloc(size_t size) { + static uint32_t page_size; + + if (page_size == 0) + page_size = sysconf(_SC_PAGESIZE); + TRACE_MEM("Request to alloc %zdKB", size / 1024); - return memalign(PAGE_SIZE, size); + return memalign(page_size, size); } static void sigalrm_handler(int signo)