Merge "Don't let missing Treble property context files affect errno." into oc-dev
diff --git a/libc/Android.bp b/libc/Android.bp
index 7fc4682..cde2391 100644
--- a/libc/Android.bp
+++ b/libc/Android.bp
@@ -1817,6 +1817,7 @@
 cc_defaults {
     name: "crt_defaults",
     defaults: ["linux_bionic_supported"],
+    vendor_available: true,
 
     no_default_compiler_flags: true,
 
@@ -1846,6 +1847,7 @@
 cc_defaults {
     name: "crt_so_defaults",
 
+    vendor_available: true,
     arch: {
         mips: {
             cflags: ["-fPIC"],
diff --git a/linker/linker_globals.h b/linker/linker_globals.h
index e4e3d97..1ed479c 100644
--- a/linker/linker_globals.h
+++ b/linker/linker_globals.h
@@ -34,6 +34,8 @@
 
 #include <unordered_map>
 
+#include "private/libc_logging.h"
+
 #define DL_ERR(fmt, x...) \
     do { \
       __libc_format_buffer(linker_get_error_buffer(), linker_get_error_buffer_size(), fmt, ##x); \
diff --git a/linker/linker_namespaces.cpp b/linker/linker_namespaces.cpp
index 273ff9b..3c86f99 100644
--- a/linker/linker_namespaces.cpp
+++ b/linker/linker_namespaces.cpp
@@ -27,6 +27,7 @@
  */
 
 #include "linker_namespaces.h"
+#include "linker_globals.h"
 #include "linker_soinfo.h"
 #include "linker_utils.h"
 
@@ -58,6 +59,13 @@
 
 bool android_namespace_t::is_accessible(soinfo* s) {
   auto is_accessible_ftor = [this] (soinfo* si) {
+    // This is workaround for apps hacking into soinfo list.
+    // and inserting their own entries into it. (http://b/37191433)
+    if (!si->has_min_version(3)) {
+      DL_WARN("invalid soinfo version for \"%s\"", si->get_soname());
+      return false;
+    }
+
     if (si->get_primary_namespace() == this) {
       return true;
     }