From 6f3ed703635c4ab62ed16917e91e8d723e77cc51 Mon Sep 17 00:00:00 2001 From: apio Date: Sun, 27 Aug 2023 20:48:33 +0200 Subject: [PATCH] kernel+libluna: Avoid scrubbing when the memory is going to be overwritten anyway This is the case for objects with constructors and temporary memory which is filled afterwards. --- kernel/src/sys/poll.cpp | 2 +- libluna/include/luna/Alloc.h | 2 +- libluna/src/Heap.cpp | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/kernel/src/sys/poll.cpp b/kernel/src/sys/poll.cpp index cfdc4247..f268060b 100644 --- a/kernel/src/sys/poll.cpp +++ b/kernel/src/sys/poll.cpp @@ -12,7 +12,7 @@ Result sys_poll(Registers*, SyscallArgs args) nfds_t nfds = (nfds_t)args[1]; int timeout = (int)args[2]; - struct pollfd* kfds = (struct pollfd*)TRY(malloc_impl(nfds * sizeof(pollfd))); + struct pollfd* kfds = (struct pollfd*)TRY(malloc_impl(nfds * sizeof(pollfd), false, false)); auto guard = make_scope_guard([kfds] { free_impl(kfds); }); if (!MemoryManager::copy_from_user(fds, kfds, nfds * sizeof(pollfd))) return err(EFAULT); diff --git a/libluna/include/luna/Alloc.h b/libluna/include/luna/Alloc.h index 0e28a901..d8fa6e11 100644 --- a/libluna/include/luna/Alloc.h +++ b/libluna/include/luna/Alloc.h @@ -24,7 +24,7 @@ */ template [[nodiscard]] Result make(Args... args) { - T* const result = (T*)TRY(malloc_impl(sizeof(T))); + T* const result = (T*)TRY(malloc_impl(sizeof(T), false, false)); new (result) T(args...); return result; } diff --git a/libluna/src/Heap.cpp b/libluna/src/Heap.cpp index bc186ee3..f038a701 100644 --- a/libluna/src/Heap.cpp +++ b/libluna/src/Heap.cpp @@ -425,12 +425,12 @@ void dump_heap_usage() #ifdef USE_FREESTANDING void* operator new(usize size, const std::nothrow_t&) noexcept { - return malloc_impl(size).value_or(nullptr); + return malloc_impl(size, false, false).value_or(nullptr); } void* operator new[](usize size, const std::nothrow_t&) noexcept { - return malloc_impl(size).value_or(nullptr); + return malloc_impl(size, false, false).value_or(nullptr); } void operator delete(void* p) noexcept