summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHu Wang <hu.wang@mediatek.com>2021-08-23 17:41:57 +0800
committerNicolas Geoffray <ngeoffray@google.com>2021-09-03 12:48:09 +0000
commitfe2bf982759e4cffbfb527f54319e281ce6cfd77 (patch)
treeda4d1e3c8e4d67300b99a29dd5ac3b2decc59fb9
parent8bc28c2d007a9066fae2ba6cf970df8ce2a342e8 (diff)
Fix android.security.cts.FileDescriptorTest#testCLOEXEC
When ART is mainline, it will create memFd boot-image-methods.art without MFD_CLOEXEC. Add MFD_CLOEXEC flag when create boot-image-methods.art memFd. Bug: 197498527 Test: run cts CtsSecurityTestCases pass Merged-In: If941c036f7adb598d67ec2b2c5bc4cb24994e3a1 (cherry picked from commit 3326fcea1ead5d5d360a053704faad27b6dd8c40) Change-Id: Icfc2420e8e9d3f61f5e3f2eb5bfc53108c2c251b (cherry picked from commit 0857789b5b09bccc977f712a071c7b68bfccae05)
-rw-r--r--libartbase/base/memfd.h4
-rw-r--r--runtime/jit/jit.cc3
2 files changed, 6 insertions, 1 deletions
diff --git a/libartbase/base/memfd.h b/libartbase/base/memfd.h
index 0bb336d45a..3c27dcb9e3 100644
--- a/libartbase/base/memfd.h
+++ b/libartbase/base/memfd.h
@@ -53,6 +53,10 @@
# define F_SEAL_FUTURE_WRITE 0x0010
#endif
+#ifndef MFD_CLOEXEC
+# define MFD_CLOEXEC 0x0001U
+#endif
+
#ifndef MFD_ALLOW_SEALING
# define MFD_ALLOW_SEALING 0x0002U
#endif
diff --git a/runtime/jit/jit.cc b/runtime/jit/jit.cc
index 5ee88718dc..876e12091c 100644
--- a/runtime/jit/jit.cc
+++ b/runtime/jit/jit.cc
@@ -1238,7 +1238,8 @@ void Jit::CreateThreadPool() {
// Start with '/boot' and end with '.art' to match the pattern recognized
// by android_os_Debug.cpp for boot images.
const char* name = "/boot-image-methods.art";
- unique_fd mem_fd = unique_fd(art::memfd_create(name, /* flags= */ MFD_ALLOW_SEALING));
+ unique_fd mem_fd =
+ unique_fd(art::memfd_create(name, /* flags= */ MFD_ALLOW_SEALING | MFD_CLOEXEC));
if (mem_fd.get() == -1) {
PLOG(WARNING) << "Could not create boot image methods file descriptor";
return;