From c51611c27f766bb4f413485bf8a12bca02e98669 Mon Sep 17 00:00:00 2001 From: Dimitri Staessens Date: Sun, 18 Jan 2026 14:35:50 +0100 Subject: lib: Call mlock() on the shared memory buffers This prevents them from swapping to disk and killing performance. It also enhances security a little bit by reducing the risk of sensitive (even encrypted) data being paged out and captured. Signed-off-by: Dimitri Staessens Signed-off-by: Sander Vrijders --- include/ouroboros/shm_rbuff.h | 2 ++ include/ouroboros/shm_rdrbuff.h | 2 ++ 2 files changed, 4 insertions(+) (limited to 'include') diff --git a/include/ouroboros/shm_rbuff.h b/include/ouroboros/shm_rbuff.h index 423a40a0..a1d2816a 100644 --- a/include/ouroboros/shm_rbuff.h +++ b/include/ouroboros/shm_rbuff.h @@ -52,6 +52,8 @@ uint32_t shm_rbuff_get_acl(struct shm_rbuff * rb); void shm_rbuff_fini(struct shm_rbuff * rb); +int shm_rbuff_mlock(struct shm_rbuff * rb); + int shm_rbuff_write(struct shm_rbuff * rb, size_t idx); diff --git a/include/ouroboros/shm_rdrbuff.h b/include/ouroboros/shm_rdrbuff.h index 4f9a215a..30dc3ff7 100644 --- a/include/ouroboros/shm_rdrbuff.h +++ b/include/ouroboros/shm_rdrbuff.h @@ -42,6 +42,8 @@ void shm_rdrbuff_destroy(struct shm_rdrbuff * rdrb); void shm_rdrbuff_purge(void); +int shm_rdrbuff_mlock(struct shm_rdrbuff * rdrb); + /* Returns block index, a ptr and du_buff. */ ssize_t shm_rdrbuff_alloc(struct shm_rdrbuff * rdrb, size_t count, -- cgit v1.2.3