Commit graph

2062 commits

Author SHA1 Message Date
Chih-Hung Hsieh
122352d983 Use -Werror in system/core
* Move -Wall -Werror from cppflags to cflags.
* Fix/suppress warning on unused variables.

Bug: 66996870
Test: build with WITH_TIDY=1
Change-Id: I1e05e96a1d0bcb2ccef1ce456504b3af57167cc5
2017-11-01 11:32:55 -07:00
Tao Wu
ee14225e0d Merge "Fix race condition between restart and stop/reset." 2017-10-27 21:32:51 +00:00
Tao Wu
84b856d901 Fix race condition between restart and stop/reset.
If there is a restart follow a stop/reset immediately or vice versa,
clear previous flag bits.

Test: manual - trigger restart after stop immediately to check if
service get started.

Change-Id: I4503177d7cb5ed054dbcf50cd8e09728415404d4
2017-10-27 11:31:42 -07:00
Tao Wu
876b13d0ec Merge "Fix one race condition between start and stop." 2017-10-26 22:48:51 +00:00
Tao Wu
990d43cb82 Fix one race condition between start and stop.
For a oneshot service, if start happens immediately after stop,
the service could be still in stopping status and then start
won't do anything. This fix this race condition.

Test: manual - see reproduce instructions in bug.
Bug: 68020256
Change-Id: I20202fa346f1949a8bda3d90deedc8b6a6d814d3
2017-10-26 22:08:56 +00:00
Treehugger Robot
03d67dd99e Merge "init: fixed issues related to forking services" 2017-10-26 18:38:23 +00:00
Joe Tanen
4bfdcb3932 init: fixed issues related to forking services
Fixed issues related to forking services into new PID + mount
namespaces.

Remounting rootfs recursively as slave when creating a service in new
PID + mount namespaces. This prevents the service from interfering with
mount points in the parent namespace.

Unmount then mount /proc instead of mounting it with MS_REMOUNT, since
MS_REMOUNT is not sufficient to update /proc to the state appropriate
for the new PID namespace. Note that the /proc mount options specified
here are not the same as those used in the default mount namespace. I
kept them consistent with those used in the code prior to this fix.

Test: Used custom sleepd service to test init 'namespace' keyword.
Tested on angler in oreo-dev - I had to add PID namespaces to the
kernel (commit ad82c662).

Change-Id: I859104525f82fef3400d5abbad465331fc3d732f
2017-10-26 09:08:11 -07:00
Treehugger Robot
0f2097c0f0 Merge "Don't use TEMP_FAILURE_RETRY on close()" 2017-10-24 19:47:20 +00:00
Nick Kralevich
3d118e72dd Don't use TEMP_FAILURE_RETRY on close()
See https://lkml.org/lkml/2005/9/10/129 for details.

Bug: 20501816
Test: code compiles and boots with no obvious problems.
Change-Id: I5a9c470156d498852cfd81fbd59ddcf267309e73
2017-10-24 10:46:34 -07:00
Wei Wang
121ff413ef Merge "init: call umount unconditionally"
am: b409e5e00b

Change-Id: I9eb45b728145301418b9d7775067ce298551f063
2017-10-24 02:13:43 +00:00
Wei Wang
25dc30f3be init: call umount unconditionally
std::all_of is using std::find_if, which means, if any element the given
predicate returns false, it stops further iteration and just returns false.
std::all_of used in Reboot.cpp will cause umount not to be called on all
block devices if some block device returns false in the middle.

Bug: 68158923
Test: reboot
Change-Id: I43ba6bd0c18018c1ed5fe2b63996552bc51cc67c
2017-10-23 16:25:31 -07:00
Tom Cherry
be96bdb09d Merge "init: clean up subcontext_test"
am: 4e2a8e375e

Change-Id: I0ab7401d36d32c5e0df7dc68286117a1ac60d2f8
2017-10-20 14:40:02 +00:00
Tom Cherry
4e2a8e375e Merge "init: clean up subcontext_test" 2017-10-20 14:36:31 +00:00
Steven Moreland
fea6f56069 Merge "init language extension for lazy HIDL services."
am: 0f40200577

Change-Id: I7b42d2b6af8c9d53a7adb97643d040037ab96b00
2017-10-20 06:43:34 +00:00
Treehugger Robot
0f40200577 Merge "init language extension for lazy HIDL services." 2017-10-20 06:38:42 +00:00
Steven Moreland
e055d73396 init language extension for lazy HIDL services.
This associates every service with a list of HIDL services
it provides. If these are disabled, hwservicemanager will
request for the service to startup.

Bug: 64678982
Test: manual with the light service
Change-Id: Ibf8a6f1cd38312c91c798b74574fa792f23c2df4
2017-10-19 20:38:47 -07:00
Tom Cherry
f0b4e4daee Merge "init: add SelabelInitialize() for subcontext"
am: cba7f57119

Change-Id: I0ea0c99c5848aeaa5fd463e347bd76c5b471b7ef
2017-10-20 00:54:39 +00:00
Tom Cherry
0d1452ee1b init: add SelabelInitialize() for subcontext
Children of init that use any of the SELinux wrapper functions,
including make_dir(), mkdir_recursive(), and plenty others, need to
first initialize the sehandle with SelabelInitialize().

I wish there were a better solution, but early init doesn't actually
want this handle initialized, so that is a valid use case.  Ueventd
needs to initialize this before fork()'ing, so lazy initialization is
not universally acceptable either.  Likely we won't have other
children that fork() then exec() init again, so this should be okay.

Bug: 62875318

Test: init unit tests
Test: sailfish creates directories with correct SELabel after wipe
Change-Id: I6de937604a060e18945427418f15b90e0b9d5c37
2017-10-19 16:25:45 -07:00
Tom Cherry
e6d37cdbf9 init: clean up subcontext_test
subcontext_test had been failing due to setexeccon() failing to
transition to vendor_init context.  This is a good thing as nothing
other than init should be able to transition into this context.

I don't want to add code to skip the setexeccon() call only for the
tests, so I instead call setexeccon() with the return value of
getcon().  This works however only for root, so these tests are
skipped for non-root.

Test: init unit tests
Change-Id: I8a415599e0ec5506511202f7f5018c0e5265837d
2017-10-19 16:24:56 -07:00
Tom Cherry
7a23e13edb Merge "init: add extra std::move"
am: d72d92aee2

Change-Id: I928e6f60bd8ffb764ea5f25a81091242efd1f61d
2017-10-19 02:27:32 +00:00
Treehugger Robot
d72d92aee2 Merge "init: add extra std::move" 2017-10-19 02:17:20 +00:00
Tom Cherry
cadc34fd9a Merge "init: wait_for_prop shouldn't run in a subcontext"
am: 6e52973623

Change-Id: I160bedcb91668ccf2b663c36835871d21be2db8b
2017-10-19 00:14:21 +00:00
Tom Cherry
5d7b55bc69 init: add extra std::move
This is meant to be copy-and-move, but I forgot the move.

Test: build
Change-Id: I755ad0d99624dc0ae419ad9ed3ae6d0e017b27c5
2017-10-18 14:52:33 -07:00
Tom Cherry
fa3e52c64a init: wait_for_prop shouldn't run in a subcontext
wait_for_prop sets a flag that prevents the action queue from
continuing while otherwise allowing init's main loop to continue
executing.  This cannot be done from a subcontext, so it's moved to
normal init.

All property functions need work in any case, particularly once
property_service is moved out of init.

Bug: 62875318
Test: boot sailfish and see that the previous failure related to this
      is fixed

Change-Id: Ib9e0d0bdbd0ff22ab0e5c3fe6db620700af266c6
2017-10-18 14:42:27 -07:00
Tom Cherry
9c767212eb Merge "Only allow UTF8 encoded property values"
am: 4ff2607ef7

Change-Id: Ib83ef796bfaaa30dfda36937dfe6be4dac878346
2017-10-17 16:17:21 +00:00
Tom Cherry
8702dcb992 Only allow UTF8 encoded property values
Java already restricts properties to only UTF8 valid strings, and
this change makes this restriction also apply to all native code.

Bug: 63177684
Test: new unit tests
Change-Id: I9fa0ecc0da066b0a026db3497c0f0cbf3f5c2d5a
2017-10-16 22:35:33 +00:00
Tom Cherry
5d40a3372f Merge "Allow setting read-only properties with value length > 92 characters"
am: 96e8042e41

Change-Id: I538a1e415f4a80df29ba7129af479c061948d36f
2017-10-12 16:19:15 +00:00
Tom Cherry
1cf8d699a4 Allow setting read-only properties with value length > 92 characters
Bug: 23102347
Bug: 34954705
Test: read and write properties with value length > 92 characters
Change-Id: Ie196c1fdacc0489508c633e98fe9f4ad7a27dc6e
2017-10-12 02:52:28 +00:00
Mark Salyzyn
cfed5e795a Merge "init+bootstat: reduce last reboot reason to canonical alias"
am: 613a5a97e0

Change-Id: I3217fe94b0b3637521ef3a9f455124155001dd0d
2017-10-10 19:26:14 +00:00
Mark Salyzyn
6290982ee3 init+bootstat: reduce last reboot reason to canonical alias
To make parsing easier for last reboot reason.  This also ensures that
last boot reason matches the content that is typically returned by the
bootloader or in turn landed in the canonical system boot reason.

Simplify parsing in bootstat.  Adjust and fix boot_reason_test.sh for
new reality.  Allow boot reason tests battery and kernel_panic to pass
if device does not support pstore (empty before and after the test).
If device somehow landed in fastboot mode while waiting for the
display, issue a fastboot reboot to move the test along.  Some cleanup
and standardization changes to the test script.

Test: system/core/bootstat/boot_reason_test.sh
Bug: 63736262
Change-Id: I97d5467c0b4a6d65df3525f1a2d0051db813d5ad
2017-10-10 09:37:59 -07:00
Jeffrey Vander Stoep
ceb5dea905 Merge "Allow redeclaring typeattributes"
am: f8bc6cee3f

Change-Id: I119e687a3aaf397ac38365728f6bf9e7c24c1067
2017-10-08 04:08:45 +00:00
Jeffrey Vander Stoep
f8bc6cee3f Merge "Allow redeclaring typeattributes" 2017-10-08 04:02:55 +00:00
Jeff Vander Stoep
5e9ba3c50b Allow redeclaring typeattributes
Allows partners to add a new attribute definition to their public
policy without causing a compatibility failure with the AOSP system
image.

Bug: 67092827
Bug: 37915794
Test: build and boot aosp_sailfish with a new type declared in public
    policy.

Change-Id: I3899065affb6806ae9080e1a7dfa5a6f368370f0
2017-10-06 17:04:28 -07:00
Tom Cherry
2f5b8bb3f0 Merge "init: use ro.init.subcontexts_enabled to enable subcontexts"
am: 99016bce92

Change-Id: If410f650dd67577957d653ecd0b1a1e5a45dd14a
2017-10-06 20:27:05 +00:00
Tom Cherry
79193a42e7 init: use ro.init.subcontexts_enabled to enable subcontexts
As SEPolicy is developed, use this property to enable/disable
subcontexts.

Bug: 62875318
Test: boot device with/without subcontexts
Change-Id: Ieb879836a71c72d4de1bb16514d083d52480bf9a
2017-10-06 10:37:09 -07:00
Jaegeuk Kim
eacc9cd637 Merge "init/reboot: call MNT_FORCE at the last umount(2)"
am: 4e008547be

Change-Id: Ief5e62e385cf83198ad3c9de65131dace0a7c4ae
2017-10-05 20:38:10 +00:00
Jaegeuk Kim
0f04f72c2d init/reboot: call MNT_FORCE at the last umount(2)
The last one will avoid errors=panic in ext4.

Test: Build
Bug: 63981945
Bug: 65481582
Change-Id: I9c86afcce441767e24fc43668ab1ff6230155a9f
Signed-off-by: Jaegeuk Kim <jaegeuk@google.com>
2017-10-04 19:30:49 -07:00
Tom Cherry
5c00898944 Merge "init: log failures if a service cannot start during class_start"
am: 533fbd62ab

Change-Id: I7a05ae9f806a23d04d649fb230e2875633b2caee
2017-10-03 22:42:51 +00:00
Treehugger Robot
533fbd62ab Merge "init: log failures if a service cannot start during class_start" 2017-10-03 22:03:33 +00:00
Tom Cherry
20acdef816 init: log failures if a service cannot start during class_start
Test: boot system with this logging and see appropriate failures
Change-Id: I312dca89f6215afe05b10b2539258a212a0c1ae2
2017-10-03 13:16:00 -07:00
Tom Cherry
71b2c17ba7 Merge "init: fix subcontext SELinux strings"
am: 60bd9ca592

Change-Id: I084da99db1fdc90aa0db276dd5bc755179b83713
2017-10-03 02:05:50 +00:00
Tom Cherry
ac7428b2f5 init: fix subcontext SELinux strings
'object_r' is supposed to be simply 'r'.

Test: boot sailfish with SELinux fully enabled and subcontexts enabled
Change-Id: I7eb8b2dd18e66f23c09863e8961da339f72d25c5
2017-10-02 16:59:02 -07:00
Tom Cherry
821cb5e16c Merge "init: run vendor commands in a separate SELinux context"
am: 8e09b0b953

Change-Id: I7e0272f29bd8bab029a9f9c07aa413c9172f6f5a
2017-10-02 20:40:03 +00:00
Tom Cherry
8e09b0b953 Merge "init: run vendor commands in a separate SELinux context" 2017-10-02 19:48:58 +00:00
Tom Cherry
cb0f9bbc85 init: run vendor commands in a separate SELinux context
One of the major aspects of treble is the compartmentalization of system
and vendor components, however init leaves a huge gap here, as vendor
init scripts run in the same context as system init scripts and thus can
access and modify the same properties, files, etc as the system can.

This change is meant to close that gap.  It forks a separate 'subcontext'
init that runs in a different SELinux context with permissions that match
what vendors should have access to.  Commands get sent over a socket to
this 'subcontext' init that then runs them in this SELinux context and
returns the result.

Note that not all commands run in the subcontext; some commands such as
those dealing with services only make sense in the context of the main
init process.

Bug: 62875318
Test: init unit tests, boot bullhead, boot sailfish

Change-Id: Idf4a4ebf98842d27b8627f901f961ab9eb412aee
2017-09-29 13:06:26 -07:00
Tom Cherry
aceda86059 Merge "init: remove non-protobuf single persistent property file"
am: 61578ab50b

Change-Id: Id4b622ebde1db431d5dcb8cc3edccc6843d4c72b
2017-09-27 20:38:29 +00:00
Tom Cherry
61578ab50b Merge "init: remove non-protobuf single persistent property file" 2017-09-27 20:35:09 +00:00
Mark Salyzyn
387dbf9ab0 Merge "init: report shutdown,container for sigterm of init"
am: d2b5a2417f

Change-Id: Ifb4ab5fa166ee055838c5ad52d69e0d0c07c7e59
2017-09-27 19:40:16 +00:00
Mark Salyzyn
d2b5a2417f Merge "init: report shutdown,container for sigterm of init" 2017-09-27 19:32:31 +00:00
Tom Cherry
9614e4d4d9 init: remove non-protobuf single persistent property file
This has moved to being serialized with libprotobuf.

Test: persistent properties work on bullhead
Test: init unit tests
Change-Id: I26ebe135e37d352f9c53612301bde703144853e7
2017-09-27 18:22:35 +00:00