Commit graph

11464 commits

Author SHA1 Message Date
Kelvin Zhang
52e3190b9b Merge "Fix shadowstack init crash on 16K page system" into main 2023-07-11 18:03:31 +00:00
Elliott Hughes
6a6f527dfc Merge "Clarify the <sys/ifunc.h> docs." into main 2023-07-11 15:17:35 +00:00
Kelvin Zhang
fb733613e9 Fix shadowstack init crash on 16K page system
shadowstack implicitly assumes that SCS_SIZE is a multiple of page size.
Currently, SCS_SIZE is set to 8K. This assumption is broken on 16K
platforms.

Test: launch_cvd --use_16k
Bug: 253652966
Bug: 279808236
Change-Id: I1180cfba32c98d638e18615ccfdc369beb390ea7
2023-07-10 16:04:01 -07:00
Elliott Hughes
0c50ed4c7c Clarify the <sys/ifunc.h> docs.
This confused the Arm folks implementing function multi-versioning.

Test: treehugger
Change-Id: Ib56fc142bed4a2f2a394d60a07f322add40702e5
2023-07-10 22:32:09 +00:00
Christopher Ferris
37c3f3c67e Update to v6.4 kernel headers.
Kernel headers coming from:

Git: https://android.googlesource.com/kernel/common/
Branch: android-mainline
Tag: android-mainline-6.4

Test: Bionic unit tests pass.
Change-Id: I991f8eaa2b272a464166addb13e6bdc63734444d
2023-07-10 10:59:05 -07:00
Christopher Ferris
852f9b0673 Modify how the malloc debug tests run.
This will, hopefully, reduce the number of flaky runs of this test.

Add skipping xml files for the notice file parser.

Bug: 280572235

Test: atest malloc_debug_system_tests
Change-Id: I6fb76287f55d0cff5b695dce09cc2b7a69b62874
2023-06-30 15:09:44 -07:00
Elliott Hughes
0a94e1584e Explicitly document overcommit and adb shell's use of oom_score_adj.
This comes up now and then, and the different behavior with `adb shell`
in particular confuses people.

Bug: https://github.com/android/ndk/issues/1897
Test: N/A
Change-Id: I757fa6b6277610a139f326563d508fb9009dcb75
2023-06-26 19:03:41 +00:00
Treehugger Robot
48d405ea4b Merge "Mark getpagesize() const." 2023-06-24 01:09:17 +00:00
Elliott Hughes
c77993eda3 Mark getpagesize() const.
If folks want to use this instead of PAGE_SIZE, let's let the compiler
know that it doesn't need to be called more than once. Using "const"
rather than "pure" lets us cover more cases, and although this function
may need to check global state, it's _immutable_ global state, so it's
effectively "const".

Test: llvm-objdump -d
Change-Id: I0b13de79d44b57545258121df7cdd6490a9a5be1
2023-06-23 22:40:57 +00:00
Treehugger Robot
8995672880 Merge "Document how to use tzalloc()/tzfree() with std::unique_ptr." 2023-06-23 18:06:01 +00:00
Florian Mayer
26e0e00279 Merge "[HWASan] add comment to explain why we can use __has_feature" 2023-06-23 01:16:22 +00:00
Florian Mayer
02108ce6b1 [HWASan] add comment to explain why we can use __has_feature
Bug: 276930343
Change-Id: I0b3e152269a147f67cae3c534be92ee169fe393b
2023-06-22 14:56:18 -07:00
Elliott Hughes
5ea305b10e Document how to use tzalloc()/tzfree() with std::unique_ptr.
The hidden pointer makes this trickier than the usual incantation, so
leave some copy & paste lying around for anyone trying to work this out.

Test: treehugger
Change-Id: I26e94bf7a74ce3e43de587edc52ab63e36d1d86b
2023-06-22 20:54:12 +00:00
Elliott Hughes
31fc69f67f Fix tzalloc(nullptr) and add a test.
This works (by reading /etc/localtime) on NetBSD, but not on Android
since we have no such file. Fix that by using our equivalent system
property instead.

Also s/time zone/timezone/ in documentation and comments. We've always
been inconsistent about this (as is upstream in code comments and
documentation) but it seems especially odd now we expose a _type_ that
spells it "timezone" to talk of "time zone" even as we're describing
that type and its associated functions.

Bug: https://github.com/chronotope/chrono/issues/499
Test: treehugger
Change-Id: I142995a3ab4deff1073a0aa9e63ce8eac850b93d
2023-06-22 09:51:01 -07:00
Elliott Hughes
2bdeff449b Remove __INTRODUCED_IN_NO_GUARD_FOR_NDK(21).
There are still some instances of
`__INTRODUCED_IN_NO_GUARD_FOR_NDK(26)` which we can get rid of after the
libc++ update, but we can get rid of the API level 21 instances right
now, since the NDK no longer supports older API levels anyway.

Test: treehugger
Change-Id: I243957f15b68d3d89ec8e15e2aefc45e8c294c31
2023-06-20 14:32:58 -07:00
Elliott Hughes
fee0b45480 Merge "Remove the always-true __INTRODUCED_IN() annotations." 2023-06-20 20:47:49 +00:00
Christopher Ferris
90e2827762 Merge "Add new mallopt M_LOG_STATS." 2023-06-20 20:35:53 +00:00
Elliott Hughes
e405c90f19 Merge "<arpa/nameser.h>: rationalize __INTRODUCED_IN." 2023-06-20 16:56:13 +00:00
Christopher Ferris
e9a7b81d4a Add new mallopt M_LOG_STATS.
This new mallopt cause statistics of the allocator to be printed in
the log.

Add a stats print for jemalloc.

This is designed to be used as part of a dumpsys meminfo --XXXX
option so that it's easier to get information about apps that
have an unusual memory footprint.

Test: Unit tests pass.
Test: Ran on a device using jemalloc and verified log data.
Test: Ran on a device using scudo and verified log data.
Change-Id: I6fa44ce619c064b2596fbbb478c231994af94f4c
2023-06-17 00:00:02 +00:00
Elliott Hughes
9dbfe8bb69 <arpa/nameser.h>: rationalize __INTRODUCED_IN.
Investigation shows that the symbols that claimed to have been in 32-bit
builds one API level earlier than in 64-bit builds actually weren't ---
everything was actually API level 22. This patch fixes the libc.map.txt
to match reality, and then simplifies the __INTRODUCED_IN()
incantations.

Investigation also shows that we have a bunch of unused #defines, so
this patch removes the ones that don't correspond to functions we
actually expose.

Test: treehugger
Change-Id: I540dd0d1d9561cac17c55eb68a07bed58dd718fa
2023-06-16 15:59:52 -07:00
Elliott Hughes
655e430b28 Remove the always-true __INTRODUCED_IN() annotations.
The NDK no longer supports API levels earlier than 21.

This *doesn't* include <ctype.h> because I have a separate change
rewriting that (that's blocked on the upcoming libc++ update).

Test: treehugger
Change-Id: I53e915f27011dfc0513e0c78d8799377e183ceca
2023-06-16 12:39:33 -07:00
Elliott Hughes
836e81d019 _FILE_OFFSET_BITS is spelled with one underscore.
Test: treehugger
Change-Id: Ic21082ffa1083b63a95514dcd7f2d9e23f84c9b0
2023-06-16 11:55:07 -07:00
Elliott Hughes
f5cd29269f Merge "Expose tzalloc()/localtime_rz()/mktime_z()/tzfree()." 2023-06-16 15:14:24 +00:00
Elliott Hughes
2bd4316bd6 Expose tzalloc()/localtime_rz()/mktime_z()/tzfree().
* Rationale

The question often comes up of how to use multiple time zones in C code.
If you're single-threaded, you can just use setenv() to manipulate $TZ.
toybox does this, for example. But that's not thread-safe in two
distinct ways: firstly, getenv() is not thread-safe with respect to
modifications to the environment (and between the way putenv() is
specified and the existence of environ, it's not obvious how to fully
fix that), and secondly the _caller_ needs to ensure that no other
threads are using tzset() or any function that behaves "as if" tzset()
was called (which is neither easy to determine nor easy to ensure).

This isn't a bigger problem because most of the time the right answer
is to stop pretending that libc is at all suitable for any i18n, and
switch to icu4c instead. (The NDK icu4c headers do not include ucal_*,
so this is not a realistic option for most applications.)

But what if you're somewhere in between? Like the rust chrono library,
for example? What then?

Currently their "least worst" option is to reinvent the entire wheel and
read our tzdata files. Which isn't a great solution for anyone, for
obvious maintainability reasons.

So it's probably time we broke the catch-22 here and joined NetBSD in
offering a less broken API than standard C has for the last 40 years.
Sure, any would-be caller will have to have a separate "is this
Android?" and even "is this API level >= 35?" path, but that will fix
itself sometime in the 2030s when developers can just assume "yes, it
is", whereas if we keep putting off exposing anything, this problem
never gets solved.

(No-one's bothered to try to implement the std::chrono::time_zone
functionality in libc++ yet, but they'll face a similar problem if/when
they do.)

* Implementation

The good news is that tzcode already implements these functions, so
there's relatively little here.

I've chosen not to expose `struct state` because `struct __timezone_t`
makes for clearer error messages, given that compiler diagnostics will
show the underlying type name (`struct __timezone_t*`) rather than the
typedef name (`timezone_t`) that's used in calling code.

I've moved us over to FreeBSD's wcsftime() rather than keep the OpenBSD
one building --- I've long wanted to only have one implementation here,
and FreeBSD is already doing the "convert back and forth, calling the
non-wide function in the middle" dance that I'd hoped to get round to
doing myself someday. This should mean that our strftime() and
wcsftime() behaviors can't easily diverge in future, plus macOS/iOS are
mostly FreeBSD, so any bugs will likely be interoperable with the other
major mobile operating system, so there's something nice for everyone
there!

The FreeBSD wcsftime() implementation includes a wcsftime_l()
implementation, so that's one stub we can remove. The flip side of that
is that it uses mbsrtowcs_l() and wcsrtombs_l() which we didn't
previously have. So expose those as aliases of mbsrtowcs() and
wcsrtombs().

Bug: https://github.com/chronotope/chrono/issues/499
Test: treehugger
Change-Id: Iee1b9d763ead15eef3d2c33666b3403b68940c3c
2023-06-16 08:10:47 -07:00
Dimitry Ivanov
81d1e3df44 Merge "Use more appropriate param type for __early_abort" 2023-06-16 09:53:00 +00:00
zijunzhao
4e274fa0a9 Nullability check for socket module.
Bugs: b/245972273
Test: adb shell
Change-Id: Id0f1aa156ff010358f2484b2f58aa3beacc1409c
2023-06-15 23:51:02 +00:00
dimitry
e07704aa6e Use more appropriate param type for __early_abort
Test: build, start emulator
Change-Id: I5f31ceb9a85ee7750f17edff76782c778a4515d8
2023-06-15 14:40:42 +00:00
Treehugger Robot
5c6961ff6d Merge "Nullability check for wctype module." 2023-06-15 00:29:25 +00:00
Treehugger Robot
42e7ac10ed Merge "<iconv.h>: clarify the docs a bit more." 2023-06-14 23:16:06 +00:00
Elliott Hughes
db14a74701 Merge "<arpa/nameser.h>: don't use __INTRODUCED_IN_64 in a defined(__LP64__) block." 2023-06-14 22:39:55 +00:00
zijunzhao
f0fb41851b Nullability check for modules in /platform directory.
Bugs: b/245972273
Test: adb shell
Change-Id: Iaefd0231de760455b24fb09aada0144a84379689
2023-06-14 22:27:49 +00:00
zijunzhao
1ee9fb5002 Nullability check for wctype module.
Bugs: b/245972273
Test: adb shell
Change-Id: I0f10db338876eb93a89be35130b097ebe19d2c15
2023-06-14 21:54:35 +00:00
Elliott Hughes
bac2573c87 <iconv.h>: clarify the docs a bit more.
Bug: https://github.com/android/ndk/issues/1895
Test: N/A
Change-Id: I68542e3b4d98ec5ae0e0ed1d199c2b4b23e98f6d
2023-06-14 20:55:58 +00:00
zijunzhao
cc475cf28d Implement C23 scanf 'wf' length modifiers
wfN: Specifies that a following b, d, i, o, u, x, or X conversion specifier applies to a fastest minimum-width integer argument with a specific width where N is a positive decimal integer with no leading zeros (the argument will have been promoted according to the integer promotions, but its value shall be converted to the unpromoted type); or that a following n conversion specifier applies to a pointer to a fastest minimum-width integer type argument with a width of N bits. All fastest minimum-width integer types (7.22.1.3) defined in the header <stdint.h> shall be supported. Other supported values of N are implementation-defined.

Bug: b/271903607
Test: adb shell
Change-Id: Iaa1f6d87251144de0b763672ca93f23272880ad1
2023-06-14 17:15:58 +00:00
zijunzhao
1e28d06667 Nullability check for socket module.
Bugs: b/245972273
Test: adb shell
Change-Id: I7b6b00705ad7476fabf30727347555eeafff6eda
2023-06-13 21:15:34 +00:00
Treehugger Robot
cf2090b962 Merge "<complex.h>: stop using __INTRODUCED_IN_(32|64)." 2023-06-13 21:05:29 +00:00
Elliott Hughes
826ea44822 Merge "Remove PAGE_SIZE call sites." 2023-06-13 20:36:45 +00:00
Zijun Zhao
0594346633 Merge "Fix iconv_open(3) docs." 2023-06-13 17:20:41 +00:00
Elliott Hughes
7a5d9925b7 Fix iconv_open(3) docs.
Strictly the _doc comment_ is correct, but the names of the parameters
are the wrong way round. (Although iconv_open() follows the usual C
tradition of "destination first", iconv() itself doesn't, so these
functions are inherently confused/confusing.)

Bug: https://github.com/android/ndk/issues/1895
Test: N/A
Change-Id: Iafc9bd630ece1d3c55986b04bb9a99c477716530
2023-06-13 07:38:02 -07:00
Peter Collingbourne
bb11ee6d9c Remove PAGE_SIZE call sites.
To enable experiments with non-4KiB page sizes, introduce
an inline page_size() function that will either return the runtime
page size (if PAGE_SIZE is not 4096) or a constant 4096 (elsewhere).
This should ensure that there are no changes to the generated code on
unaffected platforms.

Test: source build/envsetup.sh
      lunch aosp_cf_arm64_16k_phone-userdebug
      m -j32 installclean
      m -j32
Test: launch_cvd \
  -kernel_path /path/to/out/android14-5.15/dist/Image \
  -initramfs_path /path/to/out/android14-5.15/dist/initramfs.img \
  -userdata_format=ext4
Bug: 277272383
Bug: 230790254
Change-Id: Ic0ed98b67f7c6b845804b90a4e16649f2fc94028
2023-06-12 10:59:39 -07:00
Elliott Hughes
8fc6fcdfab <complex.h>: stop using __INTRODUCED_IN_(32|64).
Although the existing annotations were strictly true (see
https://github.com/android/ndk/issues/1888#issuecomment-1581773348 for
the gory details), given the Play Store requirement that 32-bit code
must have a 64-bit version, it's not obviously useful to offer a
function for 32-bit before 64-bit.

Test: treehugger
Change-Id: I8ca11b874c26dfaa632690f510cb5409d95012e9
2023-06-12 10:22:12 -07:00
Zijun Zhao
71a03774d5 Merge "Nullability check for string modules." 2023-06-12 16:57:00 +00:00
Elliott Hughes
6dd4a906b8 <arpa/nameser.h>: don't use __INTRODUCED_IN_64 in a defined(__LP64__) block.
Test: treehugger
Change-Id: I1e75d1c15abd7753e2c9f1decc57346895a7c7f8
2023-06-12 08:09:56 -07:00
Elliott Hughes
197677cfd9 Merge "Remove __INTRODUCED_IN_ architecture macros." 2023-06-12 13:40:47 +00:00
Treehugger Robot
26add4eae0 Merge "Remove __RENAME_STAT64." 2023-06-10 01:20:11 +00:00
zijunzhao
6d23a08717 Nullability check for string modules.
Bugs: b/245972273
Test: adb shell
Change-Id: I13852702ae87c1ca14ec4f073b5f4b3d42926929
2023-06-10 00:08:50 +00:00
Elliott Hughes
421b0ac28c Remove __INTRODUCED_IN_ architecture macros.
No longer used.

Test: treehugger
Change-Id: I90c2565d80fb65ab9bf3100fb85c897c3ed0afc2
2023-06-09 23:34:17 +00:00
Elliott Hughes
f242ef6f98 Remove __RENAME_STAT64.
Now API level 21 is our lowest supported API level, __RENAME_STAT64 is
useless.

Test: treehugger
Change-Id: I708b2142b30dfcf6c74e1a14475da690a8c25f59
2023-06-09 15:59:23 -07:00
Treehugger Robot
31849368bb Merge "Nullability check for fcntl module." 2023-06-09 18:38:00 +00:00
Treehugger Robot
6a65763b12 Merge "Nullability check for stdlib module." 2023-06-09 18:37:32 +00:00
Elliott Hughes
87e170df01 Merge "Remove __RENAME_LDBL." 2023-06-09 13:38:40 +00:00
zijunzhao
725c96c005 Nullability check for fcntl module.
Bugs: b/245972273
Test: adb shell
Change-Id: I8a60f54dfc0d3104f848cbb78d05aa0f96cd783a
2023-06-09 00:53:12 +00:00
zijunzhao
f40b4247e8 Nullability check for stdlib module.
Bugs: b/245972273
Test: adb shell
Change-Id: I0033d720b9da633d62b0b047563004e084829388
2023-06-09 00:52:55 +00:00
zijunzhao
7890484cae Implement C23 scanf '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 (the argument will have been promoted according to the integer promotions, but its value shall be converted to the unpromoted type); or that a following n conversion specifier applies to a pointer to an integer type argument with a width of N bits. All minimum-width integer types (7.22.1.2) and exact-width integer types (7.22.1.1) defined in the header <stdint.h> shall be supported. Other supported values of N are implementation-defined.

Bug: b/271903607
Test: adb shell
Change-Id: I595fd2ac7bc40d9fb7f1935b39933a6cc068eeff
2023-06-08 21:41:26 +00:00
Elliott Hughes
81e8402db3 Merge "Implement rvv version mem* and str* for riscv64" 2023-06-08 20:17:01 +00:00
Treehugger Robot
cb5188d4c8 Merge "Nullability check for poll module." 2023-06-08 02:06:03 +00:00
zijunzhao
b40e600ba8 Nullability check for poll module.
Bugs: b/245972273
Test: adb shell
Change-Id: Ia44d82bbc0382066ec420f2e7b676f16e1f6d90b
2023-06-07 23:57:12 +00:00
zijunzhao
a8d42a44bb Nullability check for threads_inlines module.
Bugs: b/245972273
Test: adb shell
Change-Id: I4ebf0598527857fc7bfbfc6ed07342af89de57b1
2023-06-07 23:03:46 +00:00
Elliott Hughes
ab2d3e1049 Remove __RENAME_LDBL.
Discussion of this during my recent minor cleanup convinced me that we
should just remove __RENAME_LDBL. There's no obvious benefit to being
able to build something for 32-bit if you can't build the same code for
64-bit, given that most new hardware (and entire verticals such as Auto)
are 64-bit-only, and the Play Store requires any app with 32-bit code to
also ship 64-bit code.

Test: treehugger
Change-Id: I1c5503b968ca66925d7bd125bd3630c41ec1bfd0
2023-06-07 17:20:53 +00:00
Treehugger Robot
063b6bfd65 Merge "Nullability check for stdatomic module." 2023-06-07 15:34:21 +00:00
Treehugger Robot
27713a5b02 Merge "Nullability check for termios_inlines module." 2023-06-07 00:10:39 +00:00
Treehugger Robot
4e22f30960 Merge "<math.h>: more use of __RENAME_LDBL." 2023-06-07 00:10:27 +00:00
zijunzhao
d909dffcca Nullability check for stdatomic module.
Bugs: b/245972273
Test: adb shell
Change-Id: I8d20606555f88b535259a589517f4c60b65f6761
2023-06-07 00:10:26 +00:00
Treehugger Robot
79600ce16b Merge "<fenv.h>: documentation, and __INTRODUCED_IN removal." 2023-06-06 22:37:59 +00:00
Treehugger Robot
c5774b8945 Merge "Nullability check for unistd module." 2023-06-06 22:36:04 +00:00
Treehugger Robot
fa203f18cc Merge "<sched.h>: __INTRODUCED_IN_ removal." 2023-06-06 22:22:27 +00:00
zijunzhao
9e19785d76 Nullability check for termios_inlines module.
Bugs: b/245972273
Test: adb shell
Change-Id: I0284efc272ed1c3352d4a72deb0760f697b1e877
2023-06-06 21:58:45 +00:00
zijunzhao
30cf6d09d5 Nullability check for unistd module.
Bugs: b/245972273
Test: adb shell
Change-Id: I958166bcea67399638c28d424b5976be29660232
2023-06-06 20:39:07 +00:00
Elliott Hughes
9cf6036048 <fenv.h>: documentation, and __INTRODUCED_IN removal.
Now the NDK doesn't support API levels below 21, we don't actually need
the different arm32 vs x86 annotations. In general we haven't been
removing this historical information because it might be interesting to
someone, and there's no real reason to remove it, but we've had
versioner bugs recently with these more complex cases.

Test: treehugger
Change-Id: I9460109a2648b9d05d7e21e397935293d3fea8eb
2023-06-06 20:32:12 +00:00
zijunzhao
acd090d585 Nullability check for stdio module.
Bugs: b/245972273
Test: adb shell
Change-Id: I3fe777e75f68b06b944830b96d091cf9d973e0db
2023-06-06 18:43:52 +00:00
Treehugger Robot
0428fc1a9c Merge "Nullability check for thread_properties module." 2023-06-06 00:18:33 +00:00
zijunzhao
70586d6a99 Nullability check for thread_properties module.
Bugs: b/245972273
Test: adb shell
Change-Id: I8f2c640d74d73576d81453973d63568472b2676e
2023-06-05 22:07:50 +00:00
Yun Hsiang
40a82d005c Implement rvv version mem* and str* for riscv64
Add vector version mem* and str* functions and only build them when the
vector extension is enabled.
The original implementation comes from
https://github.com/sifive/sifive-libc, which we agree to contribute to
the Android Open Source Project.

Test: mma

Change-Id: I11b671a5bc571d7c783a657f272f282df7d16c29
Signed-off-by: Yun Hsiang <yun.hsiang@sifive.com>
2023-05-31 09:32:42 +08:00
Treehugger Robot
32ce2d5c82 Merge "time.h: add doc comments." 2023-05-26 20:11:05 +00:00
Elliott Hughes
e17ebfd51a <math.h>: more use of __RENAME_LDBL.
Now the NDK doesn't support API levels below 21, we don't actually need
weird x86-specific annotations. In general we haven't been removing
this historical information because it might be interesting to someone,
and there's no real reason to remove it, but we've had versioner bugs
recently with these more complex cases.

Test: treehugger
Change-Id: Ia457bb338ecf55af8e319e411ec3bf48a03f3c03
2023-05-26 13:00:51 -07:00
Elliott Hughes
db36e0829b <sched.h>: __INTRODUCED_IN_ removal.
Now the NDK doesn't support API levels below 21, we don't actually need
the different arm32 vs x86 annotations. In general we haven't been
removing this historical information because it might be interesting to
someone, and there's no real reason to remove it, but we've had
versioner bugs recently with these more complex cases.

Test: treehugger
Change-Id: Id9c9b8ecc01d232becd5dd8741509c104a8b6e19
2023-05-26 12:58:14 -07:00
Elliott Hughes
d192dbecf0 time.h: add doc comments.
C23 adds timegm(), gmtime_r(), and localtime_r(). We should remove the
"non-standard" text for timegm(), and while I'm here, let's just
document everything in this file.

Test: treehugger
Change-Id: Ia44c1bd155c939f694f6f8138b9cb7503519522c
2023-05-26 09:13:41 -07:00
zijunzhao
c412f654c5 Nullability check for nameser module.
Bugs: b/245972273
Test: adb shell
Change-Id: I96a4616d1a758d0f04af5d7f0fb8a0206f068b6a
2023-05-25 21:47:11 +00:00
zijunzhao
bf627f4292 Nullability check for inet module.
Bugs: b/245972273
Test: adb shell
Change-Id: I5acb1910f25dc025e1c8924ebf8b6801503f5161
2023-05-24 22:02:49 +00:00
Elliott Hughes
525761fd7d static_assert is a keyword in C23.
Test: treehugger
Change-Id: I4eba529475b6255bef1af558f54c373aad8737d0
2023-05-24 08:48:42 -07:00
zijunzhao
969d6c129a Nullability check for shm module.
Bugs: b/245972273
Test: adb shell
Change-Id: I9bdd5727719311d063fa126fc286618e9d24a45b
2023-05-23 19:15:25 +00:00
Elliott Hughes
3285ae5a4d Merge "Fix the *return* types in the arm64 dynamic function dispatch." 2023-05-23 13:46:30 +00:00
Elliott Hughes
20f9d67327 Fix the *return* types in the arm64 dynamic function dispatch.
No actual effect on the code, but misleading and wrong. (The previous
change only fixed the argument types; I didn't notice that some of the
return types were wrong too.)

Test: treehugger
Change-Id: I1ee5c48e2652fd8cbf8178d5659e57f79e61898e
2023-05-22 19:28:33 +00:00
zijunzhao
9f6b4caa9e Nullability check for xattr module.
Bugs: b/245972273
Test: adb shell
Change-Id: I0137c86f3fa7e17fb5fe284c7693315b2df1e2db
2023-05-22 18:31:16 +00:00
Elliott Hughes
01db121db5 Merge "Fix the types in the arm64 dynamic function dispatch." 2023-05-19 14:15:53 +00:00
Elliott Hughes
a1974064ae Fix the types in the arm64 dynamic function dispatch.
No actually effect on the code, but misleading and wrong.

Test: treehugger
Change-Id: I55405ac224b4dcc2ae515954aed179c1cde3c73c
2023-05-18 13:40:12 -07:00
zijunzhao
2572571786 Nullability check for mman module.
Bugs: b/245972273
Test: adb shell
Change-Id: Ib5c4887d89581eaedcf4a3e128811a6a374a8d1b
2023-05-18 19:02:25 +00:00
Treehugger Robot
83f9b28792 Merge "Nullability check for system_properties module." 2023-05-18 18:38:17 +00:00
Florian Mayer
e20c5fa4ac Merge "Revert "Add debug logging for memtag level"" 2023-05-18 01:06:23 +00:00
Florian Mayer
dd44378da7 Revert "Add debug logging for memtag level"
This reverts commit b3f3e86878.

Reason for revert: This created spam in tombstones.

Change-Id: Ia7b8285a6abd6f89d49859a981be1c9cfa104f81
2023-05-17 20:59:14 +00:00
zijunzhao
a505b2d37a Nullability check for system_properties module.
Bug: b/245972273
Test: adb shell
Change-Id: I3a55b8107898014fe74fd1a6f442f1ec00e08790
2023-05-17 20:43:51 +00:00
Treehugger Robot
ad333b6161 Merge "riscv64: say "x3" rather than "gp" in shadow call stack assembler." 2023-05-17 16:51:16 +00:00
Elliott Hughes
c35a0dc08e riscv64: say "x3" rather than "gp" in shadow call stack assembler.
Neither is great, but "gp" seems actively misleading (and setjmp.S
says x3 every time, so we should be consistent if nothing else).

Bug: https://github.com/riscv-non-isa/riscv-elf-psabi-doc/pull/379
Test: treehugger
Change-Id: Ibccda74d4794caa770b82e7ba2e31ce7b645b83f
2023-05-16 16:09:30 -07:00
zijunzhao
2067ec5967 Nullability check for time module.
Bug: b/245972273
Test: adb shell
Change-Id: I61f69f48f3428ef1f544dd01e573ff078a9eab17
2023-05-16 00:17:36 +00:00
Elliott Hughes
a198c71752 Merge "printf unification: floating point." 2023-05-12 20:15:02 +00:00
Shreshta Manu
56dba096a2 Merge "Revert "Nullability check for inet module."" 2023-05-12 18:20:56 +00:00
Zijun Zhao
07a2b29dd6 Revert "Nullability check for inet module."
This reverts commit 53dbd78ae0.

Reason for revert: Break build https://android-build.googleplex.com/builds/submitted/10125312/test_suites_x86_64_coverage/latest/view/logs/build_error.log?legacy

Change-Id: Ifccf22768b916d85263abb89b2b4223ae2ce5d80
2023-05-12 18:18:29 +00:00
Zijun Zhao
50d729b228 Merge "Nullability check for inet module." 2023-05-12 17:17:48 +00:00
Zijun Zhao
8e5e8ee14b Merge "Nullability check for if module." 2023-05-12 17:17:23 +00:00
Elliott Hughes
531199c56c printf unification: floating point.
The only remaining differences between vfprintf.cpp and vfwprintf.cpp
after this are the wide/narrow conversions for %c, %m, and %s. I've used
"chars" and "bytes" for the named constants for the directions because
(a) I find -1 and 1 pretty confusing and (b) although "narrow" is the
obvious opposite of "wide", only Windows actually moved to wide
characters, so "narrow" (aka "multibyte", and probably "utf8") is the
default/normal case. Even though C confuses bytes and characters via its
`char` type, "bytes" versus "chars" seems like the appropriate
terminology (and it's what Java/Python use).

Also improve the swprintf tests assertion so failures are readable.

Test: treehugger
Change-Id: Ife8f70f65ec28d96058a7d68df353945524835d2
2023-05-11 16:51:13 -07:00
zijunzhao
53dbd78ae0 Nullability check for inet module.
Bugs: b/245972273
Test: adb shell
Change-Id: I51830ddbf5ceb7c02154bd335feb65ca1a230b66
2023-05-11 22:57:27 +00:00
zijunzhao
c741aea751 Nullability check for netdb module
Bugs: b/245972273
Test: adb shell
Change-Id: Id9b4338ca2f0fb64033c221f3bfb269ab930b79b
2023-05-11 21:31:42 +00:00
zijunzhao
87aae5309b Nullability check for if module.
Bugs: b/245972273
Test: adb shell
Change-Id: If6be7027e0ebdcf68ae4062c57e1c4e82a767abe
2023-05-11 17:15:57 +00:00
Mao Han
d4e662edab riscv64: fix return value when errorno is 4095
This issue was discovered by seccomp_seccomp_bpf_riscv_64 test.
Actual output:
[0]code=20 jt=00 jf=00 k=0000
[1]code=15 jt=00 jf=01 k=003F
[2]code=06 jt=00 jf=00 k=51000
[3]code=06 jt=00 jf=00 k=7FFF0000
ret=-4095, errno=0

Expected output:
[o]code=20 jt=00 jf=00 k=0000
[1]code=15 jt=00 jf=01 k=003F
[2]code=06 jt=00 jf=00 k=51000
[3]code=06 jt=00 jf=00 k=7FFF0000
ret=-1, errno=4095

Change-Id: Ieebf5f0d1e2f18e2887c463b58ef7ea05ea52898
Signed-off-by: Mao Han <han_mao@linux.alibaba.com>
Signed-off-by: haocheng.zy <zhangye@linux.alibaba.com>
2023-05-11 14:52:56 +08:00
Christopher Ferris
983292a972 Merge "Update to v6.3 kernel headers." 2023-05-10 23:28:53 +00:00
Christopher Ferris
b7cef6d910 Update to v6.3 kernel headers.
Kernel headers coming from:

Git: https://android.googlesource.com/kernel/common/
Branch: android-mainline
Tag: android-mainline-6.3

Test: Bionic unit tests pass.
Change-Id: I5270ef291a77343e47ef3a5fbd02b8cacf218ec5
2023-05-09 19:04:15 +00:00
Elliott Hughes
26a0ebd24b More printf unification: FLUSH().
wprintf doesn't need this (and already only has the iov stuff because
the non-wide printf implementation needs it), but we can further reduce
the diff between the two implementations by defining a no-op FLUSH() for
wide characters.

Test: treehugger
Change-Id: Ifefcb4b8474b086f995e2b0796f61558a19e2a42
2023-05-09 11:54:09 -07:00
Treehugger Robot
68904aee7b Merge "Make fork equivalent to vfork when HWASan or MTE stack tagging is enabled." 2023-05-09 00:53:48 +00:00
Peter Collingbourne
b6a592b25b Make fork equivalent to vfork when HWASan or MTE stack tagging is enabled.
Bug: 274056091
Change-Id: Iac029ca6b0e26f57f20c0a54822b75e3cae67344
2023-05-08 15:26:00 -07:00
Zijun Zhao
aaaf468370 Merge "Nullability check for uio module." 2023-05-04 20:52:09 +00:00
Elliott Hughes
e023a02cce Merge "<time.h>: change the new C23 TIME_ constants." 2023-05-04 17:35:17 +00:00
zijunzhao
d633600d1c Nullability check for uio module.
Bugs: b/245972273
Test: adb shell
Change-Id: I132f618c50f7b7a3f9b9ef26c9ac1a87a97a1b78
2023-05-04 17:13:15 +00:00
Elliott Hughes
1dff230f75 Merge "syslog.h: implement LOG_PERROR." 2023-05-04 15:09:51 +00:00
Elliott Hughes
7db0a6cc5f <time.h>: change the new C23 TIME_ constants.
Jens Gustedt suggested a better implementation last year on the musl
mailing list: https://www.openwall.com/lists/musl/2022/11/19/1

It means the constants are sparse, but in return it means we can add
future constants and they'll be backward compatible. (Sadly you'll need
to be on API level 35 before you can use anything but TIME_UTC.)

I doubt this will ever matter, because everyone should just stick to
clock_gettime()/clock_getres() anyway, and anyone who does have a
legitimate use for timespec_get() and timespec_getres() probably needs
to support non-Linux and so can't use any clocks that aren't in ISO C
anyway. But given that we don't _have_ to paint ourselves into a corner
here, we may as well take the opportunity to not do so.

Test: strace
Change-Id: I293d32fcbcf7f6703564dac0978ae2a10192a482
2023-05-03 15:37:46 -07:00
Elliott Hughes
9118450303 Merge "Add an enum for the riscv64 <sys/ucontext.h> register constants." 2023-05-03 21:43:24 +00:00
Elliott Hughes
213d943a33 syslog.h: implement LOG_PERROR.
This is the one openlog() flag that toybox uses. We should probably try
to unify toybox's POSIX logger and Android-specific log at some point,
and this will help.

Also fix our behavior with an empty format string, noticed while adding
tests.

Test: treehugger
Test: adb shell logger -s foo
Change-Id: Ic027e78a460be3db83cc4c6f9946c9efa22be6e1
2023-05-03 14:19:40 -07:00
Elliott Hughes
7fc63f2c9a Add an enum for the riscv64 <sys/ucontext.h> register constants.
That lets us have idempotent #defines to reduce namespace pollution.

Bug: http://b/279405445
Test: treehugger
Change-Id: I00312cc8911025696cf0eea2d70e3219ab361613
2023-05-03 17:45:41 +00:00
Treehugger Robot
e61cf18c3c Merge "Nullability check for get_device_api_level_inlines module." 2023-05-03 02:06:08 +00:00
zijunzhao
136e28fa8b Nullability check for get_device_api_level_inlines module.
Bugs: b/245972273
Test: adb shell
Change-Id: I49d64a12b542c8f3723f89531c63d10b84d16d26
2023-05-02 23:36:34 +00:00
zijunzhao
1fdece95d3 Implement C23 printf 'wf' length modifiers
wfN: Specifies that a following b, d, i, o, u, x, or X conversion specifier applies to a fastest minimum-width integer argument with a specific width where N is a positive decimal integer with no leading zeros (the argument will have been promoted according to the integer promotions, but its value shall be converted to the unpromoted type); or that a following n conversion specifier applies to a pointer to a fastest minimum-width integer type argument with a width of N bits. All fastest minimum-width integer types (7.22.1.3) defined in the header <stdint.h> shall be supported. Other supported values of N are implementation-defined.

Bug: b/271903607
Test: adb shell
Change-Id: Ida36d5a50af2a46fd04cb5fe039793d8872f9f3b
2023-05-02 21:06:09 +00:00
Elliott Hughes
721b93d7ec Merge "Fix the WIFSTOPPED definition." 2023-05-02 14:40:15 +00:00
Elliott Hughes
2b8ca55d14 Fix the WIFSTOPPED definition.
Although this breaks job control in several shells (including mksh),
this has been broken since the initial commit and no-one's noticed until
now.

Bug: https://github.com/android/ndk/issues/1878
Test: treehugger
Change-Id: Id7c4805965c5e5847db99b57df1af13355adcc22
2023-05-01 19:48:12 +00:00
zijunzhao
d3f2f109fc Nullability check for getopt module.
Bugs: b/245972273
Test: adb shell
Change-Id: I243bb87fe26beecd376d894b25cedd993c246880
2023-05-01 16:19:44 +00:00
zijunzhao
a23e448288 Nullability check for resource module.
Bugs: b/245972273
Test: adb shell
Change-Id: Ia875f9e0189f72317276cc28bfe6faf1f95c2908
2023-04-28 22:18:02 +00:00
Treehugger Robot
3ee441491a Merge "Nullability check for ctype_inlines module." 2023-04-28 20:57:27 +00:00
Almaz Mingaleev
8cad3f9776 Merge "Update tzcode from 2022a to 2023a." 2023-04-28 18:41:33 +00:00
zijunzhao
b4e4d05439 Nullability check for ctype_inlines module.
Bugs: b/245972273
Test: adb shell
Change-Id: I7645c51d40a226cc90bfbf8587e8b094c0c38242
2023-04-28 18:02:12 +00:00
Almaz Mingaleev
d86a3ab241 Update tzcode from 2022a to 2023a.
57b8fc957a
changes the way overflows are tracked: now compiler builtins
are used instead of manual arithmetics. But as int_fast32_t on
64-bit Android takes 8 bytes, new logic behaves differently.
See time_test.cpp changes for more details.

Changes were applied using following commands:
  1) Checkout tzcode repo
  2) Prepare patches for all tzcode file using
    git diff 2022a 2023a -- <file-name> > <file-name-patch>
  3) Apply these patches to files in bionic using
    patch -p1 <file-name> <file-name-patch>

Bug: 279742606
Test: CtsBionicTestCases
Test: CtsLibcoreTestCases
Test: CtsLibcoreOjTestCases
Test: atest toybox-tests
Change-Id: I7772a90538b8185bdd2f4be6e9d1740c95509d6c
2023-04-28 16:52:53 +01:00
Christopher Ferris
e28867ca6e Modify the wording of the mallopt.
The original wording implies that memory tagging can be disabled
per thread. That is not really possible, and doesn't happen. Instead,
this option only turns off some of the memory tagging initialization.
Leave this slightly vague since it's possible this might change
in the future.

Bug: 272383932

Test: NA
Change-Id: I6333f16175edb52a38aadfc67ce7c9ce76113e59
2023-04-27 17:07:17 -07:00
Treehugger Robot
028bb5473b Merge "Nullability check for strcasecmp module." 2023-04-27 21:20:09 +00:00
zijunzhao
88f4b1a957 Nullability check for strcasecmp module.
Bugs: b/245972273
Test: adb shell
Change-Id: Ic6322e957cccd827fe437a4a3dd2848036913f29
2023-04-27 18:03:38 +00:00
zijunzhao
628d8ca6eb Nullability check for swab module.
Bugs: b/245972273
Test: adb shell
Change-Id: I92ce194ac12cbc337932357567b8450c484f93f3
2023-04-27 18:01:33 +00:00
Elliott Hughes
0593e7922f Merge "C23: add timespec_getres() and the new TIME_* constants." 2023-04-27 15:25:06 +00:00
Treehugger Robot
c35f7d6a84 Merge "Set __BIONIC_COMPLICATED_NULLNESS for the vsnprintf family" 2023-04-27 01:50:38 +00:00
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
52541eea33 C23: add timespec_getres() and the new TIME_* constants.
Nothing to see here --- you'll want to keep using POSIX clock_gettime()
and clock_getres() instead. But portable code might use this eventually,
and it's trivial, so let's add it anyway.

(The whole "zero as an error return" precluding the direct use of
Linux's CLOCK_ constants is what really makes this a terrible API ---
we're going to have to add explicit translation any time they add a
new base.)

Test: treehugger
Change-Id: Iddb6cbe67b67b2b10fdd8b5ee654896d23deee47
2023-04-25 17:29:22 -07:00
Treehugger Robot
4d1405e509 Merge "Nullability check for modules in the netinet directory." 2023-04-25 22:35:44 +00:00
zijunzhao
577177a326 Nullability check for modules in the netinet directory.
Bugs: b/245972273
Test: adb shell
Change-Id: Ia133f55c3e93ae00b605298365f1c00396bcfba7
2023-04-25 20:10:14 +00:00
Elliott Hughes
873c1ca3cb Add SYS_riscv_flush_icache.
Fix the uapi import script to look at the riscv/asm/ directory too, and
re-run it to add the missing SYS_riscv_* entry (there's only this one)
to glibc-syscalls.h.

Test: treehugger
Change-Id: Ie52c6ca1943c05bb615932174e49e7fb79725a7b
2023-04-25 12:13:56 -07:00
Treehugger Robot
d3733e1edd Merge "riscv64: fix the name of Zisslpcfi." 2023-04-22 01:19:29 +00:00
Elliott Hughes
7663578d73 riscv64: fix the name of Zisslpcfi.
Love these risc-v extension names!

Test: N/A
Change-Id: Ieb13f82a507aa11d79650b2cf627e68f213d6a79
2023-04-21 15:32:46 -07: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
zijunzhao
21e1f2d324 Nullability check for statvfs module.
Bugs: b/245972273
Test: adb shell
Change-Id: I7e28a869e4dd66a05182abe71ff121da7cfc7283
2023-04-21 00:06:14 +00: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
e2abfb3ddf Merge "Nullability check for select module." 2023-04-20 17:33:46 +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
zijunzhao
271abebf58 Nullability check for select module.
Bugs: b/245972273
Test: adb shell
Change-Id: If847c46df7f1666e4d0d530b196ee3e2be6f0cb8
2023-04-20 01:19:03 +00:00
Elliott Hughes
17b2bae190 Merge "Make tmpfile() respect $TMPDIR." 2023-04-19 20:01:51 +00:00
Spandan Das
a43de5cbfe Revert "Add versions property to libc_hwasan stubs"
This reverts commit fe2907c133.

Reason for revert: Breaks bionic-unit-tests b/278795547. Since the original mixed build change is being reverted for now (aosp/2547450), fe2907c133 is not needed immediately

Change-Id: I2deb06a38322bf8296d4721c840f06f35b757177
2023-04-19 17:06:24 +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
Spandan Das
fe2907c133 Add versions property to libc_hwasan stubs
bp2build will generate the stub targets only if versions is not empty.

Test: b query //bionic/libc:* | grep libc_hwasan_stub_libs-current

Change-Id: Iac905497ae4955a44b7b29e2d29a2c702c86da8e
2023-04-18 16:38:46 +00:00
Zijun Zhao
7b90c81b7c Merge "Nullability check for mount module." 2023-04-17 18:41:24 +00:00
Zijun Zhao
8d3ae82c52 Merge "Nullability check for inotify module." 2023-04-17 18:25:05 +00:00
Treehugger Robot
e1df179f00 Merge "Nullability check for wait module." 2023-04-17 18:13:09 +00:00
Treehugger Robot
a1ff2e6159 Merge "Nullability check for msg module." 2023-04-17 18:09:10 +00:00
zijunzhao
fa1936bd0b Nullability check for wait module.
Bugs: b/245972273
Test: adb shell
Change-Id: I407cc592522fc8feda1916d72525d147c9c58711
2023-04-15 01:17:54 +00:00
zijunzhao
ccc9d8dbf4 Nullability check for mount module.
Bugs: b/245972273
Test: adb shell
Change-Id: I86ccf6c68f8376e47cb59f05c737d4bbef58ef86
2023-04-15 01:16:51 +00:00
zijunzhao
f4141fbcfa Nullability check for inotify module.
Bugs: b/245972273
Test: adb shell
Change-Id: I213035a8a3cf1fada0092f97c42723739d49db61
2023-04-15 01:15:31 +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
ff116eda61 Fix build error on darwin_arm64
Change-Id: Ie5bc9252de8349c3bfb8269919c0a173a9d9cc2d
2023-04-14 17:50:59 -07:00
Florian Mayer
4967017c86 Merge "Introduce hwasan mode for linker" 2023-04-14 23:27:56 +00:00
Treehugger Robot
fb63e485f1 Merge "Nullability check for capability module." 2023-04-14 21:35:58 +00:00
Treehugger Robot
3d59f2838a Merge "Nullability check for ipc module." 2023-04-14 18:29:59 +00:00
Treehugger Robot
ec50cc6f34 Merge "Nullability check for sendfile module." 2023-04-14 15:19:41 +00: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
e14f2f9f20 Nullability check for sendfile module.
Bugs: b/245972273
Test: adb shell
Change-Id: I47d116b1faf7d53ac51589e393a3df96874a4f37
2023-04-14 01:07:12 +00:00
zijunzhao
7f5c789f35 Nullability check for ipc module.
Bugs: b/245972273
Test: adb shell
Change-Id: Idb89b878e415a62399890dcd3b40e54c3e9c9ef6
2023-04-14 01:05:54 +00:00
zijunzhao
181c31653e Nullability check for capability module.
Bugs: b/245972273
Test: adb shell
Change-Id: I9df50d82e7b86576912ed42e93b1e98c6ded6551
2023-04-14 01:04:29 +00: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
Treehugger Robot
be39cd5ebb Merge "Nullability check for modules in include/android directory" 2023-04-13 18:37:42 +00:00
Elliott Hughes
4aa40a5f77 Merge "riscv64: switch from x18 to gp for shadow call stack." 2023-04-13 14:33:06 +00:00
Elliott Hughes
989c15197a Merge "setjmp.h: add some historical detail about the _JBLEN values." 2023-04-13 14:05:02 +00:00
zijunzhao
ac6d59cc75 Nullability check for modules in include/android directory
Bugs: b/245972273
Test: adb shell
Change-Id: Ic00d207331d9837a01cf96ec7fe623961e653051
2023-04-12 23:26:46 +00:00
Elliott Hughes
7dd3896fe1 riscv64: switch from x18 to gp for shadow call stack.
We want to give back a useful callee-saved general purpose
register (x18) that was only "chosen" because it was what llvm
allowed for historical reasons. gp is a better choice because it's
effectively unused otherwise anyway.

Unfortunately, that means we need extra space in jmp_buf (which I've
reserved in an earlier change, e7b3b8b467),
so let's rearrange the entries in jmp_buf to match their order in the
register file.

Bug: https://github.com/google/android-riscv64/issues/72
Bug: http://b/277909695
Test: treehugger
Change-Id: Ia629409a894c1a83d2052885702bbdd895c758e1
2023-04-12 14:19:38 -07:00
Elliott Hughes
634186b505 setjmp.h: add some historical detail about the _JBLEN values.
Test: treehugger
Change-Id: Iadc16347be9bb186d9e7ada1e6f44bd2c36b04f2
2023-04-12 12:43:10 -07: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
Treehugger Robot
97950cb186 Merge "Rename files/modules that have the same name" 2023-04-12 01:12:14 +00:00
Cole Faust
f5968d82f5 Rename files/modules that have the same name
Bazel doesn't like it when modules produce files with the same name
as the module itself, and gives warnings.

Rename either the module or file in this case so that the file has
an extension and the module doesn't.

Bug: 198619163
Test: m nothing
Change-Id: Ic4592b06f575496ffd54ac75cb4d682118b29d93
2023-04-11 15:20:19 -07:00
Treehugger Robot
4473a937df Merge "Revert "Workaround boot loop by turning off stack protector check for noreturn calls"" 2023-04-11 15:04:46 +00:00
Yi Kong
66c09671fa Revert "Workaround boot loop by turning off stack protector check for noreturn calls"
This reverts commit 9b4cf9733f.

Fixed by https://reviews.llvm.org/D147975.

Change-Id: I2de39359783d739fd7f9da410fd78421638dbd70
2023-04-11 06:56:31 +00:00
Treehugger Robot
ac599ac89e Merge "Exclude crtbrand.o from the NDK sysroot." 2023-04-11 01:00:04 +00:00
Elliott Hughes
66542d6b97 Merge "setjmp.h: increase riscv64 jmp_buf size." 2023-04-07 15:39:34 +00:00
Treehugger Robot
b6ad73993d Merge "Nullability check for pthread module" 2023-04-07 09:26:55 +00:00
zijunzhao
3c9b94811f Nullability check for pthread module
Bugs: b/245972273
Test: adb shell
Change-Id: I35da1d15c63aae0049091538c573305bf4d9f813
2023-04-06 22:39:52 +00:00
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
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
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
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
Elliott Hughes
61d435c29a Merge "riscv64: typedef struct ucontext {...} ucontext_t." 2023-04-03 15:23:31 +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
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
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
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
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
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
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
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
Florian Mayer
b4f4f4ecea Merge "Add debug logging for memtag level" 2023-03-21 20:37:00 +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
Florian Mayer
b3f3e86878 Add debug logging for memtag level
Test: adb logcat 'libc:D' | grep memtag
Bug: 272596642
Change-Id: I764a0ea4fd71b547d1c5b82a1537e50016578e0f
2023-03-21 11:10:43 -07:00
caowencheng
9a39eb3469 Increase the implementation of __memcpy_chk assembly
Use __memcpy_chk assembly to replace the implementation of c functions, which can reduce the use of instructions

Test: llvm-objdump

Change-Id: I5d75601626dc997626f6173d53af301183a64004
Signed-off-by: caowencheng <caowencheng@eswincomputing.com>
2023-03-21 02:05:14 +00:00
Mitch Phillips
008dc0d50b Merge "No-op DT_AARCH64_MEMTAG_* entries" 2023-03-20 22:06:40 +00:00
Elliott Hughes
7559e5b051 Merge "Use <bits/timespec.h> from uapi headers too." 2023-03-20 19:46:57 +00:00
Elliott Hughes
875d40559e Use <bits/timespec.h> from uapi headers too.
Bug: https://github.com/android/ndk/issues/1852
Test: treehugger
Change-Id: I554b31d2c4c443d37506e97a36099efbd3ad0e11
2023-03-20 15:07:16 +00:00
Zijun Zhao
8ed5cace7d Merge "Nullability check for link module" 2023-03-17 23:51:54 +00:00
Mitch Phillips
2e25c0f943 No-op DT_AARCH64_MEMTAG_* entries
As of https://reviews.llvm.org/D143769, binaries (with -fsanitize=memtag-*)
have DT_AARCH64_MEMTAG_* dynamic entries, as per the AArch64 MemtagABI.
Android uses an OS-specific ELF note for MTE config, but we should
migrate to the new thing (while preserving backwards compatibility).

Without actually doing the migration right now, just handle these new
entries. Otherwise, you get a whole bunch of logspam about the
unrecognised dynamic entries.

Bug: 274032544
Test: Build android, don't get logspam.
Change-Id: I5c8b59f77a0058e5b93335e269d558a5014f2260
2023-03-17 16:09:39 -07:00
Christopher Ferris
dcd1403818 Merge "Add support for M_PURGE_ALL." 2023-03-17 21:06:20 +00:00
Zijun Zhao
df92729c64 Merge "Nullability check for pwd module" 2023-03-17 20:43:32 +00:00
zijunzhao
5250d79abc Nullability check for pwd module
Bugs: b/245972273
Test: adb shell
Change-Id: I855a4e6401220e2b84f303420e8fca63bcf47e03
2023-03-17 02:53:37 +00:00
zijunzhao
0a515826af Nullability check for link module
Bugs: b/245972273
Test: adb shell
Change-Id: I850deb5422604731d1d1b4ab3ea86aedad52a883
2023-03-17 02:52:15 +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
Treehugger Robot
8270ec9282 Merge "Fix stack use-after-scope in async_safe_log." 2023-03-16 00:43:01 +00:00
Peter Collingbourne
84979776d0 Fix stack use-after-scope in async_safe_log.
The buffer filled in by strerror_r needs to stay in scope while
it is pointed to by str.

Bug: 273807460
Change-Id: I494ca8b8aca2b28ec2f0f3da72d845db99633553
2023-03-15 15:21:58 -07: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
f6f8315747 Merge "Nullability check for getopt module" 2023-03-13 18:04:20 +00:00
zijunzhao
1581f63e6d Nullability check for getopt module
Bugs: b/245972273
Test: adb shell
Change-Id: I01cab7eacee486348fd90bd2a0d34c41873c017a
2023-03-13 18:03:29 +00:00
Zijun Zhao
e718f8b912 Merge "Nullability check for mntent module" 2023-03-13 18:02:39 +00:00
Treehugger Robot
0a9fd0e77e Merge "Nullability check for signalfd module" 2023-03-13 17:38:38 +00:00
Yi Kong
9b4cf9733f Workaround boot loop by turning off stack protector check for noreturn calls
clang-r487747 added stack protector capability to check noreturn calls.
This caused the system to boot loop. Turn off the new capabilities as a
temporary workaround.

Test: build and boot
Change-Id: I62c912619dfdd2384672d504ce5d52330bf2a102
2023-03-12 19:45:55 +09:00
zijunzhao
424cb2cbfd Nullability check for mntent module
Bugs: b/245972273
Test: adb shell
Change-Id: I8cbf1960c162c1def670b016663fbf10c2f8cb93
2023-03-11 01:52:28 +00:00
zijunzhao
98f116b319 Nullability check for signalfd module
Bugs: b/245972273
Test: adb shell
Change-Id: I47efddc9c0e217fcb29b3f4f1e2d30f27b23c05f
2023-03-11 01:51:02 +00:00
Treehugger Robot
1cccc1a059 Merge "Nullability check for resolv module" 2023-03-11 01:26:13 +00:00
zijunzhao
e589574d22 Nullability check for thread module
Bugs: b/245972273
Test: adb shell
Change-Id: Id93d0456e063adf0d41483a1f99f66c2d67bd4df
2023-03-10 20:37:27 +00:00
zijunzhao
16c23883bd Nullability check for resolv module
Bugs: b/245972273
Test: adb shell
Change-Id: I3ee948b3c832ece1969453d499e6f5de5d0bd85e
2023-03-10 01:40:04 +00:00
Elliott Hughes
d2e55dd05b Merge "The syscall call uses the 'tail' instruction call" 2023-03-09 22:03:42 +00:00
caowencheng
c42c74138c The syscall call uses the 'tail' instruction call
If the 'j' command is used here,it cannot always be called.
The 'tail' command is used here, let the compiler decide
which instruction to use,when the call distance is less
than 1M, it will be compiled into 'j' command, and when
the distance is greater than 1M, it will be compiled
into 'aupic' and 'jr' command.

Test: llvm-objdump -d
Change-Id: I53d8aa7f54b9c4c96fce491487dcba7b63348219
Signed-off-by: caowencheng <caowencheng@eswincomputing.com>
2023-03-09 07:44:03 +00:00
Zijun Zhao
7f8133dc2f Merge "Nullability check for pidfd module" 2023-03-09 00:06:12 +00:00
Zijun Zhao
85fc6b141e Merge "Nullability check for utsname module" 2023-03-08 23:47:42 +00:00
Zijun Zhao
5bfbc5330f Merge "Nullability check for assert module" 2023-03-08 23:47:30 +00:00
Elliott Hughes
6cb7db2b03 Merge "riscv64: use tail for tail calls." 2023-03-08 21:13:37 +00:00