-
Notifications
You must be signed in to change notification settings - Fork 69
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2114 from AntelopeIO/memfd_cleanups
minor cleanups to `memfd_create()`
- Loading branch information
Showing
3 changed files
with
25 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
libraries/chain/include/eosio/chain/webassembly/eos-vm-oc/memfd_helpers.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#pragma once | ||
|
||
#include <linux/memfd.h> | ||
#include <sys/mman.h> | ||
|
||
namespace eosio::chain::eosvmoc { | ||
|
||
// added in glibc 2.38 | ||
#ifndef MFD_NOEXEC_SEAL | ||
#define MFD_NOEXEC_SEAL 8U | ||
#endif | ||
|
||
inline int exec_sealed_memfd_create(const char* name) { | ||
//kernels 6.3 through 6.6 by default warn when neither MFD_NOEXEC_SEAL nor MFD_EXEC are passed; optionally 6.3+ | ||
// may enforce MFD_NOEXEC_SEAL. Prior to 6.3 these flags will EINVAL. | ||
if(int ret = memfd_create(name, MFD_CLOEXEC | MFD_NOEXEC_SEAL); ret >= 0 || errno != EINVAL) | ||
return ret; | ||
return memfd_create(name, MFD_CLOEXEC); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters