summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicholas Lim <nicknitewolf@lineageos.org>2019-09-24 19:59:46 +0800
committerMichael Bestas <mkbestas@lineageos.org>2020-12-12 05:43:19 +0200
commitdd1d9ba1851d96a8d4f55cd8e983fcee1519d953 (patch)
treea12da606912683c753b4a0ff73b9d1bec29b3505
parentb7102e846bed5c1ed470a43f3ba7424afff126f9 (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
-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 a9d5db27d5..cb2ff6af0e 100644
--- a/libartbase/Android.bp
+++ b/libartbase/Android.bp
@@ -16,7 +16,10 @@
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 0bb336d45a..17019ba264 100644
--- a/libartbase/base/memfd.h
+++ b/libartbase/base/memfd.h
@@ -61,8 +61,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