[VM runtime] Do not leak file descriptors of dual mappings to child processes.
This applies to linux only and is a suggested precaution. Change-Id: I81cc345eb2c316530de1fd779cdf392804a68490 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/96982 Reviewed-by: Ryan Macnak <rmacnak@google.com> Commit-Queue: Régis Crelier <regis@google.com>
This commit is contained in:
committed by
commit-bot@chromium.org
parent
5fdb3c5057
commit
00a478ca80
@@ -83,6 +83,11 @@ static void unmap(uword start, uword end) {
|
||||
}
|
||||
|
||||
#if defined(DUAL_MAPPING_SUPPORTED)
|
||||
// Do not leak file descriptors to child processes.
|
||||
#if !defined(MFD_CLOEXEC)
|
||||
#define MFD_CLOEXEC 0x0001U
|
||||
#endif
|
||||
|
||||
// Wrapper to call memfd_create syscall.
|
||||
static inline int memfd_create(const char* name, unsigned int flags) {
|
||||
#if !defined(__NR_memfd_create)
|
||||
@@ -143,7 +148,7 @@ VirtualMemory* VirtualMemory::AllocateAligned(intptr_t size,
|
||||
const bool dual_mapping =
|
||||
is_executable && FLAG_write_protect_code && FLAG_dual_map_code;
|
||||
if (dual_mapping) {
|
||||
fd = memfd_create("dart_vm", 0);
|
||||
fd = memfd_create("dart_vm", MFD_CLOEXEC);
|
||||
if (fd == -1) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user