Commit graph

629 commits

Author SHA1 Message Date
Christopher Ferris
0e69160ebc Remove include/backtrace symlink.
This requires a few other changes to support building libutils
properly. It does appear the windows versions of libutils is
referencing CallStack code, but it doesn't seem to cause any problems.
However, I removed those references completely for the windows build.

Also removed a few extra spaces that seem to have accumulated in the
RefBase.cpp.

Bug: 170465278

Test: Builds and libutils unit tests pass.
Change-Id: Ibeee7791b13636b34bdd592c5420fd91620f752a
2020-10-20 12:46:14 -07:00
Elliott Hughes
f2f016e741 Fix SharedBuffer tests to pass under hwasan.
Allocating the entire address space is sufficiently unreasonable that
hwasan blows you out of the water if you try to do that. Half the
address space feels like it's large enough to be guaranteed to fail
(which is all I think this intended to test) without being quite so
obviously incorrect that tools like hwasan are going to object...

...except hwasan actually has a 2GiB limit. So let's keep the cleanup,
but also just disable these tests if they're running under hwasan for
now.

Bug: https://issuetracker.google.com/171054277
Test: treehugger
Change-Id: I41f3def5c3a43aa7f9ca3a130b4306ebed659d6a
2020-10-19 16:51:58 -07:00
The Android Open Source Project
7fd5f8d2bc DO NOT MERGE - Merge RP1A.201005.006
Bug: 168212094
Change-Id: I79a7517bce1c012eac2a2a7c1c2cffc5a3516eaa
Merged-In: Ia85067d4258bde4b875c832d6223db5dd26b8838
2020-10-06 04:30:21 +00:00
Dylan Katz
50ed92a7e0 Adds license header
Missed a review point made, added the license header to FuzzFormatTypes
Test: Compiled code

Signed-off-by: Dylan Katz <dylan.katz@leviathansecurity.com>
Change-Id: Ib8f32b802ec207d0483772c38a0a741e0dd1f151
2020-10-02 11:08:15 -07:00
Steven Moreland
3e3e44c740 Merge "Fixes to String8 fuzzer" 2020-09-28 22:35:38 +00:00
Rick Yiu
fa02bb9952 Revert "Add choice for changing sched policy when setting thread priority"
This reverts commit 57affbf91d.

Reason for revert: new API is no longer used

Change-Id: I97128c1d367e161aa50deaefa8b73a0f25e29af4
2020-09-27 11:21:11 +08:00
Rick Yiu
290efe38b6 Revert "Fix API for C compatibility"
This reverts commit b473061c5a.

Reason for revert: new API is no longer used

Change-Id: I2c4f9f37736faeb5d0403c2ba531c792d2531505
2020-09-27 11:20:03 +08:00
Dylan Katz
98e14de057 Fixes to String8 fuzzer
Adds support for format fuzzing, fixes several bugs.
Fix: 163680603
Fix: 162926178
Fix: 157469647
Test: libutils_fuzz_string8 clusterfuzz-testcase-minimized-libutils_fuzz_string8-6188353572306944
Test: libutils_fuzz_string8 clusterfuzz-testcase-minimized-libutils_fuzz_string8-6413754773012480
Test: libutils_fuzz_string8 clusterfuzz-testcase-minimized-libutils_fuzz_string8-5691524777246720

Signed-off-by: Dylan Katz <dylan.katz@leviathansecurity.com>
Change-Id: I7107c3637a4befccab345e17171a1119f8677557
2020-09-25 16:28:49 -07:00
Dylan Katz
806b3d8619 Removed RWLock fuzzer
The class being fuzzed here was too simple for a fuzzer to be effective at finding crashes that were not working as intended.
To resolve the issue noted in 163775285 would require the fuzzer to simply use RWLock exactly as intended, defeating the point of fuzzing it.
Because of this, we have made the decision to remove this class. It should have a fairly small impact on coverage. In the future,
perhaps a better approach would be fuzzing pthread's rwlock methods directly.
Test: Made sure the project still builds without RWLock_fuzz.

Signed-off-by: Dylan Katz <dylan.katz@leviathansecurity.com>
Change-Id: Id5e77d053dc800a982176802dc506d26b54d810f
2020-09-11 11:03:02 -07:00
Treehugger Robot
91f3227436 Merge "Move PropertyMap from libutils to libinput" am: 01a30c0d2b
Original change: https://android-review.googlesource.com/c/platform/system/core/+/1396177

Change-Id: I02919926ccbc4127f9c9c2a2b66eb2a7334c7270
2020-09-08 16:17:05 +00:00
Siarhei Vishniakou
1329696700 Move PropertyMap from libutils to libinput
The input code is the only customer of PropertyMap. For easier
maintenance and eventual removal of it, move it to libinput.

Currently, the caller is responsible for managing the lifecycle of the
returned outMap when calling PropertyMap::load. However, the fact that
the function call allocates new memory is not obvious from the function
signature.

In a separate commit, I will refactor the function to return
Result<unique_ptr<>> to make it less errorprone.
In this commit, only move the files around to make code reviews easier.

Bug: 163171599
Test: atest inputflinger_tests
Change-Id: I316084886c3f09a1776fdb449d2f03d0563b66c1
2020-09-02 20:54:38 -07:00
Xin Li
0a112d52f8 Merge Android R (rvc-dev-plus-aosp-without-vendor@6692709)
Bug: 166295507
Merged-In: Id18cb0e2d2f3e776a42b566c4a1af2e250890896
Change-Id: Iba7cab32ab3aa6f47952c840ff6dc8492e8d0704
2020-08-29 01:42:13 -07:00
Greg Kaiser
b473061c5a Fix API for C compatibility
In https://android-review.googlesource.com/c/platform/system/core/+/1224544
when we introduced a default argument to androidSetThreadPriority(),
we broke C compatibility with this API, and with the header file
in general.

We fix this up by instead introducing a new method that takes
three arguments.  This gets this header file compiling for C again,
and keeps this particular API C compatible.

Any C++ callers of the three argument version of
androidSetThreadPriority() will need to switch to using
androidSetThreadPriorityAndPolicy().  Although since this was
a recent change, we believe there is only one such user, which
we are fixing at the same time.

Test: TreeHugger
Bug: 165009705
Merged-In: Iab0b7e6c91a8e32a17ba1b186fd0c2fe96b601e4
Change-Id: Iab0b7e6c91a8e32a17ba1b186fd0c2fe96b601e4
2020-08-24 17:29:25 +00:00
Elliott Hughes
5d0eb66590 Merge "Deprecate <utils/Debug.h>." 2020-08-17 20:36:10 +00:00
Elliott Hughes
884cedc770 Don't #include <utils/Debug.h> from <utils/Flattenable.h>.
It's not used, and shouldn't be used.

Also switch to `#pragma once`.

Test: treehugger
Change-Id: I464d3de1b0e1d536cea06362e6c73fddaad967d1
2020-08-17 10:14:16 -07:00
Elliott Hughes
832815151f Deprecate <utils/Debug.h>.
I stumbled across this because of the `#ifdef __cplusplus` inside an
unguarded `namespace`, but this whole file should be deprecated and
removed in favor of static_assert.

Test: treehugger
Change-Id: I2b65db67e694115e915f0cc9d762b0fd41a7d2af
2020-08-17 10:07:29 -07:00
Steven Moreland
bad50ed24f libutils: check vsnprintf error
For encoding errors, this function will return a negative value which
causes problems down the line. Check for an error and return. Also,
integer overflows are guarded.

Bug: 161894517
Test: fuzzer test case
Change-Id: Ia85067d4258bde4b875c832d6223db5dd26b8838
Merged-In: Ia85067d4258bde4b875c832d6223db5dd26b8838
(cherry picked from commit ee22384c54)
2020-08-12 21:45:05 +00:00
Elliott Hughes
2cfea97ba3 Merge "Add second batch of fuzzers for libutils" 2020-08-10 15:40:44 +00:00
Treehugger Robot
52c8422ea1 Merge "Add uptimeNanos to SystemClock" 2020-08-08 01:04:09 +00:00
Dylan Katz
7168f2726e Add second batch of fuzzers for libutils
This adds fuzzers for:
- CallStack
- Looper
- LruCache
- Printer
- ProcessCallStack
- PropertyMap
- RWLock
- RefBase
- StopWatch.
Test: Ran each fuzzer for 10 minutes. Rough coverage est. (likely far below actual value): 10.97%

Signed-off-by: Dylan Katz <dylan.katz@leviathansecurity.com>
Change-Id: I2f9f35c18b13338c282fb7f9c3ea4099ecb2c56f
2020-08-07 15:36:39 -07:00
Suprabh Shukla
a55ef96ea7 Add uptimeNanos to SystemClock
Test: system/core/libutils/SystemClock_test.cpp

Bug: 162791194
Change-Id: I0e3ea2004146eb7442c89bb35a9f3a2171d9c4b8
2020-08-07 14:36:07 -07:00
Dan Albert
ac4500e67d Update language to comply with Android's inclusive language guidance
See https://source.android.com/setup/contribute/respectful-code for reference

Bug: http://b/161896447
Test: None
Change-Id: I9e5a37a20012b2f7a8eac55701df03f7b7a9ab6c
2020-07-28 15:58:25 -07:00
Michael Wright
ec8ff6eed3 Merge "Soften BitSet class comment." am: 2ea91cfe76 am: 009d58d8da
Original change: https://android-review.googlesource.com/c/platform/system/core/+/1360510

Change-Id: I3f6493c151e4b75be52cf3e2dbda1db94c9642b6
2020-07-16 13:00:28 +00:00
Michael Wright
f32317c869 Soften BitSet class comment.
std::bitset<> doesn't have exact replacements for all of the
functionality of BitSet32/64, so there are still places we want to use
these classes.

Bug: 160010896
Test: test BitSet_test.cpp
Change-Id: Ica59a138e014d82139fb6dcea0597a207faecc2a
2020-07-16 00:04:20 +00:00
Steven Moreland
80c46b0541 String16::remove - avoid overflow am: 4048e49956 am: 107f18cb61 am: 9be245c3f0 am: 64fb5012b8 am: 4e27b6992b am: 26b81f59d2 am: 8367a666b5
Original change: https://googleplex-android-review.googlesource.com/c/platform/system/core/+/11619802

Change-Id: Ic25dca55b553b062edc4ced44ddef68b96428906
2020-07-14 17:24:42 +00:00
Victor Khimenko
add3b3a137 Merge "Make libbacktrace buildable for native_bridge" into rvc-dev 2020-07-14 17:18:34 +00:00
Steven Moreland
8367a666b5 String16::remove - avoid overflow am: 4048e49956 am: 107f18cb61 am: 9be245c3f0 am: 64fb5012b8 am: 4e27b6992b am: 26b81f59d2
Original change: https://googleplex-android-review.googlesource.com/c/platform/system/core/+/11619802

Change-Id: Ib4704bc8a733ace56e7998b7bad5a6c5638900ad
2020-07-14 17:03:30 +00:00
Steven Moreland
3619489de6 Merge "String8: explicit int -> char cast." 2020-07-14 16:30:42 +00:00
Steven Moreland
4e27b6992b String16::remove - avoid overflow am: 4048e49956 am: 107f18cb61 am: 9be245c3f0 am: 64fb5012b8
Original change: https://googleplex-android-review.googlesource.com/c/platform/system/core/+/11619802

Change-Id: I03057c052a24f205c78ee600178d45e0cd51a3c1
2020-07-14 16:29:09 +00:00
Steven Moreland
64fb5012b8 String16::remove - avoid overflow am: 4048e49956 am: 107f18cb61 am: 9be245c3f0
Original change: https://googleplex-android-review.googlesource.com/c/platform/system/core/+/11619802

Change-Id: I3ab9771d898eea0158acfd07fbe5a2f4b7dad883
2020-07-14 16:12:53 +00:00
Steven Moreland
9be245c3f0 String16::remove - avoid overflow am: 4048e49956 am: 107f18cb61
Original change: https://googleplex-android-review.googlesource.com/c/platform/system/core/+/11619802

Change-Id: I22f6b8299b4b77be31859a10b14efe01b297d531
2020-07-14 15:51:29 +00:00
Steven Moreland
107f18cb61 String16::remove - avoid overflow am: 4048e49956
Original change: https://googleplex-android-review.googlesource.com/c/platform/system/core/+/11619802

Change-Id: I4dedf81e3471473e589a858e14d7a9ae5f91b3d9
2020-07-14 15:37:25 +00:00
Steven Moreland
fdbc565dd5 String8: explicit int -> char cast.
Since tolower/toupper take and return integer arguments, ascii chars in
the extended range will be converted from positive int values to
negative char values. In order to silence an error here, which was added
recently with integer sanitization here, casting explicitly.

Fixes: 160831549
Test: w/ libutils_fuzz_string8
Change-Id: Iedcd6643f95f84ce662a80e38931d918a200f508
2020-07-13 23:33:25 +00:00
Michael Wright
71f4494bd1 Merge "Cast away signedness of built-ins in BitSet." 2020-07-13 15:45:40 +00:00
Michael Wright
23e1363d55 Cast away signedness of built-ins in BitSet.
Most of the built-in functions return signed values but BitSet deals
only in unsigned values. We can safely cast these away though as they're
always indices, which can't be negative.

Bug: 160010896
Test: atest inputflinger_tests, atest libinput_tests
Change-Id: I6e0b33972fabcd41ad1c269ea0e2a07b13b33c12
2020-07-12 01:56:58 +01:00
Victor Khimenko
fb60e6c9ae Make libbacktrace buildable for native_bridge
Bug: http://b/153609531

Test: m -j64 libbacktrace.native_bridge

Change-Id: I2b8a881b4e952f3b68dbcaeb14f147a6d955b406
Merged-In: I2b8a881b4e952f3b68dbcaeb14f147a6d955b406
2020-07-10 20:13:23 +02:00
Yo Chiang
5b028bab2a Move SingletonTest back to libutils_test
Use the new "data_libs:" to specify test library dependency. This is
like "data:" and it treats compiled libraries as test data files.
The result is libutils_test_singleton{1,2} is picked up by libutils_test
and installed next to the test binary.

Mark the test libs libutils_test_singleton{1,2} as uninstallable. This
prevents installing libutils_test_singleton{1,2} directly and only
permits installing via "data_libs:".

```
$ m libutils_test
testcases
└── libutils_test
    ├── arm
    │   ├── libutils_test
    │   ├── libutils_test_singleton1.so
    │   └── libutils_test_singleton2.so
    ├── arm64
    │   ├── libutils_test
    │   ├── libutils_test_singleton1.so
    │   └── libutils_test_singleton2.so
    └── libutils_test.config
```

Bug: 124838889
Test: atest libutils_test
Change-Id: I432135e128fc9eedb1b8c18a331957e271d8b0f0
2020-07-10 19:34:53 +08:00
Steven Moreland
9c832028c1 libutils: integer sanitization
For sanity.

Fixes: 160342252
Test: manually introduce overflow for "ubsan: mul-overflow"
Change-Id: I292039eaef24582f05dd9f0fef011f0ece8364ed
2020-07-07 22:37:07 +00:00
Victor Khimenko
7428c52ef2 Make libbacktrace buildable for native_bridge
Bug: http://b/153609531

Test: m -j64 libbacktrace.native_bridge

Change-Id: I2b8a881b4e952f3b68dbcaeb14f147a6d955b406
2020-06-18 22:02:46 +02:00
Christopher Ferris
bff51b88aa Fail explicitly on length overflow.
Instead of aborting when FileMap::create detects an overflow, detect the
overflow directly and fail the call.

Bug: 156997193

Test: Ran unit tests, including new unit test that aborted before.
Merged-In: Ie49975b8949fd12bbde14346ec9bbb774ef88a51
Change-Id: Ie49975b8949fd12bbde14346ec9bbb774ef88a51
(cherry picked from commit 68604b9c29)
2020-05-28 15:46:51 -07:00
Steven Moreland
4048e49956 String16::remove - avoid overflow
Bug: 156999009
Test: libutils_test (cases added)
Change-Id: Iad46d95d9848928ba81000090b2fe9aec1e5eaac
Merged-In: Iad46d95d9848928ba81000090b2fe9aec1e5eaac
(cherry picked from commit f251c1c581)
(cherry picked from commit 9a9c8910e9296c9dc8d79c37f589895f5a2a836c)
2020-05-28 20:45:55 +00:00
Elliott Hughes
842e1cc17e Make systemTime() abort on bad input.
There's no CHECK in libutils, sadly.

Bug: http://b/157167405
Test: treehugger
Change-Id: I1532bf80ba7fdafad016610be3c782b547417126
2020-05-27 15:31:55 -07:00
Christopher Ferris
68604b9c29 Fail explicitly on length overflow.
Instead of aborting when FileMap::create detects an overflow, detect the
overflow directly and fail the call.

Bug: 156997193

Test: Ran unit tests, including new unit test that aborted before.
Change-Id: Ie49975b8949fd12bbde14346ec9bbb774ef88a51
2020-05-26 12:00:07 -07:00
Rick Yiu
9ada65c0c6 Merge "Add choice for changing sched policy when setting thread priority" 2020-05-20 03:03:18 +00:00
Dylan Katz
9d5845bb5e Add fuzzers for libutils classes
Adds fuzzers for BitSet, FileMap, String8, String16, and Vector.
Test: Ran fuzzers on Android Pixel 3a. Aggregate coverage was 1.2% (this is far lower than true coverage due to shared libraries being counted)

Change-Id: I739216fe88afa51dc2f73b857da91116853382f0

Removed unneeded cflags, moved libbase to defaults

Test: Built Android.bp successfully

Signed-off-by: Dylan Katz <dylan.katz@leviathansecurity.com>
Change-Id: I739216fe88afa51dc2f73b857da91116853382f0
2020-05-15 10:30:16 -07:00
Rick Yiu
57affbf91d Add choice for changing sched policy when setting thread priority
If the policy has been changed already, we do not need to change
it again.

Bug: 139521784
Test: functionality verified
Change-Id: I251db1d3f874896ba9be68df87209e7e514b80f9
2020-05-15 15:28:23 +00:00
Jooyung Han
7937f29be8 Set min_sdk_version to be part of mainline modules
Modules contributing mainline modules (APK/APEX) should set
min_sdk_version as well as apex_available.

For now setting min_sdk_version doesn't change build outputs.
But build-time checks will be added soon.

Bug: 152655956
Test: m
Merged-In: Ida890adfe6dfac79267fc0e18b63d2330266438c
Change-Id: Ida890adfe6dfac79267fc0e18b63d2330266438c
(cherry picked from commit 7ea0d74bc8)
2020-05-13 12:10:36 +09:00
Jooyung Han
7ea0d74bc8 Set min_sdk_version to be part of mainline modules
Modules contributing mainline modules (APK/APEX) should set
min_sdk_version as well as apex_available.

For now setting min_sdk_version doesn't change build outputs.
But build-time checks will be added soon.

Bug: 152655956
Test: m
Change-Id: Ida890adfe6dfac79267fc0e18b63d2330266438c
2020-05-13 08:18:06 +09:00
Christopher Ferris
310b46c1ca Merge "Fix mac build." into rvc-dev 2020-05-12 17:17:25 +00:00
Christopher Ferris
1500d0e7a9 Fix mac build.
Add an inline for mmap64 to use on mac.

Bug: 155662887
Bug: 156053599

Test: Builds.
Change-Id: Id02e2c2f40acea2bdef604e9b80b70a85a941927
(cherry picked from commit 8a6dff22dc)
2020-05-11 23:07:53 +00:00