summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHu Wang <hu.wang@mediatek.com>2021-08-23 17:41:57 +0800
committerMurtuza Raja <mraja@codeaurora.org>2021-09-28 22:11:09 +0530
commited03aff4fc6a6b7253942b0e45dcb8b7883270d4 (patch)
tree88a8d02ef488b6a17e3455da21a278cee01e9270
parent4d043fdef993d740004bec1145138bfce87dab5f (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 CRs-Fixed: 3034193 Change-Id: If941c036f7adb598d67ec2b2c5bc4cb24994e3a1 (cherry picked from commit 3326fcea1ead5d5d360a053704faad27b6dd8c40)
-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;