summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicholas Lim <nicknitewolf@lineageos.org>2019-09-24 19:59:46 +0800
committerJulian Veit <claymore1298@gmail.com>2022-03-14 10:53:37 +0100
commitedad497421204a738ab1b7b98c1041baee3275df (patch)
tree6015850c0666304fb165ae303de2cfe6448ba1ec
parentab1f62ad90952006e0a47cabdb3e5a3bcd07124e (diff)
art: Conditionally remove version check for memfd_create()
* This check is redundant as devices that lack the memfd_create syscall will fail to boot regardless of the check. This conditionally reverts commit 51f89d9. Change-Id: Ife2cebde713e14bd787f48628092650866e2ac09 (cherry picked from commit dd1d9ba1851d96a8d4f55cd8e983fcee1519d953)
-rw-r--r--libartbase/Android.bp5
-rw-r--r--libartbase/base/memfd.cc6
-rw-r--r--libartbase/base/memfd.h3
3 files changed, 11 insertions, 3 deletions
diff --git a/libartbase/Android.bp b/libartbase/Android.bp
index 8bd3bd12aa..fc53aaa28a 100644
--- a/libartbase/Android.bp
+++ b/libartbase/Android.bp
@@ -25,7 +25,10 @@ package {
cc_defaults {
name: "libartbase_defaults",
- defaults: ["art_defaults"],
+ defaults: [
+ "art_defaults",
+ "has_memfd_backport_defaults",
+ ],
host_supported: true,
srcs: [
"arch/instruction_set.cc",
diff --git a/libartbase/base/memfd.cc b/libartbase/base/memfd.cc
index 8512a3ae13..84cc66d5f2 100644
--- a/libartbase/base/memfd.cc
+++ b/libartbase/base/memfd.cc
@@ -17,11 +17,15 @@
#include "memfd.h"
#include <errno.h>
+#if !defined(HAS_MEMFD_BACKPORT)
#include <stdio.h>
+#endif
#if !defined(_WIN32)
#include <fcntl.h>
#include <sys/syscall.h>
+#if !defined(HAS_MEMFD_BACKPORT)
#include <sys/utsname.h>
+#endif
#include <unistd.h>
#endif
#if defined(__BIONIC__)
@@ -49,6 +53,7 @@ namespace art {
#if defined(__NR_memfd_create)
int memfd_create(const char* name, unsigned int flags) {
+#if !defined(HAS_MEMFD_BACKPORT)
// Check kernel version supports memfd_create(). Some older kernels segfault executing
// memfd_create() rather than returning ENOSYS (b/116769556).
static constexpr int kRequiredMajor = 3;
@@ -62,6 +67,7 @@ int memfd_create(const char* name, unsigned int flags) {
errno = ENOSYS;
return -1;
}
+#endif
return syscall(__NR_memfd_create, name, flags);
}
diff --git a/libartbase/base/memfd.h b/libartbase/base/memfd.h
index 3c27dcb9e3..d26101824b 100644
--- a/libartbase/base/memfd.h
+++ b/libartbase/base/memfd.h
@@ -65,8 +65,7 @@
namespace art {
-// Call memfd(2) if available on platform and return result. This call also makes a kernel version
-// check for safety on older kernels (b/116769556)..
+ // Call memfd(2) if available on platform and return result.
int memfd_create(const char* name, unsigned int flags);
// Call memfd(2) if available on platform and return result. Try to give us an unlinked FD in some