Revert "loader: enable loading libraries from tmpfs"

This reverts commit bb8b22a087db32773f1a9cd3473061f3ad714afc.

http://b/37245203
http://b/37590327
http://b/37589046
Change-Id: I36f45697f7478b830947d641942e453ed0d5466e
(cherry picked from commit 6d59318d78553c32c8f2f43ee48ec3bebace8e86)
(cherry picked from commit 01ea0c0ee3bd690d2acd03327312a1804e70002b)
diff --git a/linker/linker.cpp b/linker/linker.cpp
index afd990a..fc3b348 100644
--- a/linker/linker.cpp
+++ b/linker/linker.cpp
@@ -36,7 +36,6 @@
 #include <string.h>
 #include <sys/mman.h>
 #include <sys/param.h>
-#include <sys/vfs.h>
 #include <unistd.h>
 
 #include <new>
@@ -1191,15 +1190,7 @@
     return false;
   }
 
-  struct statfs fs_stat;
-  if (TEMP_FAILURE_RETRY(fstatfs(task->get_fd(), &fs_stat)) != 0) {
-    DL_ERR("unable to fstatfs file for the library \"%s\": %s", name, strerror(errno));
-    return false;
-  }
-
-  // do not check accessibility using realpath if fd is located on tmpfs
-  // this enables use of memfd_create() for apps
-  if ((fs_stat.f_type != TMPFS_MAGIC) && (!ns->is_accessible(realpath))) {
+  if (!ns->is_accessible(realpath)) {
     // TODO(dimitry): workaround for http://b/26394120 - the grey-list
 
     // TODO(dimitry) before O release: add a namespace attribute to have this enabled
diff --git a/tests/dlext_test.cpp b/tests/dlext_test.cpp
index 35dff2a..a0226a6 100644
--- a/tests/dlext_test.cpp
+++ b/tests/dlext_test.cpp
@@ -24,13 +24,9 @@
 #include <stdio.h>
 #include <string.h>
 #include <unistd.h>
-
 #include <android/dlext.h>
-
-#include <linux/memfd.h>
 #include <sys/mman.h>
 #include <sys/types.h>
-#include <sys/vfs.h>
 #include <sys/wait.h>
 
 #include <pagemap/pagemap.h>
@@ -806,98 +802,6 @@
   dlclose(handle2);
 }
 
-TEST(dlext, dlopen_ext_use_o_tmpfile_fd) {
-  const std::string lib_path = get_testlib_root() + "/libtest_simple.so";
-
-  int tmpfd = TEMP_FAILURE_RETRY(
-        open(get_testlib_root().c_str(), O_TMPFILE | O_CLOEXEC | O_RDWR | O_EXCL));
-
-  // Ignore kernels without O_TMPFILE flag support
-  if (tmpfd == -1 && (errno == EISDIR || errno == EINVAL || errno == EOPNOTSUPP)) {
-    return;
-  }
-
-  ASSERT_TRUE(tmpfd != -1) << strerror(errno);
-
-  android_namespace_t* ns =
-          android_create_namespace("testing-o_tmpfile",
-                                   nullptr,
-                                   get_testlib_root().c_str(),
-                                   ANDROID_NAMESPACE_TYPE_ISOLATED,
-                                   nullptr,
-                                   nullptr);
-
-  ASSERT_DL_NOTNULL(ns);
-
-  ASSERT_TRUE(android_link_namespaces(ns, nullptr, g_core_shared_libs.c_str())) << dlerror();
-
-  std::string content;
-  ASSERT_TRUE(android::base::ReadFileToString(lib_path, &content)) << strerror(errno);
-  ASSERT_TRUE(android::base::WriteStringToFd(content, tmpfd)) << strerror(errno);
-
-  android_dlextinfo extinfo;
-  extinfo.flags = ANDROID_DLEXT_USE_LIBRARY_FD | ANDROID_DLEXT_USE_NAMESPACE;
-  extinfo.library_fd = tmpfd;
-  extinfo.library_namespace = ns;
-
-  void* handle = android_dlopen_ext("foobar", RTLD_NOW, &extinfo);
-
-  ASSERT_DL_NOTNULL(handle);
-
-  uint32_t* taxicab_number = reinterpret_cast<uint32_t*>(dlsym(handle, "dlopen_testlib_taxicab_number"));
-  ASSERT_DL_NOTNULL(taxicab_number);
-  EXPECT_EQ(1729U, *taxicab_number);
-  dlclose(handle);
-}
-
-TEST(dlext, dlopen_ext_use_memfd) {
-  const std::string lib_path = get_testlib_root() + "/libtest_simple.so";
-
-  // create memfd
-  int memfd = syscall(__NR_memfd_create, "foobar", MFD_CLOEXEC);
-  if (memfd == -1 && errno == ENOSYS) {
-    return;
-  }
-
-  ASSERT_TRUE(memfd != -1) << strerror(errno);
-
-  // Check st.f_type is TMPFS_MAGIC for memfd
-  struct statfs st;
-  ASSERT_TRUE(TEMP_FAILURE_RETRY(fstatfs(memfd, &st)) == 0) << strerror(errno);
-  ASSERT_EQ(static_cast<decltype(st.f_type)>(TMPFS_MAGIC), st.f_type);
-
-  android_namespace_t* ns =
-          android_create_namespace("testing-memfd",
-                                   nullptr,
-                                   get_testlib_root().c_str(),
-                                   ANDROID_NAMESPACE_TYPE_ISOLATED,
-                                   nullptr,
-                                   nullptr);
-
-  ASSERT_DL_NOTNULL(ns);
-
-  ASSERT_TRUE(android_link_namespaces(ns, nullptr, g_core_shared_libs.c_str())) << dlerror();
-
-  // read file into memfd backed one.
-  std::string content;
-  ASSERT_TRUE(android::base::ReadFileToString(lib_path, &content)) << strerror(errno);
-  ASSERT_TRUE(android::base::WriteStringToFd(content, memfd)) << strerror(errno);
-
-  android_dlextinfo extinfo;
-  extinfo.flags = ANDROID_DLEXT_USE_LIBRARY_FD | ANDROID_DLEXT_USE_NAMESPACE;
-  extinfo.library_fd = memfd;
-  extinfo.library_namespace = ns;
-
-  void* handle = android_dlopen_ext("foobar", RTLD_NOW, &extinfo);
-
-  ASSERT_DL_NOTNULL(handle);
-
-  uint32_t* taxicab_number = reinterpret_cast<uint32_t*>(dlsym(handle, "dlopen_testlib_taxicab_number"));
-  ASSERT_DL_NOTNULL(taxicab_number);
-  EXPECT_EQ(1729U, *taxicab_number);
-  dlclose(handle);
-}
-
 TEST(dlext, ns_symbol_visibilty_one_namespace) {
   static const char* root_lib = "libnstest_root.so";
   ASSERT_TRUE(android_init_anonymous_namespace(g_core_shared_libs.c_str(), nullptr));