Commit graph

75249 commits

Author SHA1 Message Date
Eric Biggers
6cb5a36f4c init: fix mkdir to reliably detect top-level /data directories
To determine the default encryption action, the mkdir command checks
whether the given path is a top-level directory of /data.  However, it
assumed a path without any duplicate slashes or trailing slash(es).

While everyone *should* be providing paths without unnecessary slashes,
it is not guaranteed, as paths with unnecessary slashes still work
correctly for all other parts of the mkdir command, including the
SELinux label lookup and the actual directory creation.  In particular,
the /data/fonts directory is being created using 'mkdir /data/fonts/'.

The effect is that the mkdir command thinks that /data/fonts/ is *not* a
top-level directory of /data, so it defaults to no encryption action.
Fortunately, the full command happens to use "encryption=Require", so we
dodged a bullet there, though the warning "Inferred action different
from explicit one" is still triggered.

There are a few approaches we could take here, including even just
fixing the /data/fonts/ command specifically, but I think the best
solution is to have mkdir clean its path at the very beginning.  This
retains the Linux path semantics that people expect, while avoiding
surprises in path processing afterwards.  This CL implements that.

Note, this CL intentionally changes the behavior of, and thus would
break, any existing cases where mkdir is used to create a top-level
/data directory using a path with unnecessary slashes and without using
an explicit encryption action.  There are no known cases where this
already occurs, however.  No cases exist in platform code, and vendor
init scripts shouldn't be creating top-level /data directories anyway.

Test: atest CtsInitTestCases
Test: Booted and verified that a trailing slash is no longer present in
      the log message "Verified that /data/fonts/ has the encryption
      policy ...".  Also verified that the message "Inferred action
      different ..." is no longer present just above it.
Bug: 232554803
Change-Id: Ie55c3ac1a2b1cf50632d54a1e565cb98c17b2a6a
2022-05-13 19:29:00 +00:00
Jooyung Han
ec76b5cb4e Merge changes from topics "action-in-apex-config", "apex-ready-event", "subcontext-for-vendor-apex"
* changes:
  Use subcontext for APEX configs from /{vendor, odm}
  add apex-ready event after post-fs-data
  APEX configs support 'on' as well
2022-05-13 01:47:40 +00:00
Eric Biggers
93a8fc215e Merge "Move creation of /data/user/0 and /data/media/obb to vold" 2022-05-12 18:41:21 +00:00
Treehugger Robot
c970c8257d Merge "Remove setenvs when running boringssl_self_test." 2022-05-12 15:30:22 +00:00
Pete Bentley
ba830eb81b Remove setenvs when running boringssl_self_test.
No longer needed as the code to generate flag files based on
this environment variable is removed in Android 13.

Bug: 231946889
Test: Build and boot,
Change-Id: I8ce57619aa4d1e6457f3f864bf5e403f727c040c
2022-05-12 13:50:37 +01:00
Jooyung Han
38e8e74550 Use subcontext for APEX configs from /{vendor, odm}
Instead of using config file path, use APEX's preinstalled path to
determine whether to use subcontext or not for APEX configs.

Bug: 232021354
Test: CtsInitTestCases, CtsBluetoothTestCases
Change-Id: Iba603f09602f0bec3113e2be3d15c62055c09e72
2022-05-12 13:37:19 +09:00
Jooyung Han
1eb3394e9c add apex-ready event after post-fs-data
Since apexd.status=ready is system-only property, we need a similar or
equivalent event or property which non-system APEXes can use to define
'on' trigger actions.

Note that services can be started without its own trigger actions by
setting 'class'. For example, 'hal'-class services are started 'on boot'
automatically.

Bug: 202731768
Test: atest CtsInitTestCases
Test: atest CtsBluetoothTestCases (cuttlefish's bt apex defines
   'on' actions in the APEX config)
Change-Id: I6eb62ba8d6e350add2ebafe7da06fcaa57d825ff
2022-05-12 13:37:19 +09:00
Jooyung Han
badb7de1a2 APEX configs support 'on' as well
APEX configs have supported only 'service' definitions. For those
services relying on 'on' trigger actions, we had to have separate config
files installed in read-only partitions (e.g. /system/etc/init).

This was suboptimal because even though APEXes are updatable, read-only
partitions are not.

Now, 'on' is supported in APEX configs. Putting 'on' trigger actions
near to service definitions makes APEX more self-contained.

'on' trigger actions loaded from APEX configs are not sticky. So, events
happens before loading APEX configs can't trigger actions. For example,
'post-fs-data' is where APEX configs are loaded for now, so 'on
post-fs-data' in APEX configs can't be triggerd.

Bug: 202731768
Test: atest CtsInitTestCases
Change-Id: I5a01d9c7c57b07955b829d6cc157e7f0c91166f9
2022-05-12 13:37:13 +09:00
Christopher Ferris
dbe14f2f73 Merge "Use new AndroidUnwinder object." 2022-05-12 03:35:34 +00:00
Richard Chang
a596618d4a Merge "Remove redundant settings in init.rc for cpu scaling_max_freq" 2022-05-12 02:48:27 +00:00
Treehugger Robot
c545516e2c Merge "Doc Thread requirement." 2022-05-12 01:53:32 +00:00
Treehugger Robot
a14a44ca66 Merge "Make sure all expected actions get run." 2022-05-12 00:05:34 +00:00
Steven Moreland
90722d254e Doc Thread requirement.
Fixes: 230893354
Test: N/A
Change-Id: I426184840c7bf61fe3369388cfc6db184470acf0
2022-05-11 23:13:17 +00:00
Christopher Ferris
d2bd6c5f13 Use new AndroidUnwinder object.
Replace libbacktrace with the new AndroidUnwinder object.

Bug: 120606663

Test: Ran unit tests.
Test: Added call of UnwindMainThreadStack() in DebugRebootLogging()
Test: and verified unwind data is logged properly.
Change-Id: Ia724f9485377d6d2c894283242a3c5653bf82768
2022-05-11 15:39:20 -07:00
Eric Biggers
ef9275223c Move creation of /data/user/0 and /data/media/obb to vold
To prevent bugs, directory creation and encryption should happen
together.  /data/user/0 (and its "alias" /data/data) is a per-user
encrypted directory; such directories can only be encrypted by vold.
Therefore, move its creation to vold as well.

Besides closing the uncomfortably-large gap between the creation and
encryption of /data/user/0, this allows removing init's write access to
/data/user and similar directories (SELinux type system_userdir_file) to
prevent any such issues from being reintroduced in the future.

To also allow removing init's write access to /data/media (SELinux type
media_userdir_file), which also contains per-user encrypted directories,
also move the creation and encryption of /data/media/obb to vold.

Bug: 156305599
BYPASS_INCLUSIVE_LANGUAGE_REASON=Linux API ("slave" mount flag)
Change-Id: I7245251eeb56b345b6c7711482c0aa5848648edb
2022-05-11 21:50:35 +00:00
Christopher Ferris
af4db6749a Merge "Use the new AndroidUnwinder object." 2022-05-11 20:53:58 +00:00
Richard Chang
6f554d1a2a Remove redundant settings in init.rc for cpu scaling_max_freq
The uevent.rc will setup owner/group/permissions in all the conditions
including device boot, cpu hotplugs, and cpu online/offline.
Since ueventd always regenerates uevents at boot, we could remove the
redundant settings in init.rc.

Bug: 230291215
Test: Build and check scaling_max_freq on Cuttlefish and B3 device
Change-Id: I4fcc440f2a950967667f88da574faa501b3e227c
2022-05-11 08:55:27 +00:00
Florian Mayer
6268f6ab7a Make sure all expected actions get run.
Change-Id: I2b390ffa394ccd6a50a4a5d8805ce5a580c369b9
2022-05-11 01:02:03 +00:00
Christopher Ferris
ab63124cd9 Use the new AndroidUnwinder object.
Replaces libbacktrace in CallStack. There is one small behavioral
change, the BuildId data is added to the unwinds.

Bug: 120606663

Test: All unit tests pass.
Test: Run the fuzzer for over an hour without any crashes.
Change-Id: Ic8a4247c515ce0d3cdc4d2cc15167d1948b15fa5
2022-05-10 17:19:12 -07:00
Richard Chang
abff801ae6 Merge "Align file permissions for cpufreq scaling_max_freq node" 2022-05-10 03:31:02 +00:00
Treehugger Robot
2d6ffb27d6 Merge "Promote HWASan tests to presubmit." 2022-05-10 01:10:11 +00:00
Florian Mayer
4dd9529e2b Promote HWASan tests to presubmit.
They have been passing and do not show significant slowdown.

Change-Id: I130335423a2e111fb8cede493ce5c7449d4907ef
2022-05-09 22:42:47 +00:00
Richard Chang
cbd75b85a2 Align file permissions for cpufreq scaling_max_freq node
The ueventd.rc sets permissions to 0664 but init.rc sets cpu0 to
0660. Since lots of processes already had read access for cpufreq nodes
(refer to system/sepolicy/public/domain.te), align all cpus to 0644
permissions.

Bug: 230291215
Test: Build
Change-Id: I3c72d69590998f8da894fb02097212f834edd48c
2022-05-09 09:12:58 +00:00
Treehugger Robot
37a5303642 Merge "Promote HWASan tests to presubmit." 2022-05-06 22:34:41 +00:00
Treehugger Robot
d65a7f0ca0 Merge "Promote HWASan tests to presubmit." 2022-05-06 22:30:42 +00:00
Florian Mayer
1e7af8d975 Promote HWASan tests to presubmit.
They have been passing and do not show significant slowdown.

Change-Id: If3aea998fcf33559824cf02e9963e8a71ac80163
2022-05-06 19:14:15 +00:00
Florian Mayer
eafc35bd4f Promote HWASan tests to presubmit.
They have been passing and do not show significant slowdown.

Change-Id: I2e072d3e8f772ddcc43d497fd306bed8387403db
2022-05-06 19:08:21 +00:00
Trevor Radcliffe
b0fa575e1f Merge "set isolated: false on fuzzy_fastboot" 2022-05-06 17:11:17 +00:00
Jaegeuk Kim
45aafa58d4 Merge "Support /dev/fscklogs/log in f2fs back" 2022-05-04 07:35:09 +00:00
Treehugger Robot
ced437ea26 Merge "Promote tests to HWASan presubmit." 2022-05-04 03:57:01 +00:00
Suren Baghdasaryan
25f0c1c457 Merge changes from topic "228160715_fix"
* changes:
  init: Purge empty process groups on zygote restart
  libprocessgroup: Add a function to remove only empty process groups
2022-05-03 19:43:22 +00:00
Florian Mayer
78bf3beb49 Promote tests to HWASan presubmit.
Change-Id: I55711f80c4ea870a78e7971fe133f096dac9ef1a
2022-05-03 19:40:36 +00:00
Alix Espino
d3918d8d1e Merge "Moved contents of clang_cflags into cflags" 2022-05-03 17:12:37 +00:00
Treehugger Robot
04afe0c3dc Merge "Delete stale Virtualization image files" 2022-05-03 09:28:57 +00:00
Jaegeuk Kim
3aca50cb9e Support /dev/fscklogs/log in f2fs back
We need to fix the below error happening in early stage.

[   24.835617][    T1] init: [libfs_mgr]Running /system/bin/fsck.f2fs -a -c 10000 --debug-cache /dev/block/sda1
[   24.843693][    T1] logwrapper: Cannot log to file /dev/fscklogs/log

Bug: 230637147
Bug: 230879192
Signed-off-by: Jaegeuk Kim <jaegeuk@google.com>
Change-Id: I19bc5f7154577e29414f855de6ce72172b281975
2022-05-02 15:06:43 -07:00
Daeho Jeong
aceda4728b Merge "init.rc: increase readahead window multiplier for POSIX_FADV_SEQUENTIAL files" 2022-05-02 17:43:57 +00:00
Daeho Jeong
431e35ef7c init.rc: increase readahead window multiplier for POSIX_FADV_SEQUENTIAL files
Set readahead window multiplier for POSIX_FADV_SEQUENTIAL files as 16 to
enhance file read performance like a language package loading.

Bug: 192011293
Test: adb shell cat /dev/sys/fs/by-name/userdata/seq_file_ra_mul
Signed-off-by: Daeho Jeong <daehojeong@google.com>
Change-Id: I7f7e4339651be2d6aa99b07bcb12ab62136a940e
2022-04-29 11:52:03 -07:00
Suren Baghdasaryan
af64077f83 init: Purge empty process groups on zygote restart
When system_server crashes or gets killed, it causes zygote to kill
itself, which in turn leads to killing all processes in the same
process group (all apps). This leaves empty process groups because
system_server is not there to remove them.
Purge empty process groups when init detects zygote death.

Bug: 228160715
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
Change-Id: I0ce27eea28f8713e52033bbec2d5363a7b8ff5db
2022-04-29 17:17:51 +00:00
Suren Baghdasaryan
4345f3f50a libprocessgroup: Add a function to remove only empty process groups
When system_server and zygote crash or get killed, all apps also get
killed but their process groups are left empty. Provide a function to
remove all empty process groups so that init can purge them when this
even happens.

Bug: 228160715
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
Change-Id: Ife38ca021e80cd38106f218ae13183e8c2631bf0
2022-04-29 10:17:17 -07:00
Alan Stokes
df84dd93e5 Delete stale Virtualization image files
Delete all files and directories under
/data/misc/virtualizationservice at boot. Originally they were owned
by the virtualizationservice user; we now run as system, and don't
have permission to remove them after boot.

Bug: 230056726
Test: Create fake stale dir+file, see them deleted
Change-Id: I5ff7d055aeeb25ba7693e50876d6b8a830c4bf51
(cherry picked from commit 34ee0c931c)
2022-04-29 10:56:19 +00:00
Trevor Radcliffe
1adca2b8e9 set isolated: false on fuzzy_fastboot
fuzzy_fastboot causes vts to fail when it has isolated set to true
so manually set it to false to avoid this.

Bug: 178498003
Test: Ran tests that failed presubmit
Change-Id: I871854c26e07ac6ad94feb14703b705a3054c176
2022-04-28 19:30:42 +00:00
Treehugger Robot
a9eee03c56 Merge "sparse_fuzzer: Bug fix" 2022-04-28 12:53:23 +00:00
Elliott Hughes
4ba0e62970 Merge "libutils: clearer abort on overflow." 2022-04-28 00:16:32 +00:00
Elliott Hughes
a5f2e4d421 libutils: clearer abort on overflow.
Let's turn a bug into a feature... Since this code is built with intsan,
anyone who caused overflow here will have had an abort, so we know
no-one actually needs the BAD_INDEX return that was presumably the
original author's intent. So let's just mandate that, since it's a lot
harder to ignore an abort than it is to ignore an error return.

Bug: http://b/179044558
Test: treehugger
Change-Id: I08f1018f9da1e09de885699138b7543d55bb2a36
2022-04-27 14:29:44 -07:00
Lucas Wei
a85c719661 Merge "fastboot: Add vendor_kernel_boot" 2022-04-25 18:31:36 +00:00
Jaegeuk Kim
4669f919a6 Merge "Shutdown f2fs to avoid fsck" 2022-04-25 16:42:48 +00:00
Jooyung Han
0f3f4f402e Merge changes I72a3720c,Idac0d0ef
* changes:
  Migrate compare-bootcharts.py to python3
  Unshare mount namespace in bootchart's thread
2022-04-25 06:31:38 +00:00
Treehugger Robot
ebfdbc7a6c Merge "Remove stale files in /data/misc/virtualizationservice" 2022-04-25 03:27:07 +00:00
Jooyung Han
cee25aa926 Migrate compare-bootcharts.py to python3
Bug: 229983560
Test: system/core/init/compare-bootcharts.py \
          base-bootchart-dir exp-bootchart-dir
Change-Id: I72a3720cb3a80ef8d4fcb06fba8c8893ac08c930
2022-04-25 10:26:08 +09:00
Jooyung Han
7f8721b992 Unshare mount namespace in bootchart's thread
When bootchart is enabled its thread shares the mount namespace context
with the main thread. This prevents the main thread to switch the mount
namespace later with setns().

So, unshare() the mount namespace of the bootchart thread.

Bug: 229983560
Test: rebooted with bootcharting on/off
    enter_default_mount_ns should succeeded.
Change-Id: Idac0d0efcb4f7f7d8a7cbcebf8fa2fa29f104c35
2022-04-25 10:26:07 +09:00