Skip to content

Commit

Permalink
wasm memzero
Browse files Browse the repository at this point in the history
Signed-off-by: turuslan <[email protected]>
  • Loading branch information
turuslan committed Jul 17, 2024
1 parent 2d8d4d8 commit 4cd26aa
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
5 changes: 5 additions & 0 deletions core/runtime/common/module_instance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

#include "runtime/module_instance.hpp"

#include <openssl/mem.h>

#include "common/int_serialization.hpp"
#include "runtime/memory_provider.hpp"
#include "runtime/trie_storage_provider.hpp"
Expand Down Expand Up @@ -59,6 +61,9 @@ namespace kagome::runtime {
"__heap_base too low, allocations will overwrite wasm data segments");
}

auto memory_size = memory.memory()->size();
OPENSSL_cleanse(memory.view(0, memory_size).value().data(), memory_size);

forDataSegment([&](auto offset, auto segment) {
memory.storeBuffer(offset, segment);
});
Expand Down
4 changes: 4 additions & 0 deletions core/runtime/memory.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,10 @@ namespace kagome::runtime {
return PtrSize{ptr, static_cast<WasmSize>(v.size())}.combine();
}

auto &memory() const {
return handle_;
}

private:
std::shared_ptr<MemoryHandle> handle_;
std::unique_ptr<MemoryAllocator> allocator_;
Expand Down

0 comments on commit 4cd26aa

Please sign in to comment.