Commit graph

3145 commits

Author SHA1 Message Date
zijunzhao
5a918d922b Nullability check for stdlib module.
Bugs: b/245972273
Test: None

Change-Id: Ib33a5359a924c21888f268158c4d7f824740dd55
2022-12-02 21:00:02 +00:00
Florian Mayer
7c2ce66b52 Merge "[MTE] test for exception cleanup." 2022-12-02 00:54:32 +00:00
Elliott Hughes
dfe67d266c Tell people when they've messed up with fcntl(FD_SETFD).
This is a subtle bug that even experts struggle with.

Test: treehugger
Change-Id: If9cf16a1c32c836f5688bb3374cfd21d55125b17
2022-11-30 20:19:22 +00:00
Elliott Hughes
ec9f023f41 Add invalid riscv64 ELF files for the linker tests.
The libtest_empty.so was built by the "libtest_empty" build rule, and
the other files are copies of that with small edits made by the toybox
hexedit tool. I worked out what to edit in each case from a combination
of "what does the name imply?" and "what does a diff of the xxd output
of the corresponding two arm64 files show?".

I failed to produce a working (by which I mean "failing") local-tls
file despite my best efforts. I'm not sure what exactly it was about the
gold-generated files we didn't like, because the commentary implies that
this would be problematic:

    39: 0000000000000004     4 TLS     LOCAL  DEFAULT   12 tls_var_2

But it loads without complaint.

Test: ran locally
Change-Id: I3b9b2b4db1f8827243541cf13380c6ceb840f123
2022-11-16 00:52:26 +00:00
Elliott Hughes
73840b56b2 Merge "Update sys_ptrace_test.cpp for riscv64." 2022-11-15 17:22:35 +00:00
Elliott Hughes
89719df107 Update sys_ptrace_test.cpp for riscv64.
We'll want to come back to this once either Zcmp's push/pop instructions
or V's vector loads/stores are available. But for now, we have no >64b
stores.

But at least this builds.

Test: treehugger
Change-Id: I9503e890cacb198f4ba987bfc92f6eff21c290b0
2022-11-12 00:08:17 +00:00
Elliott Hughes
fc03503f67 Update a comment to be more intention-revealing.
And also inclusive of riscv64.

Test: treehugger
Change-Id: I27280e1d934ce3bb47026820b75850c824801022
2022-11-11 22:52:04 +00:00
dimitry
2cc2910e70 Disable MemtagNoteTest#SEGV for native bridge
This commit disables MemtagNoteTest#SEGV when running
on native bridge.

Bug: http://b/242170715
Test: run arm64 Bionic tests on T Emulator
Change-Id: I8ae99c5ba22f09a8d7e751f8bb4938894abe231f
2022-11-08 05:50:07 +00:00
Florian Mayer
f5f4112b07 [MTE] test for exception cleanup.
This depends on the LLVM change https://reviews.llvm.org/D135639.

Test: adb shell /data/local/tmp/stack_tagging_helper exception_cleanup
Bug: 174878242
Change-Id: Ia1dfdbe482b40c174acaf6c1ac4ad054470d10b8
2022-11-07 18:17:44 -08:00
Orion Hodson
974b15e0ab Merge "Fix-up for change in pwd/grp ids for PRNG seeder daemon" into android13-tests-dev am: d06e75b7e3
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2273426

Change-Id: I4d17c2c68d9661530371c53d109410397edbe7c5
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-10-31 07:54:37 +00:00
Orion Hodson
f5fd5adf04 Fix-up for change in pwd/grp ids for PRNG seeder daemon
The PRNG seeder daemon is introduced in TM-QPR2 which can lead to
breakage running Android 13 CTS tests depending on when the platform
and CTS tests are built.

Fix: 253185870
Test: run cts --module CtsBionicTestCases
Change-Id: I94fa0aa2f32b09222aee08891e7643bf14d1a204
2022-10-27 11:21:29 +01:00
Treehugger Robot
4b0e16bc72 Merge "Fix stdio -NaN tests for riscv64." 2022-10-26 02:17:22 +00:00
Elliott Hughes
e0a9a3836c Fix stdio -NaN tests for riscv64.
riscv64 hates nans. From the spec: "Except when otherwise stated, if the
result of a floating-point operation is NaN, it is the canonical NaN.
The canonical NaN has a positive sign and all significand bits clear
except the MSB, a.k.a. the quiet bit."

This broke our tests here because the float-to-double instruction isn't
one of the "otherwise stated" cases, so it turns -nanf() into +nan().
The sign manipulation instructions are "otherwise stated" cases, though,
so as long as we avoid a conversion we're fine. And we didn't actually
_need_ a float here (pretty much by definition, since varargs means you
always end up with a double anyway), so we can just simplify things and
switch to using doubles directly to fix the tests.

Test: bionic-unit-tests-static
Change-Id: I13aa452dd6cc8708275f7676b37fc772b37a7b32
2022-10-25 22:56:43 +00:00
Elliott Hughes
4ceb3474be Add riscv64 lrint.S.
This is mainly just to match what we have for arm64.

The test failures before and after this change are all for the long
double variant, which this change doesn't touch. (The problem there is
that clang is calling `__fixtfdi` for the cast in lrintl(), but that
doesn't respect the current rounding mode, which lrintl() is required
to do. `#pragma STDC FENV_ACCESS ON` doesn't fix this, so there's going
to be some llvm work needed to fix this.)

I've replaced the ASSERTs with EXPECTs in the relevant test to ensure
we're checking all the other assertions despite the `long double`
failures.

Test: bionic-unit-tests-static
Change-Id: Ia24bf21619631b6f8b3b607d30536011bb4cd826
2022-10-25 22:27:10 +00:00
Treehugger Robot
b9af0678e1 Merge "Fix bionic tests for undefined __SIGRTMIN in musl" 2022-10-20 23:12:21 +00:00
Colin Cross
23b986c0c8 Fix bionic tests for undefined __SIGRTMIN in musl
Musl doesn't export __SIGRTMIN, and it is being removed from the
Android wrappers to avoid accidentally referencing bionic's
reserved signals when compiling against musl.

Bug: 190084016
Test: m USE_HOST_MUSL=true host-native -k
Change-Id: I342666a17abc31bbc57b383b5cc881c2752886f7
2022-10-20 13:16:21 -07:00
Treehugger Robot
f2be65d0f7 Merge "Remove explicit lists of ABIs." 2022-10-19 18:08:17 +00:00
Elliott Hughes
3f73ea6547 Remove explicit lists of ABIs.
Rather than add riscv64 to these lists, let's just outsource to libbase.

Test: treehugger
Change-Id: Ifd0f19564b9bca4544ef60c05eda9591fd8958dd
2022-10-19 16:20:02 +00:00
Elliott Hughes
017bd9882a riscv64: fix <fenv.h> tests.
Group riscv64 with arm/arm64, and allow for the fact that there's no
FE_DENORMAL in the riscv64 spec.

Test: fenv.*
Change-Id: Ibf188bcedffd092a7ef1555fa2762e249e1f9845
2022-10-18 23:47:28 +00:00
Elliott Hughes
e1905ed629 riscv64 setjmp.
Signed-off-by: Mao Han <han_mao@linux.alibaba.com>
Signed-off-by: Xia Lifang <lifang_xia@linux.alibaba.com>
Signed-off-by: Chen Guoyin <chenguoyin.cgy@linux.alibaba.com>
Signed-off-by: Wang Chen <wangchen20@iscas.ac.cn>
Signed-off-by: Lu Xufan <luxufan@iscas.ac.cn>
Test: m
Change-Id: I02cf117f67bda74516e4de8cd6f4c05efdb9a85b
2022-10-17 23:23:36 +00:00
Elliott Hughes
d25a5e73f8 Add an explicit test that fegetenv()/fesetenv() includes the rounding mode.
I haven't found this explicitly stated anywhere, but it's how our
existing implementations behave, and it seems obviously implied by
the word "entire" in POSIX's claim that fenv_t "Represents the entire
floating-point environment".

Test: treehugger
Change-Id: Ic8fc993775b4ded57dc88766a7d24d0954f3b56d
2022-10-14 20:55:23 +00:00
Elliott Hughes
5cc8a46419 riscv64's struct stat is the same as arm64's.
(And all other new architectures.)

Signed-off-by: Mao Han <han_mao@linux.alibaba.com>
Signed-off-by: Xia Lifang <lifang_xia@linux.alibaba.com>
Signed-off-by: Chen Guoyin <chenguoyin.cgy@linux.alibaba.com>
Signed-off-by: Wang Chen <wangchen20@iscas.ac.cn>
Signed-off-by: Lu Xufan <luxufan@iscas.ac.cn>
Test: treehugger
Change-Id: Iceb2dd16c738302624980179788c4a2e68b797ed
2022-10-06 00:26:18 +00:00
Automerger Merge Worker
4b13827fe4 Merge "Merge "stack_protector_DeathTest#modify_stack_protector: avoid flake." into android12-tests-dev am: 793d1fb5ab" into android12L-tests-dev am: 6aa3bdfb16
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2240186

Change-Id: I479c56a6509cef84a1f614a937a6434ebce5dbcd
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-10-06 00:22:47 +00:00
Florian Mayer
e2a10da5be Merge "Do not strip bionic test helpers" 2022-10-04 16:13:59 +00:00
Elliott Hughes
b24c89b4df stack_protector_DeathTest#modify_stack_protector: avoid flake.
I've never been able to repro the flake myself (in hundreds of thousands
of runs), but it's certainly possible that a byte of the cookie is
already zero. So let's invert the byte we plan to corrupt rather than
set it to zero.

Bug: http://b/202948861
Test: treehugger
Change-Id: Iccd552fe302d6c01e376819d23c11a308e03acdb
(cherry picked from commit 23ce50c172)
2022-10-04 00:00:50 +00:00
Florian Mayer
37b4a152a4 Do not strip bionic test helpers
Change-Id: I651511cf11d38f8012ddf968dacae530e7a66d69
2022-10-03 23:35:22 +00:00
Florian Mayer
7819140c5a [MTE] use GTEST_SKIP on non-MTE hw for memtag_stack_test
Bug: 174878242
Change-Id: If980ac4d9bf4bada6e150a5f30c486bdd6de3508
2022-09-30 23:02:52 +00:00
Colin Cross
26532523c6 Cast sysinfo.uptime for musl
Upstream musl libc defines sysinfo.uptime as unsigned long, while the
kernel and glibc define it as long.  Cast it to long for the
comparision.

Bug: 190084016
Test: bionic-unit-tests-glibc
Change-Id: Ib322472d512a9a7474a936e33f35523e1dc995d9
2022-09-29 11:15:06 -07:00
Elliott Hughes
23ce50c172 stack_protector_DeathTest#modify_stack_protector: avoid flake.
I've never been able to repro the flake myself (in hundreds of thousands
of runs), but it's certainly possible that a byte of the cookie is
already zero. So let's invert the byte we plan to corrupt rather than
set it to zero.

Bug: http://b/202948861
Test: treehugger
Change-Id: Iccd552fe302d6c01e376819d23c11a308e03acdb
2022-09-27 22:37:03 +00:00
Elliott Hughes
82be76b5a2 Add __freadahead.
At the time I added <stdio_ext.h>, I just added what was on the man
page (which matched glibc), not realizing that musl and glibc had
slightly different functionality in their headers.

The toybox maintainer came up with a legitimate use case for this, for
which there is no portable workaround, so I'm adding it here. I'm not
adding the other functions that are in musl but not glibc for lack of a
motivating use case.

Bug: http://lists.landley.net/htdig.cgi/toybox-landley.net/2022-April/020864.html
Test: treehugger
Change-Id: I073baa86ff0271064d4e2f20a584d38787ead6b0
2022-09-22 23:47:42 +00:00
Florian Mayer
298bcecead Merge "Add android_mallopt to query MTE stack state" 2022-09-09 00:49:08 +00:00
Christopher Ferris
76da7bad0e Fix tests/NOTICE file.
Some previous change did not update the NOTICE file properly.

Test: Uploads.
Change-Id: I9d1797cbb7d0d0485e697e8038497f182e33446c
2022-09-08 21:54:29 +00:00
Florian Mayer
cc61ad895e Add android_mallopt to query MTE stack state
Bug: 244364391
Change-Id: Ie6267201f0c2e293b27c71cd160a2311c9de8091
2022-09-07 23:38:42 +00:00
Florian Mayer
44742701c9 Merge "Revert^2 "memtag_stack tests."" 2022-09-01 19:29:33 +00:00
Florian Mayer
c82d7fcd22 Revert^2 "memtag_stack tests."
8162b05ccd

Change-Id: I68c1988b0d76dddfaf69189cfd439192cabda00d
2022-08-31 20:57:03 +00:00
Florian Mayer
376e9b07ca Merge "Revert "memtag_stack tests."" 2022-08-31 18:37:29 +00:00
Florian Mayer
8162b05ccd Revert "memtag_stack tests."
Revert "[soong] Add memtag-stack sanitizer, switch to linker-gen..."

Revert submission 2096883-memtag-stack

Reason for revert: b/244454542
Reverted Changes:
I7fee03d90:memtag_stack tests.
I52d2318c8:[soong] Add memtag-stack sanitizer, switch to link...

Change-Id: I0dac2a6a6757a78c9f831cd7cc463b0e0f6376c6
2022-08-31 18:30:18 +00:00
Florian Mayer
5c6c043820 Merge "memtag_stack tests." 2022-08-31 17:53:43 +00:00
Evgenii Stepanov
d624d2f3d9 memtag_stack tests.
This tests cover stack tagging setup in response to NT_MEMTAG_STACK and
vfork and longjmp support.

Bug: b/174878242
Test: fvp_mini with ToT LLVM
  SANITIZE_TARGET="memtag_heap"
  SANITIZE_TARGET="memtag_heap,memtag_stack"

Change-Id: I7fee03d901092d9428d86a6fab6bef4e2e3b51eb
2022-08-30 18:00:21 +00:00
Xin Li
75f40e8dcb Merge android12L-tests-dev@8941410.
Change-Id: I5c71068d05f27bff99f1adc17400c0ec709b4dd0
2022-08-17 22:08:00 -07:00
Elliott Hughes
f9fac36f15 Merge "Add C23's memset_explicit()." 2022-08-11 22:01:28 +00:00
Elliott Hughes
d1c3d4a454 Merge "Add %b and %B support to the scanf/wscanf and strto*/wcsto* families." 2022-08-11 21:22:23 +00:00
Elliott Hughes
1f462dec34 Add %b and %B support to the scanf/wscanf and strto*/wcsto* families.
Coming to C23 via WG14 N2630.

This one is a little interesting, because it actually changes existing
behavior. Previously "0b101" would be parsed as "0", "b", "101" by these
functions. I'm led to believe that glibc plans to actually have separate
versions of these functions for C23 and pre-C23, so callers can have the
behavior they (implicitly) specify by virtue of which -std= they compile
with. Android has never really done anything like that, and I'm pretty
sure app developers have more than enough to worry about with API levels
without having to deal with the cartesian product of API level and C
standard.

Therefore, my plan A is "if you're running on Android >= U, you get C23
behavior". My plan B in the (I think unlikely) event that that actually
causes trouble for anyone is "if you're _targeting_ Android >= U, you
get C23 behavior". I don't think we'd actually want to have two versions
of each of these functions under any circumstances --- that seems by far
the most confusing option.

Test: treehugger
Change-Id: I0bbb30315d3fabd306905ad1484361f5d8745935
2022-08-11 00:25:08 +00:00
Elliott Hughes
0d64243407 Add C23's memset_explicit().
https://open-std.org/jtc1/sc22/wg14/www/docs/n2897.htm

Test: treehugger
Change-Id: Ia0cfc72bdf3c22eda6a4fc9adaa4c0ca0ff9a7c8
2022-08-10 23:36:16 +00:00
Elliott Hughes
462c542855 Merge "Don't even try to allocate 2GiB on LP32." 2022-08-03 15:35:49 +00:00
Florian Mayer
5d35ab8f42 [MTE] Add comment about nested ScopedDisableMTE in test.
Change-Id: I02a4b44ebe1fad6f00b10d1083b43b52a0b5c316
2022-08-02 23:52:43 +00:00
Elliott Hughes
0cac2919fd Don't even try to allocate 2GiB on LP32.
std::vector will just throw std::length_error anyway...

Bug: http://b/241114825
Test: treehugger
Change-Id: I44a9be9a5357c7b3a1c1d1273ef90a023a91e81b
2022-08-02 18:25:22 +00:00
Elliott Hughes
b813a6a6be Add %b and %B support to the printf/wprintf family.
Coming to C23 via WG14 N2630, and already in glibc.

We're still missing clang support for %b and %B in format string checking,
but it's probably easier to fix this first. (Apparently GCC already has
support because of glibc.)

Test: treehugger
Change-Id: Ie8bfe4630d00c50e1d047d6756a7f799205356db
2022-08-01 22:18:40 +00:00
Elliott Hughes
27b3ad2c78 Merge "Simplify the implementation of get_nproc()." 2022-07-29 18:19:29 +00:00
Elliott Hughes
6f4bb0771e Merge "fread: cope with >2GiB totals." 2022-07-29 16:16:27 +00:00