Commit graph

6821 commits

Author SHA1 Message Date
Elliott Hughes
e9daecf74b Merge "Stop defining HAVE_PTHREAD_COND_TIMEDWAIT_RELATIVE." 2016-04-01 16:43:42 +00:00
Elliott Hughes
5dd13d09c1 Differentiate the MNTTYPE_* and MNTOPT_* constants.
Bug: http://b/27952303
Change-Id: I926593c16143f76b21a65af7f6e1979d0fb44cac
2016-03-31 18:20:01 -07:00
Elliott Hughes
1f1a51aecd Add a few missing types and constants to headers.
This (and other stuff still to come) prevented xfstests from building out
of the box.

Bug: http://b/27952303
Change-Id: Id38fd37386d43fc351c56dca18785a465e3e6145
2016-03-31 17:05:30 -07:00
Elliott Hughes
96583dcf95 Stop defining HAVE_PTHREAD_COND_TIMEDWAIT_RELATIVE.
Bug: http://b/27918161
Change-Id: I21d4dfa4636aa06a93b3c8a215113f66f37f0bc7
2016-03-30 10:33:54 -07:00
Josh Gao
eaf50be332 Merge "Add a checksum to jmp_buf on mips and mips64." 2016-03-30 02:27:00 +00:00
Josh Gao
a42789f9d2 Merge changes from topic 'setjmp_checksum_x86'
* changes:
  Add a checksum to jmp_buf on x86_64.
  Delete lies from x86_64 setjmp implementation.
  Add a checksum to jmp_buf on x86.
2016-03-30 00:58:30 +00:00
Josh Gao
686e5f6f69 Add a checksum to jmp_buf on x86_64.
Bug: http://b/27856501
Bug: http://b/27417786
Change-Id: I541f5a7ce4972ef56b3f69e73927ca7df362609a
2016-03-29 17:28:32 -07:00
Josh Gao
c244fcb8a3 Delete lies from x86_64 setjmp implementation.
Previously, the implementation of setjmp on x86_64 claimed that
sigprocmask would write to two longs' worth of bytes.

Bug: http://b/27856501
Change-Id: I9f32b40ac773a0cd91a976aace5bfba6e67fb0f8
2016-03-29 17:28:32 -07:00
Josh Gao
9260785393 Add a checksum to jmp_buf on x86.
Bug: http://b/27856501
Bug: http://b/27417786
Change-Id: Id5a0a81fc38e311bff678cbc7dc2219bc0074503
2016-03-29 17:28:32 -07:00
Dan Willemsen
23aae1ce30 Update Android.bp with getdomainname
Change-Id: I32383162acd16430089708fdce8927be43d1bc5a
2016-03-29 15:21:38 -07:00
Greg Hackmann
d15dfb2ff5 clock_nanosleep: add CLOCK_THREAD_CPUTIME_ID special case
POSIX makes "the CPU-time clock of the calling thread" (i.e.,
CLOCK_THREAD_CPUTIME_ID) a special case which returns EINVAL instead of
ENOTSUP.

However, the clock_nanosleep syscall treats this clock just like any
other, and returns -EOPNOTSUPP to indicate an unimplemented nanosleep
handler.  So we need to handle this ourselves in userspace.

This change fixes the LTP clock_nanosleep01 testcase.

Change-Id: If3bed940d276834bcd114d8c17f96197e9384711
Signed-off-by: Greg Hackmann <ghackmann@google.com>
2016-03-28 10:29:16 -07:00
Predrag Blagojevic
3299590dfe Add a checksum to jmp_buf on mips and mips64.
Make it easier to diagnose applications mucking with the contents of
jmp_buf by checksumming its contents.

Bug: http://b/27417786
Change-Id: I473bc2871dece23a9b9d02481945246160d671c6
2016-03-28 14:54:49 +00:00
Nick Kralevich
dbf2e19281 fixup x86 setdomainname.S
Both be91052932 and
e2faf07d65 were submitted about
two days ago. The former changed how the syscalls stubs were
generated, but the latter was submitted using the old stub
format.

Use the new stub format for setdomainname.S

Change-Id: I578acd7053f57a275f6831dd2404ef04826c578e
2016-03-27 14:52:58 -07:00
Greg Hackmann
d132099e05 Merge "Add hasmntopt(3)" 2016-03-25 22:43:01 +00:00
Elliott Hughes
d81143df71 Merge "libc: implement kernel vdso syscalls for i386" 2016-03-25 22:20:42 +00:00
Greg Hackmann
76640d5555 Merge "Add {get,set}domainname(2)" 2016-03-25 22:02:07 +00:00
Greg Hackmann
3679ade533 Add hasmntopt(3)
bionic has the Linux-specific mntent.h but is missing hasmntopt().

Change-Id: I0ab7b83626c969704add4e64b37a6fc715d4a723
Signed-off-by: Greg Hackmann <ghackmann@google.com>
2016-03-25 14:16:58 -07:00
Greg Hackmann
e2faf07d65 Add {get,set}domainname(2)
{get,set}domainname aren't in POSIX but are widely-implemented
extensions.

The Linux kernel provides a setdomainname syscall but not a symmetric
getdomainname syscall, since it expects userspace to get the domain name
from uname(2).

Change-Id: I96726c242f4bb646c130b361688328b0b97269a0
Signed-off-by: Greg Hackmann <ghackmann@google.com>
2016-03-25 14:16:58 -07:00
Mingwei Shi
be91052932 libc: implement kernel vdso syscalls for i386
This patch uses __kernel_vsyscall instead of "int 0x80"
as the syscall entry point. AT_SYSINFO points to
an adapter to mask the arch specific difference and gives a
performance boost on i386 architecture.

Change-ID: Ib340c604d02c6c25714a95793737e3cfdc3fc5d7
Signed-off-by: Mingwei Shi <mingwei.shi@intel.com>
2016-03-25 14:10:05 -07:00
Greg Hackmann
2846ae70fb Merge "epoll_create: reject size <= 0" 2016-03-25 19:35:01 +00:00
Greg Hackmann
61cb584f9f Merge "clone: check for NULL child stack" 2016-03-25 19:34:44 +00:00
Elliott Hughes
204990cc83 Fix x86 __memset_chk.
The stack offsets assumed we'd pushed %ebx. Unlike x86-64 we can't fall
through, but we can avoid repeating work we've already done.

Change-Id: I7e5f9be50983ed6178dd0c0534042da7ea30ad0c
2016-03-24 22:34:47 -07:00
Greg Hackmann
a03c62b469 epoll_create: reject size <= 0
Even though the size parameter to epoll_create(2) is (otherwise) unused,
passing in size <= 0 is explicitly documented as an error.

This change fixes the LTP epoll01 testcase.

Change-Id: I044a38be823c2fa956b57e77cc66571dfae8a4bb
Signed-off-by: Greg Hackmann <ghackmann@google.com>
2016-03-24 16:37:20 -07:00
Greg Hackmann
fb23fa3046 clone: check for NULL child stack
The clone syscall accepts NULL child stacks, interpreting this to mean
the child gets a copy of the parent's stack with copy-on-write
semantics.  However clone(2) is explicitly documented to treat this an
an error.

"Fortunately" every architecture's __bionic_clone implementation pushes
something onto the child stack before making the clone syscall.  So we
know fixing this won't break legacy apps, because any app that tried
using a NULL child stack would have died with SIGSEGV.

This change fixes the LTP clone04 testcase.

Change-Id: I663b34f34bc8dad2aa405c46e4eed4418cccca0d
Signed-off-by: Greg Hackmann <ghackmann@google.com>
2016-03-24 16:37:20 -07:00
Elliott Hughes
cc78b252d1 Remove the __USE_GNU guard from pthread_setname_np again.
Caused build breakage, but not spotted by TreeHugger:

  external/libnfc-nxp/Linux_x86/phDal4Nfc.c:737:5: error: implicit declaration of function 'pthread_setname_np' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
    pthread_setname_np(pthread_self(), "reader");
    ^

Nice file name.

Change-Id: I102e55718babf4e4f2f2c64066c6a83ed3ac86d3
2016-03-23 20:26:35 -07:00
Elliott Hughes
63322aa555 Merge "Add pthread_getname_np." 2016-03-24 02:47:10 +00:00
Elliott Hughes
725b2a96a7 Add pthread_getname_np.
Also guard both these GNU extensions with _GNU_SOURCE.

Also improve the tests to test each case on both the current thread and
another thread, since the code paths are totally different.

Bug: http://b/27810459
Change-Id: I72b05bca5c5b6ca8ba4585b8edfb716a1c252f92
2016-03-23 17:40:25 -07:00
Greg Hackmann
e5c872ffb7 genversion-scripts: fix script name in autogenerated comment
Change-Id: I2a304818cfc54d08a08d2e621e4cf74e7ce465dd
Signed-off-by: Greg Hackmann <ghackmann@google.com>
2016-03-23 16:25:42 -07:00
Christopher Ferris
5f1de52eca Merge "Fix race in malloc debug option free_track." 2016-03-17 17:52:55 +00:00
Christopher Ferris
d0919623a2 Fix race in malloc debug option free_track.
The free track mechanism could fail if, at the same time a free occurs,
another thread is trying to free and verify the same allocation. This
doesn't work if the freed allocation is added to the list and we still
do work on it. The fix is to only add to the free list when we are done
with the allocation.

Also fix a problem where the usable size is computed incorrectly because
two of the arguments where reversed.

In addition, add a check that the allocation being verified has the correct
tag before trying to check the body of the allocation.

Add a test to catch the original failure.

Add a test for the tag being different.

Bug: 27601650
Change-Id: Ie9200677d066255b8e668a48422f23f909f4ddee
2016-03-16 17:38:08 -07:00
Douglas Leung
f3b9c89d3a Fix bug where t9 is not correct when __memset_chk_fail is called.
t9 is used to calculate gp at the start of __memset_chk_fail.

Change-Id: Ief5018699e060afa691bfc1d861abd5e463ab80c
2016-03-16 17:02:17 -07:00
Elliott Hughes
545afa16bb Fix PTHREAD_THREADS_MAX.
We don't have a compile-time limit on the number of threads,
and we don't have a definite run-time limit either.

Bug: http://b/27617302
Change-Id: I6a6fe083e7b655d24eb9e7ef7f3e0280d483080b
2016-03-15 17:23:12 -07:00
Christopher Ferris
a4b1425275 Fix problem where unknown option is not an error.
If the first option is found, then any unknown options are simply
ignored, but do not produce an error. Fixed this so that each
option found is actually verified to exist.

Bug: 27620263
Change-Id: If58732df3285eeae72188162c505e0e202fada8c
2016-03-14 15:34:22 -07:00
Christopher Ferris
0e00c168ce Merge "Init functions after debug malloc succeeds." 2016-03-12 21:15:34 +00:00
Christopher Ferris
20f2c1ebd5 Init functions after debug malloc succeeds.
Do not initialize all of the global function pointers associated with
debug malloc until the initialization has completed correctly.

Bug: 27600760
Change-Id: I0621b54bc2d9fab63805d7992d384e550d6fed2a
2016-03-11 12:27:02 -08:00
Colin Cross
7877df66c2 malloc_debug: fix multiplication overflow in debug_calloc
The over flow check for nmemb * bytes in debug_calloc is incorrect,
use the builtin overflow functions to check for multiplication and
addition overflow.

Change-Id: I3f1c13102621bc5380be1f69caa88dba2118f3cb
(cherry picked from commit 239838608d)
2016-03-10 14:53:02 -08:00
Colin Cross
9567c7b82c malloc_debug: round 0 byte allocations up to 1 byte
0 byte allocations can cause problems if they are immediately followed
by another allocation with no header, as both allocations will have the
same address.  Treat 0 byte allocations as 1 byte allocations so that
debug_iterate will return separate addresses for them.

Bug: 27578580
Change-Id: Ia8dc3481fa7062391e9b3ae58a36e8d47e7ee557
(cherry picked from commit 15af478080)
2016-03-10 14:53:02 -08:00
Colin Cross
baa7c6f307 malloc_debug: iterate: use usable_size
malloc_iterate with malloc debug enabled was returning allocation sizes
using the requested size instead of usable size.  If anything wrote
pointers above the requested size but below the usable size, those
pointers would be invisible to libmemunreachable and referenced
allocations could be reported as a leak.

Bug: 27107100
Change-Id: I6b19fd631f68ce93b3aee408cc3d296ec457bd01
(cherry picked from commit b23c6606d2)
2016-03-10 14:53:02 -08:00
Elliott Hughes
ffd19ee64d Merge "Improve and fix the stack-protector tests." 2016-03-10 16:12:27 +00:00
Elliott Hughes
fc69a8ad5f Improve and fix the stack-protector tests.
Bug: http://b/26888853
Change-Id: I505dbf7d5934f7247fb639f55dd6a9341df3947b
2016-03-09 14:50:03 -08:00
Erik Kline
7bbb181bf0 Don't leak sockets if setsockopt() or fchown() fail.
Change-Id: Idcf8c08ff50d21c3a04b7ef80c4044f3f9762f2b
2016-03-09 12:11:13 +09:00
Elliott Hughes
2bf5332f23 Minor clock_getcpuclockid optimization.
Don't ask the kernel to copy data to userspace if we don't need it.
(Noticed while cleaning up sysconf to not call clock_getres.)

Change-Id: Icc0f7559775b8a2dcefe638ce831d06b75d67122
2016-03-07 11:54:02 -08:00
Josh Gao
ba2232d013 Merge "forkpty: set the output fd to -1 on the slave side." 2016-03-05 03:04:37 +00:00
Elliott Hughes
d2b8de2cd1 Don't call clock_getres in sysconf.
There are a hundred other reasons why we can't run on kernels old enough
to not have all the clocks covered by sysconf.

This was causing trouble for jemalloc 4.1.0 in a seccomp-constrained process
because jemalloc 4.1.0 introduced a call to sysconf that caused us to make
clock_getres syscalls for the first time, leading to SIGSYS.

Bug: http://b/27408522
Change-Id: I2eb6986d871bc03cbef278e5617734409c39e057
2016-03-04 18:28:53 -08:00
Josh Gao
6d7c1ee9ff forkpty: set the output fd to -1 on the slave side.
glibc, FreeBSD, OpenBSD, and Darwin all just leave the fd unchanged and
possibly uninitialized. Setting it to -1 seems friendlier, though.

Bug: http://b/27506278
Change-Id: I7acdc8eecbea4404d5fb4ba0b4d572245a323886
2016-03-04 18:04:41 -08:00
Douglas Leung
29d4b71426 Add __memset_chk assembler for mips32 and mips64.
Change-Id: I365b1f345c695850c30ccb1a9f56f254ce182000
2016-03-04 15:15:00 -08:00
Elliott Hughes
728e0e9b97 Merge "Add x86 __memset_chk assembler." 2016-03-04 16:28:10 +00:00
Elliott Hughes
7d188ce0fe Merge "Fix x86-64 __memset_chk." 2016-03-04 03:12:35 +00:00
Elliott Hughes
a80ddc8a34 Fix x86-64 __memset_chk.
I can only assume I was testing the 32-bit implementation when I claimed
this worked. While improving the 32-bit code I realized that I'd used
signed comparisons instead of unsigned, and came back to find that the
64-bit code didn't work.

By way of apology, make x86-64 the first architecture where __memset_chk
falls through to memset.

Change-Id: I54d9eee5349b6a2abb2ce81e161fdcde09556561
2016-03-03 16:46:25 -08:00
Elliott Hughes
81d6a18c69 Add x86 __memset_chk assembler.
Change-Id: Ic6732f761ea8a41f70d5ff59d47ad38417d17cc2
2016-03-03 16:10:33 -08:00