Commit graph

3215 commits

Author SHA1 Message Date
zijunzhao
e1833e54a7 Set __BIONIC_COMPLICATED_NULLNESS for the vsnprintf family
When annotating the netinet directory aosp/2552567, we realize the
argment s for vsnprintf family can be null only if the buffer size is 0.
So we correct them and add some tests to verify our assumption.

Bugs: b/245972273
Test: adb shell
Change-Id: I51063286272be0daee0d7c1453a374b1f5674481
2023-04-26 23:14:36 +00:00
Elliott Hughes
88ba3c1af3 Fix the hwasan_test copyright header.
Someone uploaded --no-verify, and now I'm being asked to change the
NOTICE file. Instead, let's just use the existing BSD header for 2023,
since we've been trying to keep the tests BSD licensed anyway.

Test: treehugger
Change-Id: I4a5b1a50c65bebaaa3015634b67868b3b7a7ce32
2023-04-24 17:10:20 -07:00
Zijun Zhao
727ebe08ca Merge "Nullability check for sem module." 2023-04-22 01:13:01 +00:00
Elliott Hughes
1c1e1a6f04 Merge "Fix pthread#pthread_heap_allocated_stack for jemalloc." 2023-04-21 22:18:00 +00:00
zijunzhao
271d4d2515 Nullability check for sem module.
Bugs: b/245972273
Test: adb shell
Change-Id: Ie29aa34c449300c53591557c99b6ec08ebe3efcf
2023-04-21 21:34:11 +00:00
Elliott Hughes
18e335b3da Fix pthread#pthread_heap_allocated_stack for jemalloc.
Since we need a page-aligned allocation for a thread stack, explicitly
ask for one. (Scudo happens to just give us one anyway for an allocation
this large, but 32-bit jemalloc does not.)

Bug: http://b/277598913
Test: treehugger
Change-Id: I41eeb6aadb6a22bf5d9619e768e5e0a76617f747
2023-04-21 11:18:40 -07:00
zijunzhao
3b846ea6e7 Implement C23 printf 'w' length modifiers
wN: Specifies that a following b, d, i, o, u, x, or X
conversion specifier applies to an integer argument with
a specific width where N is a positive decimal integer with
no leading zeros

Bug: b/271903607
Test: adb shell
Change-Id: I688f6cefeb2e5c8325b007a59935a46f4116ac29
2023-04-20 20:34:33 +00:00
Zijun Zhao
e2c25fa87f Merge "stdio_test: improve the %b/%B tests." 2023-04-20 18:59:59 +00:00
Elliott Hughes
e393d48bc7 Merge "Clarify dlfcn.dladdr_libc slightly." 2023-04-20 15:06:48 +00:00
zijunzhao
7ce2f95e28 Nullability check for wchar module.
Bugs: b/245972273
Test: adb shell
Change-Id: I9898a1120c2364e5269633a67bf789a8bb943ba5
2023-04-20 01:41:49 +00:00
Elliott Hughes
e50d9d2418 stdio_test: improve the %b/%B tests.
Test all the widths, and test the PRIb* macros too.

Test: treehugger
Change-Id: I86c222b4c6282ab557e6456a892c007f09cd53db
2023-04-19 16:41:37 -07:00
Elliott Hughes
17b2bae190 Merge "Make tmpfile() respect $TMPDIR." 2023-04-19 20:01:51 +00:00
Elliott Hughes
0cf311c53b Clarify dlfcn.dladdr_libc slightly.
This isn't a very helpful way to say "realpath() failed":
```
bionic/tests/dlfcn_test.cpp:(1006) Failure in test dlfcn.dladdr_libc
Value of: realpath("/system/lib64/" "hwasan/libc.so", libc_realpath) == libc_realpath
  Actual: false
Expected: true
```

Bug: http://b/278795547
Test: treehugger
Change-Id: I1078ab4a675b956327f2578086a1a5e7d8a2928b
2023-04-19 20:01:17 +00:00
Elliott Hughes
8b86c0bdeb Make tmpfile() respect $TMPDIR.
Contrary to the old comment, POSIX says nothing about whether or not
tmpfile() respects $TMPDIR, and it's significantly more useful on
Android if it does (because there's no shared /tmp that everyone can
write to).

Bug: https://issuetracker.google.com/36991167
Test: treehugger
Change-Id: I3cc45adff167420f100c8ed1c63cba1ea67e9f70
2023-04-18 17:11:06 -07:00
Treehugger Robot
a1ff2e6159 Merge "Nullability check for msg module." 2023-04-17 18:09:10 +00:00
zijunzhao
c76899fe5e Nullability check for msg module.
Bugs: b/245972273
Test: adb shell
Change-Id: Iefb2ae298240b91fcf5657aca0e6f8370095f50b
2023-04-15 01:13:26 +00:00
Florian Mayer
4967017c86 Merge "Introduce hwasan mode for linker" 2023-04-14 23:27:56 +00:00
Colin Cross
6ff7f99b61 Merge "Skip utmp_test.cpp for musl" 2023-04-14 19:39:37 +00:00
Colin Cross
118202b132 Skip utmp_test.cpp for musl
Musl #defines utmp to utmpx, which causes the tests in utmp_test.cpp
to collide with the ones in utmpx_test.cpp.  Skip the utmp_test.cpp
when building for musl.

Test: m USE_HOST_MUSL=true
Change-Id: Ie05ddf6e1fd8c3bcc687d2537c19b6ab70ab8d67
2023-04-14 09:33:11 -07:00
Treehugger Robot
177b724cb4 Merge "Nullability check for random module." 2023-04-14 14:41:12 +00:00
Florian Mayer
c10d064b5c Introduce hwasan mode for linker
This mode instructs the linker to search for libraries in hwasan
subdirectories of all library search paths. This is set up to contain a
hwasan-enabled copy of libc, which is needed for HWASan programs to
operate. There are two ways this mode can be enabled:

* for native binaries, by using the linker_hwasan64 symlink as its
  interpreter
* for apps: by setting the LD_HWASAN environment variable in wrap.sh

Bug: 276930343
Change-Id: I0f4117a50091616f26947fbe37a28ee573b97ad0
2023-04-14 01:33:30 -07:00
zijunzhao
e43d55348f Nullability check for random module.
Bugs: b/245972273
Test: adb shell
Change-Id: Ie7e06bcf4fda1b177c8d8fcb6a813c1b4a50ea26
2023-04-14 01:01:37 +00:00
zijunzhao
d3e0652877 Nullability check for semaphore module
Bugs: b/245972273
Test: adb shell
Change-Id: I52598efabf40a49dc75057dc8acb8228ed039fca
2023-04-12 18:07:11 +00:00
Christopher Ferris
80e5ee7e23 Merge "Add annotations." 2023-04-06 22:00:14 +00:00
Christopher Ferris
59075565d2 Add annotations.
Bug: 265431689

Test: NA
Change-Id: I0c19fc76b1ccdcb9f42167b52d1df247765fcd34
Merged-In: I0c19fc76b1ccdcb9f42167b52d1df247765fcd34
(cherry picked from commit ed4ad19662)
2023-04-06 19:30:23 +00:00
Elliott Hughes
7b5cc4b251 Merge "<spawn.h>: add posix_spawn_file_actions_addchdir_np()/posix_spawn_file_actions_addfchdir_np()." 2023-04-06 17:51:45 +00:00
Elliott Hughes
462ca8b314 <spawn.h>: add posix_spawn_file_actions_addchdir_np()/posix_spawn_file_actions_addfchdir_np().
The recent header nullability additions and the corresponding source
cleanup made me notice that we're missing a couple of actions that most
of the other implementations have. They've also been added to the _next_
revision of POSIX, unchanged except for the removal of the `_np` suffix.

They're trivial to implement, the testing is quite simple too, and
if they're going to be in POSIX soon, having them accessible in older
versions of Android via __RENAME() seems useful. (No-one else has shipped
the POSIX names yet.)

Bug: http://b/152414297
Test: treehugger
Change-Id: I0d2a1e47fbd2e826cff9c45038928aa1b6fcce59
2023-04-04 17:28:39 -07:00
Elliott Hughes
dbf5b2eb55 Add POSIX <utmpx.h>.
Now <utmpx.h> isn't any more useful on Android than <utmp.h> is, but it
is POSIX, and -- importantly -- we can implement it with just a header
file, so code can use it on every existing API level.

macOS does indeed only have the <utmpx.h> functions (although it does
still have the <utmp.h> header!), so potentially portable code might
want <utmpx.h> on Android. (glibc/musl both have both headers.)

Bug: https://github.com/landley/toybox/pull/213
Test: treehugger
Change-Id: Iaa88167708182009a63e2e1a15f11186b251ed02
2023-04-03 17:20:58 -07:00
Mitch Phillips
e6d5099fcc Merge "[GWP-ASan] Remove system_default torture tests." 2023-04-03 17:05:35 +00:00
zijunzhao
2146303272 Nullability check for sched module.
Bugs: b/245972273
Test: adb shell
Change-Id: Icb8028ec5864370c0ebfb300f9b6df01edf2742d
2023-03-29 21:46:57 +00:00
Mitch Phillips
c59d5cc5f1 [GWP-ASan] Remove system_default torture tests.
While these tests were running, other native processes would get torture GWP-ASan. This can lead to OOMs.

Bug: 273904016
Change-Id: Ia813a73bfc1c379633be022dbf4b7d567069c731
Test: atest bionic-unit-tests (in presubmit)
2023-03-27 14:34:40 +00:00
Treehugger Robot
bc28931eb9 Merge "Skip the MemtagNoteTests when the overriding sysprop is set." 2023-03-23 22:36:51 +00:00
Peter Collingbourne
d642c30ee0 Skip the MemtagNoteTests when the overriding sysprop is set.
Bug: 273807460
Change-Id: Ieb33354fd8a705c1b2a661055f69d2ec4b32b5e8
2023-03-22 20:08:42 -07:00
Treehugger Robot
688bddc1e5 Merge "Fix setjmp.bug_152210274 with HWASan/stack MTE enabled." 2023-03-22 23:29:31 +00:00
Peter Collingbourne
85a7f6b391 Merge "Disable stack tagging in CloneStartRoutine." 2023-03-22 21:14:54 +00:00
Peter Collingbourne
25a7c3fd57 Fix setjmp.bug_152210274 with HWASan/stack MTE enabled.
This test was flaky because there was no synchronization between the end
of the test function scope and the jumper threads, resulting in a racy
use-after-scope when accessing the thread array. Fix it by joining the
threads before leaving the test function scope.

Replace the thread array access, which can race with the store to the
thread array in the main thread, with an access to a pre-initialized
variable, which acts as a kind of enforcement that the threads are done
before leaving the test.

Bug: 227390656
Change-Id: Icfbb0d7cae66c12e5ce31072c34529e3c5fdf563
2023-03-22 13:49:53 -07:00
Peter Collingbourne
955f04425e Disable stack tagging in CloneStartRoutine.
We don't support running threads on a tagged stack. Untagging SP may
lead to accesses to the stack via a non-SP register, which will be tag
checked, and the check will fail. And indeed that's exactly what the
__bionic_clone function does in its first instruction. Fix the problem by
disabling HWASan and MTE stack tagging on CloneStartRoutine, and remove
the call to untag_address, as it is unnecessary.

Bug: 273807460
Change-Id: I94cc56c816897531c0113c856b54ec41b4aab874
2023-03-21 22:57:50 -07:00
Elliott Hughes
060cd2438c Merge "riscv64 SCS support." 2023-03-21 22:10:56 +00:00
Christopher Ferris
35759fa84c Fix mte build breakage.
The strerror_buf is way too large, so instead of using a separate
buffer for just this string, reuse the already existing buffer.
Increase the buffer size to cover the maximum errno string.

Add a unit test to verify that none of the errno values are cut off
in the async_safe_format_buffer function when passing %m.

Bug: 274474681

Test: New unit test passes.
Test: Changing the buffer to a small value and verify that the test fails.
Change-Id: I4cb4652709582a8a6b958e12de5d923ec950e6b6
2023-03-21 18:11:02 +00:00
Christopher Ferris
dcd1403818 Merge "Add support for M_PURGE_ALL." 2023-03-17 21:06:20 +00:00
zijunzhao
106aa0074d Nullability check for locale module
Bugs: b/245972273
Test: adb shell
Change-Id: If730065895e0f074318df545906b7e60fcae053d
2023-03-16 21:42:57 +00:00
Yi Kong
714a33d32d Set optnone attribute for modify_stack_protector_test
clang-r487747 gets too clever and removes the store, even if it is
declared as volatile. Set optnone to prevent the compiler optimizing out
the store.

Test: atest CtsBionicTestCases
Bug: 271214588
Change-Id: I14a537ecd4657ee3f510ff531313bd9d56f22f47
2023-03-15 01:03:59 +09:00
Christopher Ferris
d86eb8665c Add support for M_PURGE_ALL.
This is a new mallopt option that will force purge absolutely
everything no matter how long it takes to purge.

Wrote a unit test for the new mallopt, and added a test to help
verify that new mallopt parameters do not conflict with each other.

Modified some benchmarks to use this new parameter so that we can
get better RSS data.

Added a new M_PURGE_ALL benchmark.

Bug: 243851006

Test: All unit tests pass.
Test: Ran changed benchmarks.
Change-Id: I1b46a5e6253538108e052d11ee46fd513568adec
2023-03-13 19:55:32 -07:00
Zijun Zhao
2c445d9979 Merge "Nullability check for stdio module" 2023-03-08 05:16:57 +00:00
Elliott Hughes
b6e7e2c39b Merge "Remove #pragma workarounds for %b/%B." 2023-03-07 16:24:18 +00:00
zijunzhao
00a3dbaab6 Nullability check for stdio module
Bugs: b/245972273
Test: adb shell
Change-Id: I6d1f2afad6ab3f884795a2d33875684a14fe54d6
2023-03-07 01:07:19 +00:00
Elliott Hughes
6f231ce503 Remove #pragma workarounds for %b/%B.
We have a new enough clang now that it knows about %b/%B.

Test: treehugger
Change-Id: I92f21e3bebdd652a4826ce8caa33400c3e3db72f
2023-03-06 23:30:12 +00:00
Florian Mayer
ee824ae6e0 Merge "add test for using malloced stack for pthread_create" 2023-03-06 20:52:25 +00:00
Christopher Ferris
90dd5f0fd1 Merge "Don't run GWP ASan integration tests under HWASan." 2023-03-03 01:48:58 +00:00
Florian Mayer
f966620ca0 add test for using malloced stack for pthread_create
Bug: 148982147
Change-Id: I65e284a083236f1a552fb1e2fefe1c268ed2ecc3
2023-03-02 15:34:10 -08:00