Commit graph

38581 commits

Author SHA1 Message Date
Elliott Hughes
e7b3b8b467 setjmp.h: increase riscv64 jmp_buf size.
If we switch from x18 to gp for shadow call stack, we're going to need
another slot in jmp_buf. We'll need this even for hardware shadow call
stacks too.

While I'm here, and because this is likely my last chance, let's just
round this up to 32 for safety. musl and glibc only have the minimum
needed (which I think means they'll need an ABI break to support SCS
unless they just use a callee-saved general purpose register), but since
we can't do ABI breaks after we ship, let's play it safe.

Bug: https://github.com/google/android-riscv64/issues/72
Test: treehugger
Change-Id: I60661fb7a308c900bfd08c9361f51919b798c005
2023-04-06 14:44:50 -07:00
Florian Mayer
eb1b6fffdd Merge "Remove unused include" 2023-04-06 21:06:27 +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
6296071782 Merge "Add POSIX <utmpx.h>." 2023-04-06 14:57:12 +00:00
Florian Mayer
a902a0d876 Remove unused include
Change-Id: Id46b277016e5f942a6cf8445d726da6fac254e22
2023-04-05 23:56:51 +00:00
Treehugger Robot
3260e71254 Merge "Nullability check for search module" 2023-04-05 22:10:22 +00:00
zijunzhao
fdf9e2e2e5 Nullability check for search module
Bugs: b/245972273
Test: adb shell
Change-Id: I9dffba498f2d46318378c3b5e436962d6c4b9dae
2023-04-05 19:40:21 +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
Dan Albert
eee46dc744 Exclude crtbrand.o from the NDK sysroot.
Bug: None
Test: None
Change-Id: I8cb860d9c47b9140926531d21f7864b8d7cbcba3
2023-04-04 23:27:52 +00: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
Elliott Hughes
4b27a21b6a Merge "ELS TLS documentation: s/module/module_id/." 2023-04-03 20:47:59 +00:00
Elliott Hughes
97c6902269 Merge "uapi headers: simplify the <linux/compiler.h> stuff." 2023-04-03 18:44:53 +00:00
Treehugger Robot
022a139497 Merge "Nullability check for spawn module" 2023-04-03 18:18:37 +00:00
Mitch Phillips
e6d5099fcc Merge "[GWP-ASan] Remove system_default torture tests." 2023-04-03 17:05:35 +00:00
Elliott Hughes
61d435c29a Merge "riscv64: typedef struct ucontext {...} ucontext_t." 2023-04-03 15:23:31 +00:00
Elliott Hughes
b692ecb913 ELS TLS documentation: s/module/module_id/.
The field is actually called `module_id` in the code.

Test: N/A
Change-Id: I10f5ce07cb67f7f338036c49e0008c3dce2db0bd
2023-04-03 14:31:37 +00:00
Treehugger Robot
e744d81787 Merge "Nullability check for dirent module" 2023-04-01 02:46:24 +00:00
zijunzhao
8f23da612f Nullability check for spawn module
Bugs: b/245972273
Test: adb shell
Change-Id: Ibf99a24e2af8a317f513252391a30576f0c08e2e
2023-04-01 00:14:02 +00:00
Zijun Zhao
6ef483eb87 Merge "posix_spawn_file_actions_addopen(): crash early rather than late." 2023-03-31 23:59:02 +00:00
Elliott Hughes
53c90ebfdd riscv64: typedef struct ucontext {...} ucontext_t.
All the other architectures are already polluting the namespace with
`struct ucontext`, so make riscv64 match for source compatibility with
other Android code. (Code _should_ be using the POSIX `ucontext_t`, but
ART in particular had a lot of `struct ucontext`, and although I'll
clean that up separately, if there's some in our tree, there's probably
a lot more out there in the wild.)

Test: treehugger
Change-Id: Id0e4e97e660d7d60e792cd2462ddb9788d4772d7
2023-03-31 15:31:37 -07:00
Elliott Hughes
b8e4e469dc posix_spawn_file_actions_addopen(): crash early rather than late.
We're going to dereference a null pointer if you pass one instead of a
pointer to a path, but at the moment (because of implementation sharing
between the different file actions) we won't do it until the last
minute, in the child itself. Let's crash as soon as you make the mistake
instead, to make debugging a lot easier.

Test: treehugger
Change-Id: I987d2700ba05b9867a936ebe770224259376633f
2023-03-31 20:18:18 +00:00
zijunzhao
7d2df8be98 Nullability check for dirent module
Bugs: b/245972273
Test: adb shell
Change-Id: I70532170144a65f00dbccf56378f55daf2d362df
2023-03-31 18:54:31 +00:00
Elliott Hughes
0f0c18f695 uapi headers: simplify the <linux/compiler.h> stuff.
We don't really need <linux/compiler.h> and <linux/compiler_types.h>. We
already have a mechanism to remove unused macros, so let's do that. We
don't currently have a way to remove unused #includes, so we still need
<linux/compiler.h> and <linux/compiler_types.h> files (but I've clarified
the comments in them).

I've kept the empty definitions of `__user` and `__force` for source
compatibility. (We had one security test at least that was assuming
a kernel struct definition will "just work".)

Bug: http://b/262917450
Test: treehugger
Change-Id: Iacbbbc1aeef9a4fac52dabd7811ab875cc267d4f
2023-03-30 12:47:08 -07:00
Treehugger Robot
5ae243b7f9 Merge "Nullability check for fts module" 2023-03-30 18:20:48 +00:00
Treehugger Robot
0fec9c0e19 Merge "Nullability check for sched module." 2023-03-30 01:35:49 +00:00
zijunzhao
dec8efd72a Nullability check for fts module
Bugs: b/245972273
Test: adb shell
Change-Id: I56f796a3968484c69c3389fffafdbd960a99845f
2023-03-29 22:51:24 +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
Elliott Hughes
9dfcaa64e8 Merge "scandir: clarity improvements." 2023-03-29 21:07:25 +00:00
Treehugger Robot
9a3164145c Merge "Nullability correction for stdlib module." 2023-03-29 18:54:34 +00:00
zijunzhao
99dd5b1e27 Nullability correction for stdlib module.
Bugs: b/245972273
Test: adb shell
Change-Id: I0a800ccfe3bae88d3e924dd621bad182cb186b27
2023-03-29 00:26:29 +00:00
Elliott Hughes
f6c25d6fd3 scandir: clarity improvements.
Move the "is there a comparator?" check into the sole caller, to match
the "is there a filter?" check. Remove the unnecessary (and unlikely)
pre-sort "is the array empty?" check.

Test: treehugger
Change-Id: I8bd461380420dce4a8bc05ef5fe3511b26347d7c
2023-03-28 22:35:24 +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
Christopher Ferris
345f54666a Merge "Move M_PURGE to M_PURGE_ALL." 2023-03-24 19:29:51 +00:00
Treehugger Robot
76210fba9e Merge "Time for SEO in <android/api-level.h>." 2023-03-24 16:10:48 +00:00
Yi Kong
ab3a319746 Merge "Workaround boot loop by turning off stack protector check for noreturn calls" 2023-03-24 13:19:52 +00:00
Treehugger Robot
bc28931eb9 Merge "Skip the MemtagNoteTests when the overriding sysprop is set." 2023-03-23 22:36:51 +00:00
Elliott Hughes
572053a02e Time for SEO in <android/api-level.h>.
So many names/numbers for one release...

Test: treehugger
Change-Id: I00ddb13485c185fc003ea087f1df404bc39fa435
2023-03-23 21:30:15 +00:00
Treehugger Robot
40af03dcaf Merge "Add macro for API level V." 2023-03-23 21:28:49 +00:00
Dan Albert
b3e895c86a Add macro for API level V.
No idea if this will be the actual API level or not, but that's all
the more reason to abstract it away early...

Bug: None
Test: None
Change-Id: I8a17bb42dbb08a6e760427514af8331e7dc9b549
2023-03-23 18:35:16 +00:00
Elliott Hughes
98886bb28d Merge "risc-v: use clang's builtins for more of libm." 2023-03-23 18:09:55 +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
Elliott Hughes
2289ca2bd3 risc-v: use clang's builtins for more of libm.
This completes the set, and gets riscv64 to parity with arm64.

Test: llvm-objdump -d
Test: bionic-unit-tests-static --gtest_filter='math*'
Bug: https://github.com/google/android-riscv64/issues/11
Change-Id: I4230005abcd8d6025d82f1e8afe5831fad2db04d
2023-03-22 14:11:35 -07: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
Christopher Ferris
f1ab9c4de7 Move M_PURGE to M_PURGE_ALL.
Since it doesn't matter if these calls take a little longer than
before, use the more thorough but slightly longer purge mechanism.

Test: Unit tests pass.
Change-Id: Ifab7166a9682a13231746b78717d52673d13be1b
2023-03-22 13:47:27 -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
424cf4378a Merge "Fix mte build breakage." 2023-03-21 21:20:55 +00:00