Commit graph

36251 commits

Author SHA1 Message Date
Elliott Hughes
900a9890e4 Mention O_CREAT and O_TMPFILE in both open(2) fortify messages.
Spotted while reading gbiv's forthcoming "how fortify works"
documentation.

Test: treehugger
Change-Id: I89827bc9afa8e445de8361e938075fabf73ac518
2022-06-06 23:50:34 +00:00
Treehugger Robot
4ebdeebef7 Merge "memtag_stack: vfork and longjmp support." 2022-05-27 23:12:43 +00:00
Treehugger Robot
6cfefe5842 Merge "Revert "Update to v5.18 kernel headers."" 2022-05-27 22:40:37 +00:00
Greg Kaiser
55b5639cca Revert "Update to v5.18 kernel headers."
Revert "Update to v5.18 kernel headers."

Revert submission 2106847-kernel_update

Reason for revert: b/234125620
Reverted Changes:
I5844ca1fc:Update to v5.18 kernel headers.
I5700813ee:Update to v5.18 kernel headers.
Bug: 234125620

Change-Id: I07a39aa9c01939455b5a2a9da5fc04be497ca399
2022-05-27 20:41:14 +00:00
Evgenii Stepanov
3031a7e45e memtag_stack: vfork and longjmp support.
With memtag_stack, each function is responsible for cleaning up
allocation tags for its stack frame. Allocation tags for anything below
SP must match the address tag in SP.

Both vfork and longjmp implement non-local control transfer which
abandons part of the stack without proper cleanup. Update allocation
tags:
* For longjmp, we know both source and destination values of SP.
* For vfork, save the value of SP before exit() or exec*() - the only
  valid ways of ending the child process according to POSIX - and reset
  tags from there to SP-in-parent.

This is not 100% solid and can be confused by a number of hopefully
uncommon conditions:
* Segmented stacks.
* Longjmp from sigaltstack into the main stack.
* Some kind of userspace thread implementation using longjmp (that's UB,
  longjmp can only return to the caller on the current stack).
* and other strange things.

This change adds a sanity limit on the size of the tag cleanup. Also,
this logic is only activated in the binaries that carry the
NT_MEMTAG_STACK note (set by -fsanitize=memtag-stack) which is meant as
a debugging configuration, is not compatible with pre-armv9 CPUs, and
should not be set on production code.

Bug: b/174878242
Test: fvp_mini with ToT LLVM (more test in a separate change)

Change-Id: Ibef8b2fc5a6ce85c8e562dead1019964d9f6b80b
2022-05-27 13:19:34 -07:00
Treehugger Robot
39de8b944e Merge "Basic support for MTE stack tagging." 2022-05-27 02:15:53 +00:00
Evgenii Stepanov
f9fa32acf3 Basic support for MTE stack tagging.
Map all stacks (primary, thread, and sigaltstack) as PROT_MTE when the
binary requests it through the ELF note.

For the reference, the note is produced by the following toolchain changes:
https://reviews.llvm.org/D118948
https://reviews.llvm.org/D119384
https://reviews.llvm.org/D119381

Bug: b/174878242
Test: fvp_mini with ToT LLVM (more tests in a separate change)

Change-Id: I04a4e21c966e7309b47b1f549a2919958d93a872
2022-05-26 16:18:53 -07:00
Christopher Ferris
a92074cb01 Merge "Update to v5.18 kernel headers." 2022-05-26 00:42:21 +00:00
Christopher Ferris
5d3679612f Update to v5.18 kernel headers.
Kernel headers coming from:

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

Test: Builds.
Test: All bionic unit tests pass on a coral device.
Change-Id: I5700813eec0fb0db55bee4d75b129400b7a239bd
2022-05-25 14:30:25 -07:00
Colin Cross
98edc0c14e Merge "Disable close_range test for musl" 2022-05-24 15:08:13 +00:00
Colin Cross
1b8ebeab1c Disable close_range test for musl
Musl doesn't have close_range, skip the test.

Bug: 190084016
Test: m USE_HOST_MUSL=true host-native
Change-Id: I7ed485f2d0ec08358c856430b7c4c45fbe45a39f
2022-05-23 16:07:22 -07:00
Treehugger Robot
5c36810f5e Merge "Fix it to call the lambda function" 2022-05-23 22:03:02 +00:00
Christopher Ferris
08f98b6734 Merge "Add options to only backtrace specific sizes." 2022-05-19 16:32:29 +00:00
Suchang Woo
119765415a Fix it to call the lambda function
The lambda function is converted to bool instead of being called. So,
get_transparent_hugepages_supported() returns always true.

Test: check whether /sys/kernel/mm/transparent_hugepage/enabled is
accessed via strace.
Bug: http://b/233137490
Signed-off-by: Suchang Woo <suchang.woo@samsung.com>
Change-Id: I88b0d18d8ceb2300482043391eed4ae7041866ca
2022-05-19 02:13:39 +00:00
Christopher Ferris
a383648d3a Add options to only backtrace specific sizes.
Add backtrace_size for only backtracing a single size.
Add backtrace_min_size to set the minimum value of size to backtrace.
Add backtrace_max_size to set the maximum value of size to backtrace.

Documented the new options.

Test: New unit test pass.
Change-Id: I1a773737910cd4bc2af9546547b3a2740bbcb22b
2022-05-18 17:05:05 -07:00
Elliott Hughes
f2d59f93e6 Merge "Remove the KSM hack in mmap()." 2022-05-18 23:15:47 +00:00
Christopher Ferris
c7b31befbf Merge "Make the unit tests isolated." 2022-05-18 22:53:27 +00:00
Florian Mayer
fb42de4449 Merge "Remove unused function." 2022-05-18 18:09:40 +00:00
Automerger Merge Worker
f4b3e6c408 Merge "Merge "Merge "Merge "Merge "mntent_test: don't assume /proc isn't the first mount." into android10-tests-dev am: 0462cfb766" into android11-tests-dev am: 0a5cc21c42" into android12-tests-dev am: 46871c040d" into android12L-tests-dev am: e6fb091bba" 2022-05-18 01:29:27 +00:00
Automerger Merge Worker
57ce2d6520 Merge "Merge "Merge "Merge "mntent_test: don't assume /proc isn't the first mount." into android10-tests-dev am: 0462cfb766" into android11-tests-dev am: 0a5cc21c42" into android12-tests-dev am: 46871c040d" into android12L-tests-dev am: e6fb091bba
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2098734

Change-Id: I00dfbcd763718b10c473f4cf8fe41a6ac2dc99d5
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-05-18 01:29:24 +00:00
Automerger Merge Worker
e6fb091bba Merge "Merge "Merge "Merge "mntent_test: don't assume /proc isn't the first mount." into android10-tests-dev am: 0462cfb766" into android11-tests-dev am: 0a5cc21c42" into android12-tests-dev am: 46871c040d" into android12L-tests-dev 2022-05-18 01:11:09 +00:00
Automerger Merge Worker
c3a2e6b232 Merge "Merge "Merge "mntent_test: don't assume /proc isn't the first mount." into android10-tests-dev am: 0462cfb766" into android11-tests-dev am: 0a5cc21c42" into android12-tests-dev am: 46871c040d
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2098734

Change-Id: I10ed03dd6f920e19dc8c62c89217bf583dd21d96
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-05-18 01:11:07 +00:00
Automerger Merge Worker
46871c040d Merge "Merge "Merge "mntent_test: don't assume /proc isn't the first mount." into android10-tests-dev am: 0462cfb766" into android11-tests-dev am: 0a5cc21c42" into android12-tests-dev 2022-05-18 00:51:37 +00:00
Automerger Merge Worker
d285f43605 Merge "Merge "mntent_test: don't assume /proc isn't the first mount." into android10-tests-dev am: 0462cfb766" into android11-tests-dev am: 0a5cc21c42
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2098734

Change-Id: Ic585470d3f383c9dcbc6e989b46ec8d6ce17eefd
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-05-18 00:51:35 +00:00
Automerger Merge Worker
0a5cc21c42 Merge "Merge "mntent_test: don't assume /proc isn't the first mount." into android10-tests-dev am: 0462cfb766" into android11-tests-dev 2022-05-18 00:32:25 +00:00
Shubhangi Pawar
ab9bb66180 Merge "mntent_test: don't assume /proc isn't the first mount." into android10-tests-dev am: 0462cfb766
Original change: https://android-review.googlesource.com/c/platform/bionic/+/2098734

Change-Id: I92a208d548197b48fc35082b5e219895bf16a904
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-05-18 00:32:22 +00:00
Christopher Ferris
0d07dcc241 Make the unit tests isolated.
Modify the tests that require a single filename, to use a filename
that has the pid as part of the name. This allows multiple different
versions of the test to run on the same machine, and allows
each test to be run at the same time.

Test: Ran unit tests on device.
Test: Ran the unit tests 100 times, no failures.
Change-Id: Ia38483049e7b66bd3da824bcd484c03e46f85280
2022-05-17 17:25:38 -07:00
Shubhangi Pawar
0462cfb766 Merge "mntent_test: don't assume /proc isn't the first mount." into android10-tests-dev 2022-05-18 00:13:12 +00:00
Florian Mayer
e54a0525e7 Remove unused function.
Change-Id: Iac7b16278868e1d5d267eb9637de6dbcb6bdacfb
2022-05-17 22:54:09 +00:00
Elliott Hughes
b3b0eb6f0e Remove the KSM hack in mmap().
We've been telling people not to use KSM since 2018.

Bug: http://b/115637122
Test: treehugger
Change-Id: Iaa4e0e31e449a74700b6ed47881b9625556f0982
2022-05-17 12:38:38 -07:00
Christopher Ferris
6f54ff6ca1 Merge "Use new AndroidLocalUnwinder." 2022-05-17 17:35:15 +00:00
Christopher Ferris
dfbc59ae51 Use new AndroidLocalUnwinder.
The new object incorporates all Android specific knowledge into
a single place and makes everything simpler.

Fixed a bug where if backtrace_full was enabled, the AddBacktrace
function would always set the size to the maximum number
of frames instead of the actual number of frames.

Added a new smoke system tests for backtrace_full.

Modified the smoke test to do a malloc/free, so it's really
a smoke test.

Bug: 232575330

Test: Unit tests pass on device.
Test: Verify the full backtrace actually produces valid backtraces.
Test: Run bionic-unit-tests with backtrace_full enabled.
Test: Run bionic-benchmarks --benchmark_filter=stdlib_malloc_free_decay1/512
Change-Id: I23128a73a8691007e1c7f69e0c99bb4dcd713db8
2022-05-16 15:37:21 -07:00
Elliott Hughes
1727595b0e mntent_test: don't assume /proc isn't the first mount.
This test tried to be lazy and test both getmntent() and getmntent_r()
in the same test, but that led to an implicit assumption that /proc
isn't the first mount returned.

This new version is quite a bit more thorough than the old. It does
assume that the mount list doesn't change while the test is running, but
that seems like a reasonable assumption to make during CTS?

Bug: https://issuetracker.google.com/230228681
Test: treehugger
Change-Id: I5c5f0b86ae1c4df9a2ce69d48e1c3accb42c687b
(cherry picked from commit 1e393b0699)
2022-05-16 17:56:24 +00:00
Elliott Hughes
a2e4fbb366 Merge "mntent_test: don't assume /proc isn't the first mount." 2022-05-16 17:55:17 +00:00
Elliott Hughes
1e393b0699 mntent_test: don't assume /proc isn't the first mount.
This test tried to be lazy and test both getmntent() and getmntent_r()
in the same test, but that led to an implicit assumption that /proc
isn't the first mount returned.

This new version is quite a bit more thorough than the old. It does
assume that the mount list doesn't change while the test is running, but
that seems like a reasonable assumption to make during CTS?

Bug: https://issuetracker.google.com/230228681
Test: treehugger
Change-Id: I5c5f0b86ae1c4df9a2ce69d48e1c3accb42c687b
2022-05-13 16:06:54 -07:00
Zijun Zhao
3d425bb8fb Merge "Add copy_file_range(2) syscall stub to bionic." 2022-05-12 17:20:55 +00:00
zijunzhao
c2e412e086 Add copy_file_range(2) syscall stub to bionic.
Test: treehugger
Bug: https://buganizer.corp.google.com/issues/227784687
Change-Id: I543306cd2234189401bf7c9d80d405eeb6e4d41d
2022-05-12 16:53:41 +00:00
Christopher Ferris
bcd8f15e27 Merge "Add option to force memunreachable check." 2022-05-11 23:28:21 +00:00
Florian Mayer
55d286e98a Merge "Remove unnecessary static variable." 2022-05-11 01:22:19 +00:00
Christopher Ferris
b42e8b4dec Add option to force memunreachable check.
The new option is named check_unreachable_on_signal. It is meant
to duplicate dumpsys meminfo --unreachable <PID> for non-java
processes. When enabled, a user can send a signal to a process
which will trigger the unreachable check on the next allocation
call.

Added new unit tests.

Test: New unit tests pass.
Test: Enabled for the entire system, then dumped on the netd
Test: process and also system_server.
Change-Id: I73561b408a947a11ce21a211b065d59fcc39097b
2022-05-10 17:37:19 -07:00
Treehugger Robot
08bbabcc45 Merge "Improve the "how to add a system call" doc" 2022-05-11 00:20:54 +00:00
Alix Espino
6087a278e0 Merge changes I158862fd,Ieb9de996
* changes:
  Removing clang_cflags to check if they're even necessary
  Moved contents of clang_cflags into cflags
2022-05-10 22:17:26 +00:00
zijunzhao
e5e1e4e55a Improve the "how to add a system call" doc
Test: None
Bug: None
Change-Id: Ie4212956836ae057009e6985812efcbbb7859dea
2022-05-10 22:07:31 +00:00
Florian Mayer
3c0f0969b9 Remove unnecessary static variable.
Change-Id: I1e0049895fc493f5e8b728707a076d5ad022f8c1
2022-05-10 20:57:13 +00:00
Treehugger Robot
c66cb5ba6a Merge "add new Linux close_range() system call to bionic" 2022-05-06 22:25:26 +00:00
Maciej Żenczykowski
b65e105047 add new Linux close_range() system call to bionic
See:
  https://man7.org/linux/man-pages/man2/close_range.2.html

Note: 'man close_range' documents 'flags' as unsigned int,
while glibc unistd.h as just 'int'.  Picking 'int' to match glibc,
though it probably doesn't matter.

BYPASS_INCLUSIVE_LANGUAGE_REASON=man is a cli command
Test: TreeHugger
Bug: 229913920
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I1e2d1c8edc2ea28922d60f3ce3e534a784622cd1
2022-05-06 10:33:04 +00:00
Christopher Ferris
de9fe1e2de Merge "Mangle the pointers stored in PointerData." 2022-05-05 19:12:29 +00:00
Christopher Ferris
f78486f40e Mangle the pointers stored in PointerData.
The libmemunreachable library looks through memory to determine
if pointers are leaked. Unfortunately, the malloc debug code
stores the original pointer in data structures, so it looks like
pointers are still in use. The fix is to mangle the pointers
stored in memory so that it doesn't trick the library into thinking
they are live.

Test: All unit/system tests pass.
Test: Ran libmemunreachable and verified leaks show up.
Change-Id: Ic40a0a5ae73857cde936fd76895d88829686a643
2022-05-04 17:07:40 -07:00
Ryan Prichard
0e91012d42 Merge "legacy strtof inline: don't set errno for "inf"" 2022-05-04 22:47:08 +00:00
Elliott Hughes
082b9290d0 Merge "seccomp: allow stat() for ubsan." 2022-05-04 16:35:26 +00:00