Zero-initialize user_desc for __set_thread_area.
The kernel does seem to read some of the "unused" fields if only to do
basic validity checks.
valgrind complained about this, and I'm not convinced it's spurious.
Bug: http://b/38034461
Test: ran tests
Change-Id: I077fcc75bf0738491242166fc4576a9693ce18a5
diff --git a/libc/arch-x86/bionic/__set_tls.cpp b/libc/arch-x86/bionic/__set_tls.cpp
index b26fd56..241d94a 100644
--- a/libc/arch-x86/bionic/__set_tls.cpp
+++ b/libc/arch-x86/bionic/__set_tls.cpp
@@ -32,9 +32,9 @@
#include <asm/ldt.h>
-extern "C" int __set_thread_area(struct user_desc*);
+extern "C" int __set_thread_area(user_desc*);
-__LIBC_HIDDEN__ void __init_user_desc(struct user_desc* result, bool allocate, void* base_addr) {
+__LIBC_HIDDEN__ void __init_user_desc(user_desc* result, bool allocate, void* base_addr) {
if (allocate) {
// Let the kernel choose.
result->entry_number = -1;
@@ -58,7 +58,7 @@
}
extern "C" __LIBC_HIDDEN__ int __set_tls(void* ptr) {
- struct user_desc tls_descriptor;
+ user_desc tls_descriptor = {};
__init_user_desc(&tls_descriptor, true, ptr);
int rc = __set_thread_area(&tls_descriptor);