Snap for 12748980 from 8a0176cf648227b1cda6e1cd32d99d418c4f534a to 25Q1-release
Change-Id: Iadf359924d77ae90c8b8e048d5501eeb898c158d
diff --git a/libc/Android.bp b/libc/Android.bp
index 3c5c9f1..c34023c 100644
--- a/libc/Android.bp
+++ b/libc/Android.bp
@@ -1659,8 +1659,14 @@
},
native_bridge_supported: false,
// It is never correct to depend on this directly. This is only
- // needed for the runtime apex, and in base_system.mk.
- visibility: ["//bionic/apex"],
+ // needed for the runtime apex, and in base_system.mk, and system_image_defaults
+ // which is default module for soong-defined system image.
+ visibility: [
+ "//bionic/apex",
+ "//build/make/target/product/generic",
+ //TODO(b/381985636) : Remove visibility to Soong-defined GSI once resolved
+ "//build/make/target/product/gsi",
+ ],
}
genrule {
diff --git a/libc/bionic/elf_note.cpp b/libc/bionic/elf_note.cpp
index d5cd5de..9cc6b21 100644
--- a/libc/bionic/elf_note.cpp
+++ b/libc/bionic/elf_note.cpp
@@ -38,31 +38,34 @@
return false;
}
+ size_t note_name_len = strlen(note_name) + 1;
+
ElfW(Addr) p = note_addr;
ElfW(Addr) note_end = p + phdr_note->p_memsz;
-
while (p + sizeof(ElfW(Nhdr)) <= note_end) {
+ // Parse the note and check it's structurally valid.
const ElfW(Nhdr)* note = reinterpret_cast<const ElfW(Nhdr)*>(p);
p += sizeof(ElfW(Nhdr));
const char* name = reinterpret_cast<const char*>(p);
- p += align_up(note->n_namesz, 4);
+ if (__builtin_add_overflow(p, align_up(note->n_namesz, 4), &p)) {
+ return false;
+ }
const char* desc = reinterpret_cast<const char*>(p);
- p += align_up(note->n_descsz, 4);
+ if (__builtin_add_overflow(p, align_up(note->n_descsz, 4), &p)) {
+ return false;
+ }
if (p > note_end) {
- break;
- }
- if (note->n_type != note_type) {
- continue;
- }
- size_t note_name_len = strlen(note_name) + 1;
- if (note->n_namesz != note_name_len || strncmp(note_name, name, note_name_len) != 0) {
- break;
+ return false;
}
- *note_hdr = note;
- *note_desc = desc;
-
- return true;
+ // Is this the note we're looking for?
+ if (note->n_type == note_type &&
+ note->n_namesz == note_name_len &&
+ strncmp(note_name, name, note_name_len) == 0) {
+ *note_hdr = note;
+ *note_desc = desc;
+ return true;
+ }
}
return false;
}
diff --git a/linker/linker_phdr.cpp b/linker/linker_phdr.cpp
index 14bf208..e5369ac 100644
--- a/linker/linker_phdr.cpp
+++ b/linker/linker_phdr.cpp
@@ -752,9 +752,10 @@
}
/*
- * Returns true if the kernel supports page size migration, else false.
+ * Returns true if the kernel supports page size migration for this process.
*/
bool page_size_migration_supported() {
+#if defined(__LP64__)
static bool pgsize_migration_enabled = []() {
std::string enabled;
if (!android::base::ReadFileToString("/sys/kernel/mm/pgsize_migration/enabled", &enabled)) {
@@ -763,6 +764,9 @@
return enabled.find("1") != std::string::npos;
}();
return pgsize_migration_enabled;
+#else
+ return false;
+#endif
}
// Find the ELF note of type NT_ANDROID_TYPE_PAD_SEGMENT and check that the desc value is 1.
diff --git a/tests/Android.bp b/tests/Android.bp
index 22fa542..a97f5a8 100644
--- a/tests/Android.bp
+++ b/tests/Android.bp
@@ -389,7 +389,9 @@
"bug_26110743_test.cpp",
"byteswap_test.cpp",
"complex_test.cpp",
- "cpu_target_features_test.cpp",
+ // Disabled while investigating
+ // b/378304366, b/375525252
+ // "cpu_target_features_test.cpp",
"ctype_test.cpp",
"dirent_test.cpp",
"elf_test.cpp",