Commit graph

49891 commits

Author SHA1 Message Date
Steven Moreland
1ec3b78b67 libprocessgroup users use libcutils
libprocessgroup symbols are being moved into libcutils in order to
optimize linking/memory usage. libprocessgroup will no longer be
required in the future (however removing references to it will come
separately).

Bug: 135145426
Test: boot

Test:
BEFORE:
$ adb shell showmap -a $(pid hwservicemanager) | grep -P "libprocessgroup|libcutils" -A1 | grep -P 'libprocessgroup|libcutils|\.bss' | awk '{s += $9}END{print s}'
28

AFTER:
$ adb shell showmap -a $(pid hwservicemanager) | grep -P "libprocessgroup|libcutils" -A1 | grep -P 'libprocessgroup|libcutils|\.bss' | awk '{s += $9}END{print s}'
12

Change-Id: I10d7c2d2b2b14cbbe0a128b9156d31206419d24c
2019-06-18 22:03:54 +00:00
Steve Muckle
9b90198887 VtsKernelLiblpTest: use static test
To avoid introducing dependencies on target libraries, use a statically
compiled test instead.

Bug: 134912860
Test: run vts-kernel -m VtsKernelLiblpTest
Change-Id: Ie24cc8532c7821cb225c024c240c4d485557bfa7
2019-06-14 16:10:25 -07:00
TreeHugger Robot
4e5fddd5f5 Merge "Add libcgrouprc to ld.config.txt." into qt-dev 2019-06-12 22:36:30 +00:00
mtk16036
540b1556c9 race condition in libprocessgroup
while enable fdsan (file descriptor sanitizer),
fdsan report use-after-close error after boot complete (sedom).

Because, in SetCgroupAction::EnableResourceCaching() currently has a data race against all the
use fd_ functions like SetCgroupAction::ExecuteForProcess(uid_t uid, pid_t pid) etc.

ThreadA                                     | ThreadB
-------------------------------------------------------------------------------------------------
in SetCgroupAction::EnableResourceCaching() | in SetCgroupAction::ExecuteForProcess(...)
-------------------------------------------------------------------------------------------------
                                            | in SetCgroupAction::AddTidToCgroup(int tid, int fd)
-------------------------------------------------------------------------------------------------
fd_ = std::move(fd); /*modified fd_ value*/ |
-------------------------------------------------------------------------------------------------
                                            | write(fd)  /* crash here, fd is closed by ThreadA*/
-------------------------------------------------------------------------------------------------

So, add mutex lock to protect fd_ data race.

Bug: 134120826
Test: auto test, run the adb reboot test 100 times and no fdsan error report on libprocessgroup
Merged-In: Iccf2f705e030f79324f1164509e715dc5be825de
Change-Id: Iccf2f705e030f79324f1164509e715dc5be825de
2019-06-12 19:27:14 +00:00
Min Yun
8d502fc150 Add libcgrouprc to ld.config.txt.
- In GSI, media.extractor has follow dependency.
media.extractor -> libmpeg2extractor (media ns) ->
libprocessgroup (media ns) -> libcgrouprc (default ns).
If libcgroupsrc can't link from libmpeg2extractor, media.extractor is crashed.

Test: media.extractor didn't die.
Bug: 134981805
Merged-In: I7d3e7e6477708a505b87a884e05cd719f5a3d496
(cherry picked from commit d695733df9)

Change-Id: I7d3e7e6477708a505b87a884e05cd719f5a3d496
2019-06-12 13:56:31 +09:00
Jaegeuk Kim
607611e016 Merge "fs_mgr: support -o sync" into qt-dev 2019-06-11 02:55:47 +00:00
Jaegeuk Kim
9b85e1fb20 fs_mgr: support -o sync
Bug: 134172577
Change-Id: I1ad8811b07657727d8227d3668f58b0fbc7e7609
Merged-In: I1ad8811b07657727d8227d3668f58b0fbc7e7609
Signed-off-by: Jaegeuk Kim <jaegeuk@google.com>
2019-06-10 21:52:40 +00:00
Mark Salyzyn
0dff785221 fs_mgr: overlayfs: pre-emptive filesystem setup
If we just disabled verity, take the step to setup the backing
storage for overlayfs.

Test: adb-remount-test.sh
Bug: 130131892
Change-Id: Ic56569eaf363e4417a0ce5df11ee5480a07b8b03
Merged-In: Ic56569eaf363e4417a0ce5df11ee5480a07b8b03
2019-06-04 14:14:58 +00:00
Anton Hansson
b6d9fbddc6 Merge "Close /dev/fuse FD before calling onClosed" into qt-dev 2019-05-31 15:59:39 +00:00
Anton Hansson
c9e873f274 Close /dev/fuse FD before calling onClosed
This works around a deadlock when a bridge that is about to be closed
is reused for a new call to openFile. The call to open() ends up holding
the vold lock, waiting for appfuse to respond. The appfuse event loop
calls onClosed(), which ends up calling vold.unmountAppFuse(), which
cannot get the lock.

Closing this file descriptor causes any current calls to open() on its
mount path to fail with either ECONNABORTED or ENOTCONN, allowing the
event loop to make progress, call onClosed() and unmount the path.

Note that the failed call to open() will result in a retry, which
will create a new appfuse bridge. This is not ideal but not a new
problem -- the common case here is that that each call to
openProxyFileDescriptor creates a new bridge. This should ideally
be improved.

Bug: 132344997
Test: flick through info of photos with location info attached
Exempt-From-Owner-Approval: verbal approval of approach
Change-Id: I878e5cf86f18c5233f8505f52eb9db076bd72d01
2019-05-31 15:58:45 +00:00
TreeHugger Robot
4d63d1b7bb Merge "init: make fatal reboot target configurable" into qt-dev 2019-05-31 15:35:15 +00:00
TreeHugger Robot
d0ed53e5e7 Merge "init: dump stack when aborting" into qt-dev 2019-05-31 15:35:13 +00:00
Daichi Hirono
ca0d4ffbe3 Fix BridgeEpollController to handles EAGAIN correctly
When reading/writing proxy FD, if it returns EAGAIN,
BridgeEpollController updates epoll entries to observe specific FD
events. Before updating epoll entries, BridgeEpollController checks if
it really needs to update by comparing |state_| and |last_state_|.
|last_state_| has not been updated correctly so it resulted in wrong
epoll settings and keeps blocking the event loop.

Bug: 134104939
Test: atest libappfuse_test
Change-Id: I1c4a0164c1c016baf24ecfd523476ced981d3b28
2019-05-31 12:51:05 +09:00
Tim Murray
cc18faf4d6 Merge "lmkd: use ALOGE for logging kills" into qt-dev 2019-05-30 22:10:56 +00:00
Tim Murray
b62b3ef2ba lmkd: use ALOGE for logging kills
Test: boots, works
Bug: 133761317
Signed-off-by: Tim Murray <timmurray@google.com>
Exempt-From-Owner-Approval: trivial change

Change-Id: I1a4a3741694078eec124f1f560ea68e78754bca6
2019-05-30 22:10:36 +00:00
Tom Cherry
b80149d8bc init: make fatal reboot target configurable
Currently, if init encounters a fatal issues it reboots to fastboot
but this may be not desirable in all cases, especially the case of
critical services crashing.  Therefore this change adds the ability
for vendors to customize the reboot target via the
androidboot.init_fatal_reboot_target= kernel command line.

This applies to all LOG(FATAL) messages as well as fatal signals in
userdebug/eng builds, except for signals before logging is enabled in
first stage init.

Bug: 121006328
Test: device reboots to configurable target with LOG(FATAL)
Test: device reboots to configurable target after a segfault in the
      various stages of init
Test: device reboots to fastboot without a configured target
Change-Id: I16ea9e32e2fee08dece3d33b697d7a08191d607b
Merged-In: I16ea9e32e2fee08dece3d33b697d7a08191d607b
(cherry picked from commit 75e13baf32)
2019-05-30 12:10:51 -07:00
Tom Cherry
1fcd51255a init: dump stack when aborting
Dump init stacks when aborting either due to LOG(FATAL) or in
userdebug/eng builds due to signals, including signals from
sanitizers.

Doesn't work for static first stage init yet, b/133450393 tracks
that.

Also, ensure that LOG(FATAL) in child processes calls abort() in all
stages of init, not just 2nd stage init.

Bug: 131747478
Test: abort init in various ways and see stacks
Test: hang or crash in backtrace handler and see child reboot
Change-Id: Ib53b5d3e7e814244203f875de016ada9900dfce8
Merged-In: Ib53b5d3e7e814244203f875de016ada9900dfce8
(cherry picked from commit 59656fb377)
2019-05-30 12:08:42 -07:00
TreeHugger Robot
9122289a97 Merge "Fix non-aio USB read issue for fastbootd" into qt-dev 2019-05-29 23:11:55 +00:00
chihhao.chen
5f8b966d96 Fix non-aio USB read issue for fastbootd
non-aio USB read function was stuck in a loop waiting for more data
because data length parameter is always set 64 for fastbootd commands.
It should be a normal case to get less data than expected
since lengths of these commands are usually less than 64.
Add logic to check this and one more parameter to distinguish
fastbootd from general adbd case.

Bug: 133189029
Test: try various fastbootd commands
Change-Id: I6690324840d78f3f1e04235040301520329976db
2019-05-29 12:41:55 -07:00
Ryan Mitchell
d1531ac4e8 Fix leak of mapped zip central directories
Memory mapping the central directory of specific APKs caused memory
mappings to build up over time because they were never unmapped
correctly. This is because MappedFile is not calling munmap with the
size of the data after aligning the mmap offset to a page boundary.

Bug: 133463863
Test: install APKs and verify that the entire mapped CD is unmaped
Test: ran aapt2 as daemon and confirmed that mapped CD is unmapped
Change-Id: Icb6cfebe0e8d67160fee34c5e6423d0f05de526b
2019-05-28 23:00:04 +00:00
Narayan Kamath
c6ca823710 rootdir / sdcard : Stop creating /data/media/obb.
This directory is no longer used. OBB content is
placed in /data/media/$user/Android.

Test: make
Test: manually verify the path doesn't exist.
Bug: 129167772

Change-Id: I8549826586b9a68c8cfa3fe2e51295363f9b4e11
2019-05-23 15:09:54 +01:00
Bowgo Tsai
b36b54cf79 Merge "Moving /odm/build.prop to /odm/etc/buid.prop" into qt-dev 2019-05-23 02:13:26 +00:00
Josh Gao
8ef22b102c Merge "adbd: respond to device-to-host control transfers." into qt-dev 2019-05-22 21:06:56 +00:00
Wei Wang
c39fcd42d7 Merge "Report non-empty system boot reason when bootloader reason is empty" into qt-dev 2019-05-22 20:28:58 +00:00
Wei Wang
699e342b3d Report non-empty system boot reason when bootloader reason is empty
Bug: 133321647
Test: build
Change-Id: Icd3ea4b69ef2ad040926e2b0e121a8f5f1c1b658
2019-05-22 09:46:02 -07:00
Hridya Valsaraju
4472fdb4d0 fastbootd: reduce USB buffer size to 16K
Some USB controllers can only support transfers upto 16K.

Bug: 133208811
Test: fastboot flashall
Change-Id: Ic025bdd8e7a6cf2634fc24524fd189e0cc9efbb5
Merged-In: Ic025bdd8e7a6cf2634fc24524fd189e0cc9efbb5
(cherry picked from commit d747dba9c0)
2019-05-22 16:14:22 +00:00
Victor Chang
28904625b8 Merge "Allow linking to libicuuc.so and libicui18n.so from executable in /data" into qt-dev 2019-05-22 15:43:44 +00:00
Bowgo Tsai
3182ea132e Moving /odm/build.prop to /odm/etc/buid.prop
In device root directory, we have the following symlinks:
  - /odm/app -> /vendor/odm/app
  - /odm/bin -> /vendor/odm/bin
  - /odm/etc -> /vendor/odm/etc
  ...

This allows the Generic System Image (GSI) to be used on both devices:
  1) Has a physical odm partition, where those symlink will be hidden
     when /odm is used as the mount point
  2) Has no physical odm partition and fallback to /vendor/odm/.

We can't just have the symlink /odm -> /vendor/odm, because the former
devices won't have /vendor/odm directory, which leads to mount failure
when the mount point /odm is resolved to /vendor/odm.

The existing /vendor/odm/build.prop won't be loaded in the latter
devices, because there is no symlink
    - /odm/build.prop -> /vendor/odm/build.prop.

Note that init blocks reading through direct symlinks (O_NOFOLLOW) so
the above symlink won't work either. This CL moves the odm build.prop
to /odm/etc/build.prop for init to load it (symlinks in earlier
components of the path will still be followed by O_NOFOLLOW).

Bug: 132128501
Test: boot a device and checks /odm/etc/build.prop is loaded
Change-Id: I0733c277baa67c549bb45599abb70aba13fbdbcf
Merged-In: I0733c277baa67c549bb45599abb70aba13fbdbcf
(cherry picked from commit c49655b2a4)
2019-05-22 16:15:44 +08:00
Josh Gao
af086e9a95 adbd: respond to device-to-host control transfers.
Failing to write to the endpoint results in subsequent reads on ep0 to
fail with EL2HLT, so do an empty write to fulfill the transfer.

Bug: http://b/131867920
Test: manually tested with modified auto client
Change-Id: If2eec162ca4b31a9974c7bd5802be51cee9e2708
2019-05-21 16:39:51 -07:00
Suren Baghdasaryan
9b77c0ba32 Merge "libprocessgroup: add flags to indicate when a controller failed to mount" into qt-dev 2019-05-21 16:53:52 +00:00
TreeHugger Robot
2a19765eb5 Merge "Get max-download-size from device during fastbootd for flashall/update" into qt-dev 2019-05-21 04:54:08 +00:00
TreeHugger Robot
7eeed22871 Merge "adbd: reduce queue depths." into qt-dev 2019-05-21 00:05:34 +00:00
TreeHugger Robot
5b882637e1 Merge "adbd: avoid starting multiple worker threads." into qt-dev 2019-05-21 00:04:15 +00:00
Hridya Valsaraju
f929aaa7c0 Get max-download-size from device during fastbootd for flashall/update
Currently, during a 'fastboot flashall/fastboot update', the 'getvar
max-download-size' command is issued once to the device when it is in
bootloader mode and the same value is used even after the device boots
into fastbootd. If the max-download-size returned by bootloader is
greater than the max-download-size in fastbootd, this could break flash
as large images are broken down into chunks before downloading by using
the max-download-size variable. This will cause fastbootd to return
an error since it checks whether the buffer being downloaded has a size
greater than the max-download-size limit.

Test: fastboot flashall
Bug: 132917902

Change-Id: Ife7c1ec0583d80d4a31ecf01f1fc14a8365afe0d
Merged-In: Ife7c1ec0583d80d4a31ecf01f1fc14a8365afe0d
(cherry picked from commit 83d856e4c5)
2019-05-20 23:58:45 +00:00
TreeHugger Robot
6031286936 Merge "adbd: read, print, and ignore USB control transfers." into qt-dev 2019-05-20 21:37:24 +00:00
Victor Chang
32190f45e0 Allow linking to libicuuc.so and libicui18n.so from executable in /data
Executable in /data/ runs in default linker namespace, not
classloader namespace.
In Q, we moved libicuuc.so and libicui18n into the runtime
namespace, and allow linking from runtime namespace and classloader
namespace.

This change further allows linking from default namespace, and tries
to fix the regression temporarily.

Bug: 130788466
Test: The app issue is fixed after this CL
Merged-In: Ifae52b554124514e433cfe78875643a7450fbabd
Change-Id: Ifae52b554124514e433cfe78875643a7450fbabd
(cherry picked from commit 0c7edece94)
2019-05-20 11:59:51 +01:00
Josh Gao
12807c7012 adbd: read, print, and ignore USB control transfers.
It seems like we're blowing up when receiving a control transfer that's
intended for Android Auto, because we're not expecting to get the data
for the control transfer in a subsequent read.

Bug: http://b/131867920
Test: none
Change-Id: Icfd642e6dfc02d2ccbdd60c39f89e534298c944d
2019-05-17 18:34:23 -07:00
Suren Baghdasaryan
fd285d2b70 libprocessgroup: add flags to indicate when a controller failed to mount
Controllers listed in cgroups.json file might fail to mount if kernel is
not configured to support them. We need a way to indicate whether a
controller was successfully mounted and is usable to avoid logging errors
and warnings when a controller that failed to mount is being used. Add
flags bitmask to cgrouprc controller descriptor and use a bit to indicate
that controller is successfully mounted. Modify cpusets_enabled() and
schedboost_enabled() functions to use this bit and report the actual
availability of the controller.

Bug: 124080437
Test: libcutils_test with cpuset and schedtune controllers disabled
Change-Id: I770cc39fe50465146e3205aacf77dc3c56923c5d
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
2019-05-17 16:18:29 -07:00
TreeHugger Robot
982259add1 Merge "Initialize all fields of struct iocb." into qt-dev 2019-05-16 23:27:38 +00:00
Evgenii Stepanov
9da358d6d3 Initialize all fields of struct iocb.
Kernel does not accept non-zero value of iocb->aio_reserved2.

Bug: 132803232
Test: initialize malloc() memory to non-zero pattern and see what breaks

Change-Id: I65a7e89e3a2c1ba79df1dc2d011d6c76c41afb81
(cherry picked from commit fe7eca7b8f)
2019-05-16 12:55:41 -07:00
Alistair Strachan
9924f7ee2d Merge "Add asan.permitted.paths for the media namespace" into qt-dev 2019-05-16 14:45:58 +00:00
Martijn Coenen
5ff7c4b22d Merge "class_start_post_data also starts disabled services." into qt-dev 2019-05-16 07:29:35 +00:00
TreeHugger Robot
2c4803838e Merge "Allow CreateResizeDeleteLP test case to run on non-A/B devices" into qt-dev 2019-05-15 22:25:03 +00:00
Martijn Coenen
ebce675b17 class_start_post_data also starts disabled services.
This keyword was introduced to support restarting services on devices
using APEX and FDE. The current implementation is not a restart, but
rather a 'reset' followed by a 'start', because the real /data must be
mounted in-between those two actions. But we effectively want this to be
a restart, which means that we also want to start 'disabled' services
that were running at the time we called 'class_reset_post_data'.

To implement this, keep track of whether a service was running when its
class was reset at post-data, and start all those services.

Bug: 132592548
Test: manual testing on FDE Taimen
Change-Id: I1e81e2c8e0ab2782150073d74e50e4cd734af7b9
2019-05-15 22:23:41 +02:00
Hridya Valsaraju
fbaffb5deb Allow CreateResizeDeleteLP test case to run on non-A/B devices
Test: fuzzy_fastboot --gtest_filter=*Logical*
Bug: 117220134

Change-Id: Ic7c2b246b7c5646d3589f8f57eceb9ba5feeef2b
Merged-In: Ic7c2b246b7c5646d3589f8f57eceb9ba5feeef2b
(cherry picked from commit f81bd17179)
2019-05-15 09:29:34 -07:00
Jiyong Park
78e6b181ac Add asan.permitted.paths for the media namespace
Permitted paths were empty for ASAN builds with the media namespace.

Bug: 131625115
Test: no dlopen failure on libflacextractor.so in aosp_cf_x86_pasan
Change-Id: I90050fc54820ba68d64931412572f3b0954e6616
2019-05-15 12:41:01 +09:00
TreeHugger Robot
83e9f6bd68 Merge "fs_mgr: overlayfs: ReadFstabFromFile touches errno" into qt-dev 2019-05-14 00:25:22 +00:00
TreeHugger Robot
82ebfca5cd Merge "adbd: don't abort on EOF on functionfs control fd." into qt-dev 2019-05-13 22:21:59 +00:00
Josh Gao
1f7ae9d4e3 adbd: don't abort on EOF on functionfs control fd.
Also, improve the logging in the cases where we do abort.

Bug: http://b/131867920
Test: treehugger
Change-Id: If8ec9f4614ce146e6dbd21cc77587ea81658199b
(cherry picked from commit 2916e148d9)
2019-05-13 11:42:29 -07:00
Mark Salyzyn
8471f92a20 fs_mgr: overlayfs: ReadFstabFromFile touches errno
(cherry picked from commit 98a0128e44)

Regression from commit 77c28476f1
("Remove the mount points defined in skip_mount.cfg from
ReadDefaultFstab()") resulted in ReadFstabFromFile to report
errno ENOENT even upon success, preventing clear error propagation
for real failures (ReadFstabFromFile would _always_ report ENOENT).

The bad error propagation resulted in an adb remount failure.

Added immunization against future adjustments that may also
result in a similar regression in adb remount behaviors.

Test: adb-remount-test.sh
Bug: 132594161
Bug: 128961335
Change-Id: Icf5d48bbfc6d938d4b9657ca8004a6a6ddaab5a6
2019-05-13 11:03:10 -07:00