Commit graph

1775 commits

Author SHA1 Message Date
Tom Cherry
2afdb6d526 Merge "init: reap zombies only after kill(-pid, ...)" am: a51c40ce35 am: 0924b32c1f am: 419a9ef8f1
am: fc479afbb6

Change-Id: Id45511f512fce014de32cc4d642df4cdcf5634c3
2017-07-06 00:20:08 +00:00
Tom Cherry
fc479afbb6 Merge "init: reap zombies only after kill(-pid, ...)" am: a51c40ce35 am: 0924b32c1f
am: 419a9ef8f1

Change-Id: I0f2e6b2b2dfed4dab480acf2562df78da8d2f65e
2017-07-05 23:37:21 +00:00
Tom Cherry
419a9ef8f1 Merge "init: reap zombies only after kill(-pid, ...)" am: a51c40ce35
am: 0924b32c1f

Change-Id: I18a3c9a9a96a2488c7714113175f3e8115bd697f
2017-07-05 23:01:35 +00:00
Tom Cherry
0924b32c1f Merge "init: reap zombies only after kill(-pid, ...)"
am: a51c40ce35

Change-Id: I4f1b7a05cdff1fe7851b528d0bdeda354011b599
2017-07-05 22:50:17 +00:00
Jin Qian
3ca00a3c98 Merge "init: rename mke2fs tools with _static suffix" into oc-dr1-dev
am: 5c5c544e80

Change-Id: Ifee5b6516fe3aee03df845a46421753295cbc740
2017-07-05 22:40:42 +00:00
Tom Cherry
a51c40ce35 Merge "init: reap zombies only after kill(-pid, ...)" 2017-07-05 22:39:51 +00:00
TreeHugger Robot
5c5c544e80 Merge "init: rename mke2fs tools with _static suffix" into oc-dr1-dev 2017-07-05 22:33:35 +00:00
Nick Kralevich
1d4647b4ce Merge "Remove unnecessary SELinux dependencies" am: 22de50d351 am: e9b9b10c58 am: 0056e6bccc
am: 4192d74a83

Change-Id: I6d1cfcbfa98881fb24a516646f030d451fa357ee
2017-07-01 16:54:36 +00:00
Nick Kralevich
4192d74a83 Merge "Remove unnecessary SELinux dependencies" am: 22de50d351 am: e9b9b10c58
am: 0056e6bccc

Change-Id: Id160e23a6bd53238ad279bb5b28e7ca8a08c0805
2017-07-01 16:49:35 +00:00
Nick Kralevich
0056e6bccc Merge "Remove unnecessary SELinux dependencies" am: 22de50d351
am: e9b9b10c58

Change-Id: Ifead418ceb9fe806d76102d9068a32539a8b99d0
2017-07-01 16:44:36 +00:00
Nick Kralevich
e9b9b10c58 Merge "Remove unnecessary SELinux dependencies"
am: 22de50d351

Change-Id: Icbd6b0df4378980eb2a7878bab1896f6ecefb6a8
2017-07-01 16:39:37 +00:00
Nick Kralevich
33391dad15 Remove unnecessary SELinux dependencies
These are unused.

Test: code compiles.
Change-Id: Idd707dfcc8f6daac3a489c791ecc364841cf31f9
2017-07-01 07:41:48 -07:00
Luis Hector Chavez
9ba4038c79 Merge "init: Read previous state of securebits before modifying" am: c10e14110a am: 19f32317b3 am: 9dabbbaa6a
am: dd79958ecb

Change-Id: Ic053669c2e3c576a27b1ee4748c635c338068105
2017-07-01 00:45:12 +00:00
Luis Hector Chavez
dd79958ecb Merge "init: Read previous state of securebits before modifying" am: c10e14110a am: 19f32317b3
am: 9dabbbaa6a

Change-Id: Id5cdc260c7f6800e493c0f3b4e0da08ddca34b63
2017-07-01 00:39:42 +00:00
Luis Hector Chavez
9dabbbaa6a Merge "init: Read previous state of securebits before modifying" am: c10e14110a
am: 19f32317b3

Change-Id: I87084032373a71b507ed0604c7ff38ec076fc74a
2017-07-01 00:35:11 +00:00
Luis Hector Chavez
19f32317b3 Merge "init: Read previous state of securebits before modifying"
am: c10e14110a

Change-Id: I0a9b2dc97ebbc449288de2ce3e2745a1f60a4372
2017-07-01 00:30:42 +00:00
Luis Hector Chavez
f5965519d1 init: Read previous state of securebits before modifying
When Android is running in a container, some of the securebits might be
locked, which makes prctl(PR_SET_SECUREBITS) fail.

This change gets the previous state of the process' securebits and adds
the desired bits.

Bug: 62388055
Test: aosp_bullhead-eng boots
Test: If init has non-zero securebits, it can also boot
Change-Id: Ie03bf2538f9dca40955bc58314d269246f5731bd
2017-06-30 14:42:46 -07:00
Tom Cherry
8d13d808a5 init: reap zombies only after kill(-pid, ...)
When init gets SIGCHLD, it uses waitpid() to get the pid of an exited
process.  It then calls kill(-pid, ...) to ensure that all processes
in the process group started by that process are killed as well.

There is a bug here however as waitpid() reaps the pid when it
returns, meaning that the call to kill(-pid, ...) may fail with ESRCH
as there are no remaining references to that pid.  Or worse, if the
pid is reused, the wrong processes may get the signal.

This fixes the bug by using waitid() with WNOWAIT to get the pid of an
exited process, which does not reap the pid.  It then uses waitpid()
with the returned pid to do the reap only after the above kill(-pid,
...) and other operations have completed.

Bug: 38164998
Test: kill surfaceflinger and see that processes exit and are reaped
      appropriately
Test: `adb reboot` and observe that the extraneous kill() failed
      messages do not appear

Change-Id: Ic0213e1c97e0141e6c13129dc2abbfed86de138b
2017-06-30 13:52:48 -07:00
Luis Hector Chavez
ea8ac69141 Merge changes I0a95f87a,I36b22986 am: a703202093 am: 835d259e7a am: 40e88b22f2
am: 1b42dbf22c

Change-Id: Icf60412199db65e686c2f3b38087d0fc66cad7f6
2017-06-30 04:38:03 +00:00
Luis Hector Chavez
1b42dbf22c Merge changes I0a95f87a,I36b22986 am: a703202093 am: 835d259e7a
am: 40e88b22f2

Change-Id: I04e3d91d34d2c50d15ab2357db175b1f69796af1
2017-06-30 04:33:30 +00:00
Luis Hector Chavez
40e88b22f2 Merge changes I0a95f87a,I36b22986 am: a703202093
am: 835d259e7a

Change-Id: I329bddc9b470da86d07bde3ce3ab8a69c37a38e2
2017-06-30 04:29:28 +00:00
Luis Hector Chavez
835d259e7a Merge changes I0a95f87a,I36b22986
am: a703202093

Change-Id: Id0ab2a68ade41db6c1327d9b96489bf0f9a223cb
2017-06-30 04:24:32 +00:00
Luis Hector Chavez
7bb360230d init: Use ScopedCaps for cap_init()
This change homogenizes the use of std::unique_ptr for storing
capabilities in system/core/.

Bug: None
Test: m
Change-Id: I0a95f87a27b0261e9d321841d5140fc000473293
2017-06-29 14:41:23 -07:00
Luis Hector Chavez
519e5f0592 init: Reland "Terminate gracefully when CAP_SYS_BOOT is absent"
This change makes it possible for Android running in a container to
terminate cleanly instead of calling abort() when requested to shut
down.

Bug: 62388055
Test: `adb reboot` on bullhead causes no kernel panics
Test: `adb reboot` on a system without CAP_SYS_BOOT makes init terminate
       nicely

Change-Id: I36b2298610f5b4a2bf8b05103d04804883df2c88
2017-06-29 14:41:23 -07:00
Hung-ying Tyan
0c6a19657d Merge "Load default prop from /system/etc/prop.default" into oc-dr1-dev am: d334d69b70
am: 42388236a4

Change-Id: Ie8d1f695eac185e1be21073ecd3e40c0e8212d13
2017-06-28 06:34:43 +00:00
Hung-ying Tyan
42388236a4 Merge "Load default prop from /system/etc/prop.default" into oc-dr1-dev
am: d334d69b70

Change-Id: I358c9b60bf20d7852d81006bb37a9efab0dd19ad
2017-06-28 06:31:08 +00:00
TreeHugger Robot
d334d69b70 Merge "Load default prop from /system/etc/prop.default" into oc-dr1-dev 2017-06-28 06:28:09 +00:00
Guang Zhu
806f2ed9be Merge "Revert "init: Terminate gracefully when CAP_SYS_BOOT is absent"" am: b5b4136ac4 am: aa447d7aa5 am: 3734cd3442
am: 387f28c18a

Change-Id: Id00c27b2d10743e0a19a6bfb8da85aa2e2c3f622
2017-06-28 02:33:21 +00:00
Guang Zhu
387f28c18a Merge "Revert "init: Terminate gracefully when CAP_SYS_BOOT is absent"" am: b5b4136ac4 am: aa447d7aa5
am: 3734cd3442

Change-Id: I5dc1e8c2ad06b162e3971aa2385dc7c00d5a37d0
2017-06-28 02:29:19 +00:00
Guang Zhu
aa447d7aa5 Merge "Revert "init: Terminate gracefully when CAP_SYS_BOOT is absent""
am: b5b4136ac4

Change-Id: Icd0a76aeb770cec04c029d30114bb3cf645a850c
2017-06-28 02:22:49 +00:00
Guang Zhu
c22f93856f Revert "init: Terminate gracefully when CAP_SYS_BOOT is absent"
Bug: 63080844

This reverts commit 683ebc8059.

Change-Id: I6074ff09300fd30bfc66881ded1c4f868a845a91
2017-06-28 02:10:33 +00:00
Luis Hector Chavez
0333dedbc0 Merge "init: Terminate gracefully when CAP_SYS_BOOT is absent" am: fbb482f499 am: ec8a5f2aa6 am: 6d815a554d
am: e955adacb7

Change-Id: Ieb254ee9aaf629935fc9207ea14b086f7a8edbe5
2017-06-27 23:12:40 +00:00
Luis Hector Chavez
e955adacb7 Merge "init: Terminate gracefully when CAP_SYS_BOOT is absent" am: fbb482f499 am: ec8a5f2aa6
am: 6d815a554d

Change-Id: I1ca1bb153b3e3725f695107d56cc36a54a0379f1
2017-06-27 23:07:18 +00:00
Luis Hector Chavez
ec8a5f2aa6 Merge "init: Terminate gracefully when CAP_SYS_BOOT is absent"
am: fbb482f499

Change-Id: I7cff66250e7f5d0b9d55feb2ddb6d74608aa4dd9
2017-06-27 23:01:19 +00:00
Luis Hector Chavez
683ebc8059 init: Terminate gracefully when CAP_SYS_BOOT is absent
This change makes it possible for Android running in a container to
terminate cleanly instead of calling abort() when requested to shut
down.

Bug: 62388055
Test: setprop sys.powerctl reboot makes init terminate nicely

Change-Id: I31c7b475d89d7cbd665e135d9b8951dfd4bca80d
2017-06-27 13:51:46 -07:00
Jin Qian
5eb6e5bd73 init: rename mke2fs tools with _static suffix
We build a static version for recovery mode. Give them
different names to avoid conflicts with regular version
in /system/bin/

Bug: 35219933
Change-Id: I738655ad9b9ad71c63ae604d9a4d659b0b671121
Merged-In: I738655ad9b9ad71c63ae604d9a4d659b0b671121
2017-06-26 17:15:15 -07:00
Hung-ying Tyan
aef2b092f5 Load default prop from /system/etc/prop.default
/default.prop is moved to /system/etc/prop.default for full Treblized
devices. Modifies property_service to load it from there first.
In recovery mode, the file is renamed as /prop.default. This path is
tried if /system/etc/prop.default is not available.

Bug: 37815285
Test: Tested with ag/2419001. Booted pixel phones, checked the location
      of prop.default, verified the symlink at /default.prop, checked a
      few properties via adb shell and manually tested a few apps.
      Booted to recovery and ran 'adb sideload' successfully.
Change-Id: I485231f21fc86b0aec58edf867e229a31e77d85e
Merged-In: I485231f21fc86b0aec58edf867e229a31e77d85e
(cherry-picked from 527d80d945)
2017-06-26 01:33:59 +00:00
Bowgo Tsai
1773266f95 AVB: allow no metadata in the generic system.img for project Treble
The generic system.img released from project Treble can't contain any verity
metadata (e.g., vboot 1.0, AVB, or any other implementation) because it's
*generic*. To make any device can boot with it, `avbctl disable-verification`
is introduced to set a new flag AVB_VBMETA_IMAGE_FLAGS_VERIFICATION_DISABLED
in the top-level vbmeta to disable the entire AVB verification process. This
should be done prior to flash the generic system.img. See the following link
for details:

    https://android-review.googlesource.com/#/c/418399/

This CL checks whether AVB_VBMETA_IMAGE_FLAGS_VERIFICATION_DISABLED is
set in the top-level vbmeta. When set, skip verifying the vbmeta structs
against androidboot.vbmeta.{hash_alg, size, digest} because it will be
absent in kernel cmdline. Also, only top-level vbmeta struct is read then
returned by libavb in this case.

Note that another flag AVB_VBMETA_IMAGE_FLAGS_HASHTREE_DISABLED, usually
set by `adb disable-verity`, is used to signal fs_mgr to skip setting up
dm-verity, but libavb still verifies all vbmeta structs. fs_mgr will
also verify all vbmeta structs against androidboot.vbmeta.{hash_alg,
size, digest} from kernel cmdline as well.

Also rename SetUpAvb() to SetUpAvbHashtree() to better fit its usage.
This function will return kDisabled when any of the above two flags is set.

Finally, regardless of which flag is set or not set, we still only allow two
return values from avb_slot_verify():

   - AVB_SLOT_VERIFY_RESULT_OK: it's still possible to get this value
     when any of these flags are set in build time. e.g.,
     BOARD_AVB_MAKE_VBMETA_IMAGE_ARGS=--flags 2

   - AVB_SLOT_VERIFY_RESULT_ERROR_VERIFICATION: in most cases we should
     get this value, because the flags are likely set at run time.

Bug: 62523303
Test: boot device with 'avbctl disable-verification'.
Test: boot device with 'avbctl enable-verification'.
Test: boot device with 'adb disable-verity'.
Test: boot device with 'adb enable-verity'.

Test: build image with BOARD_AVB_MAKE_VBMETA_IMAGE_ARGS=--flags 2, then boot device.
      repeat the above steps to boot device again.

Merged-In: Ie8436f3e0e82c78490208f3b85eac5238a9fdfdb
Change-Id: Ie8436f3e0e82c78490208f3b85eac5238a9fdfdb
(cherry picked from commit 60f19a0792)
2017-06-24 10:01:32 +08:00
Bowgo Tsai
8ee91bf77c Merge "AVB: allow no metadata in the generic system.img for project Treble" am: c70bf5836c am: caa5b4417f am: 2410d0c792
am: 61cdb66230

Change-Id: I23cdb0a5826f3378245375c5f5551aa46edd8536
2017-06-24 01:54:51 +00:00
Bowgo Tsai
61cdb66230 Merge "AVB: allow no metadata in the generic system.img for project Treble" am: c70bf5836c am: caa5b4417f
am: 2410d0c792

Change-Id: I5b03a7ac1cdb883df27aca8122c4a1383d805126
2017-06-24 01:51:47 +00:00
Bowgo Tsai
2410d0c792 Merge "AVB: allow no metadata in the generic system.img for project Treble" am: c70bf5836c
am: caa5b4417f

Change-Id: I4859e15d3bf05c22a708761e91b2e52fbb28ca1f
2017-06-24 01:40:33 +00:00
Treehugger Robot
c70bf5836c Merge "AVB: allow no metadata in the generic system.img for project Treble" 2017-06-24 01:28:25 +00:00
Bowgo Tsai
60f19a0792 AVB: allow no metadata in the generic system.img for project Treble
The generic system.img released from project Treble can't contain any verity
metadata (e.g., vboot 1.0, AVB, or any other implementation) because it's
*generic*. To make any device can boot with it, `avbctl disable-verification`
is introduced to set a new flag AVB_VBMETA_IMAGE_FLAGS_VERIFICATION_DISABLED
in the top-level vbmeta to disable the entire AVB verification process. This
should be done prior to flash the generic system.img. See the following link
for details:

    https://android-review.googlesource.com/#/c/418399/

This CL checks whether AVB_VBMETA_IMAGE_FLAGS_VERIFICATION_DISABLED is
set in the top-level vbmeta. When set, skip verifying the vbmeta structs
against androidboot.vbmeta.{hash_alg, size, digest} because it will be
absent in kernel cmdline. Also, only top-level vbmeta struct is read then
returned by libavb in this case.

Note that another flag AVB_VBMETA_IMAGE_FLAGS_HASHTREE_DISABLED, usually
set by `adb disable-verity`, is used to signal fs_mgr to skip setting up
dm-verity, but libavb still verifies all vbmeta structs. fs_mgr will
also verify all vbmeta structs against androidboot.vbmeta.{hash_alg,
size, digest} from kernel cmdline as well.

Also rename SetUpAvb() to SetUpAvbHashtree() to better fit its usage.
This function will return kDisabled when any of the above two flags is set.

Finally, regardless of which flag is set or not set, we still only allow two
return values from avb_slot_verify():

   - AVB_SLOT_VERIFY_RESULT_OK: it's still possible to get this value
     when any of these flags are set in build time. e.g.,
     BOARD_AVB_MAKE_VBMETA_IMAGE_ARGS=--flags 2

   - AVB_SLOT_VERIFY_RESULT_ERROR_VERIFICATION: in most cases we should
     get this value, because the flags are likely set at run time.

Bug: 62523303
Test: boot device with 'avbctl disable-verification'.
Test: boot device with 'avbctl enable-verification'.
Test: boot device with 'adb disable-verity'.
Test: boot device with 'adb enable-verity'.

Test: build image with BOARD_AVB_MAKE_VBMETA_IMAGE_ARGS=--flags 2, then boot device.
      repeat the above steps to boot device again.

Change-Id: Ie8436f3e0e82c78490208f3b85eac5238a9fdfdb
2017-06-24 09:20:15 +08:00
Tom Cherry
6b6d4834b0 Merge "init: create android::init:: namespace" am: 040212706b am: d3d79b2196 am: b57e1180e3
am: 99d93f4462

Change-Id: If8efbff1df7bead15a9f3c595e63390d9786dde7
2017-06-23 23:28:53 +00:00
Tom Cherry
99d93f4462 Merge "init: create android::init:: namespace" am: 040212706b am: d3d79b2196
am: b57e1180e3

Change-Id: Ic6d35273820d70136a6085bf49dcf3afcbb24f24
2017-06-23 23:24:21 +00:00
Tom Cherry
b57e1180e3 Merge "init: create android::init:: namespace" am: 040212706b
am: d3d79b2196

Change-Id: I3dccff251dda7d7452e33a7e71178c59f0c22169
2017-06-23 23:19:53 +00:00
Jeff Vander Stoep
e8bd9e88b5 Merge "Revert "crash_dump: during early boot, output to kmsg on userdebug."" into oc-dr1-dev am: 75a32dead5
am: d47d328b41

Change-Id: I54ccbffab33e03df978b8ab5e42daee41c87d418
2017-06-23 23:13:10 +00:00
Jeff Vander Stoep
d47d328b41 Merge "Revert "crash_dump: during early boot, output to kmsg on userdebug."" into oc-dr1-dev
am: 75a32dead5

Change-Id: Ia893832c1428858afd8d8726a789a5989dafa9a0
2017-06-23 23:01:27 +00:00
TreeHugger Robot
75a32dead5 Merge "Revert "crash_dump: during early boot, output to kmsg on userdebug."" into oc-dr1-dev 2017-06-23 22:45:48 +00:00
Jeff Vander Stoep
5fdc4cc746 Revert "crash_dump: during early boot, output to kmsg on userdebug."
This reverts commit bf2dd48241.

Addresses:
avc: denied { relabelto } for name="kmsg_debug" dev="tmpfs" ino=10642
scontext=u:r:init:s0 tcontext=u:object_r:device:s0 tclass=chr_file

Bug: 62101480, 35197529
Test: build and boot device. Verify selinux denial no longer occurs.
Change-Id: I28ce16f50eec20ef15c1721f41b66f22a84e7cca
2017-06-23 13:37:54 -07:00