Commit graph

1156 commits

Author SHA1 Message Date
Jorge Lucangeli Obes
c406474c54 Merge "init: Add support for ambient capabilities."
am: 043bc971f2

Change-Id: I92b7b0f5397e4d938b9c1f1e74aa2145c2297371
2016-11-02 15:52:56 +00:00
Jorge Lucangeli Obes
24b29132a0 init: Add support for ambient capabilities.
Ambient capabilities are inherited in a straightforward way across
execve(2):

"
If you are nonroot but you have a capability, you can add it to pA.
If you do so, your children get that capability in pA, pP, and pE.
For example, you can set pA = CAP_NET_BIND_SERVICE, and your
children can automatically bind low-numbered ports.
"

This will allow us to get rid of the special meaning for AID_NET_ADMIN
and AID_NET_RAW, and if desired, to reduce the use of file capabilities
(which grant capabilities to any process that can execute the file). An
additional benefit of the latter is that a single .rc file can specify
all properties for a service, without having to rely on a separate file
for file capabilities.

Ambient capabilities are supported starting with kernel 4.3 and have
been backported to all Android common kernels back to 3.10.

I chose to not use Minijail here (though I'm still using libcap) for
two reasons:

1-The Minijail code is designed to work in situations where the process
is holding any set of capabilities, so it's more complex. The situation
when forking from init allows for simpler code.

2-The way Minijail is structured right now, we would not be able to
make the required SELinux calls between UID/GID dropping and other priv
dropping code. In the future, it will make sense to add some sort of
"hook" to Minijail so that it can be used in situations where we want
to do other operations between some of the privilege-dropping
operations carried out by Minijail.

Bug: 32438163
Test: Use sample service.
Change-Id: I3226cc95769d1beacbae619cb6c6e6a5425890fb
2016-11-01 19:56:14 -04:00
Nick Kralevich
ba2a810deb Merge "init: Put init in group AID_READPROC"
am: 995560919c

Change-Id: Id2271f8200b020fe5ccaa82e3ea4b68368a6adf1
2016-10-31 19:21:49 +00:00
Treehugger Robot
995560919c Merge "init: Put init in group AID_READPROC" 2016-10-31 19:13:35 +00:00
Wei Wang
fc60c4694c Merge "Fix log for early_mount"
am: fff1669341

Change-Id: I1624e4ac16b6bab7e6aaddb4ef9def01a5c8d15c
2016-10-31 15:10:21 +00:00
Treehugger Robot
fff1669341 Merge "Fix log for early_mount" 2016-10-31 15:04:38 +00:00
Nick Kralevich
80960d2a9a init: Put init in group AID_READPROC
bootcharts currently only show root's processes, which isn't very
useful. To investigate and track boot duration issues, we need a way for
init to see all the pids. Add init to GID 3009 (aka AID_READPROC)

Ensure that init's children don't inherit this GID by always clearing
supplementary group IDs on fork.

Bug: 32506197
Test: Device boots and /proc/1/status says init is in gid 3009
Test: zygote starts and the Group: line in /proc/ZYGOTEPID/status is empty
Change-Id: Iba90717aaa591f1d6030a379a272aee003600c0a
Not-Tested: bootchart actually works. Speculative fix.
2016-10-29 12:20:00 -07:00
Wei Wang
313b352382 Fix log for early_mount
Test: on device
Bug: 32508724
Change-Id: Ib2908b19f6068012d5597ac4cc590ffb0c063b75
2016-10-28 18:05:36 -07:00
Elliott Hughes
62fd68bb47 Merge "Log when bootcharting ends."
am: cd368c640a

Change-Id: I39e25bb450d601084f5d88d72934d319607a76d9
2016-10-29 00:35:07 +00:00
Elliott Hughes
5ee97e8ec0 Log when bootcharting ends.
Bug: http://b/26863004
Test: bootcharted N9
Change-Id: Ie91a4342d05ac5e7b6a8d37fa729edf36c38912b
2016-10-28 12:30:32 -07:00
Iliyan Malchev
8ef815de68 Merge "init: allow '.' and '@' in service names"
am: d879e0c750

Change-Id: Ib6064fff33f31905c9f2a0b3dc46ac87f29edcf1
2016-10-26 17:36:36 +00:00
Iliyan Malchev
f655480b48 init: allow '.' and '@' in service names
Services implementing HIDL HALs must be named the same as the HIDL
package, e.g. android.hardware.nfc@1.0.  Allow init to accept names
containing '.' and '@'.

Also combined logic for legal property names and legal service names.

Bug: 31458381
Bug: 32109611
Test: Tested creating service nfc@1.0-service which creates property
'init.svc.nfc@1.0-service' with and without this change. This service
successfully started only with this change.

Change-Id: Ie7a4310742bc03498d774d37b3b5fafa7c6068cc
Signed-off-by: Iliyan Malchev <malchev@google.com>
2016-10-26 08:46:24 -07:00
Iliyan Malchev
6b03c273b1 Merge "init: account for "init.svc." prefix in IsValidName"
am: 8cf0bd75f7

Change-Id: I41c9d2472412a4b4cafb23a39598ea0e31619629
2016-10-24 17:38:21 +00:00
Iliyan Malchev
00860da2f0 init: account for "init.svc." prefix in IsValidName
For each service ${service} described in a .rc file, init creates the
property init.svc.${service}.  This implies that service-name lengths
are bound by the maximum size of a property.  This patch accounts for
the "init.svc." prefix and the maximum property-name length when
validating a service name.

Test: pass

Change-Id: I32dffa37363b41a8211f7644600b81973d30a3b2
Signed-off-by: Iliyan Malchev <malchev@google.com>
2016-10-24 08:46:06 -07:00
Yabin Cui
1051e107f2 init: use libbootloader_message.
Bug: 29582118
Change-Id: I6285b29774a11d6dda8496c7c73e4c1d17a672bd
(cherry picked from commit 0b1252cca0)
2016-10-18 11:37:52 -07:00
Elliott Hughes
7948a33f2c resolve merge conflicts of a4398c1 to stage-aosp-master am: 195669febc
am: b2ab1c43cb

Change-Id: I412943235ad6cd908aca04c56aa19a3d2bbb5413
2016-10-14 02:55:55 +00:00
Elliott Hughes
da46b392f1 Move off std::sto* function which abort on failure.
Bug: http://b/31403370
Test: builds, boots, libbase tests pass
Change-Id: I89cd7ca3d8f1c8a1bad0ddf3043439449d19a293
2016-10-13 15:34:05 -07:00
Tao Bao
6efc7a787b Merge "Update the header path for ext4_utils." am: 5bc3ce85cf am: 148b85b050
am: 2815ac5584

Change-Id: I966296de6eb4ff7518b9cfcd5853fe919765b826
2016-10-10 22:14:48 +00:00
Glenn Kasten
af97f66b59 Merge "Traverse /etc/init in a well-defined order" am: db7715c7dd am: 31dcb81e63
am: 010624bd2c

Change-Id: Ie8c3467d5bb286bbdacb8479c62d2f52fef246df
2016-10-09 17:26:37 +00:00
Tao Bao
6d881d6db4 Update the header path for ext4_utils.
Test: `mmma system/core`

Change-Id: I6291d10d6c8d4972aeca55596baa83f555496193
2016-10-09 10:23:36 -07:00
Glenn Kasten
2de796491a Traverse /etc/init in a well-defined order
Bug: 31996208
Test: will need a CTS, not yet done
Change-Id: I5ecc7f0519d42a83065b7b97a31cdb5b33549cda
2016-10-07 13:56:37 -07:00
Wei Wang
46a59f8e07 Merge "Modify log level for service and ueventd" am: 891d0ba904 am: 42335b04b4
am: 06515d3231

Change-Id: Ie15a869062ef43f1c4ef2fb1540836971fa23363
2016-10-05 04:42:16 +00:00
Wei Wang
a285dac9c0 Modify log level for service and ueventd
Bug: 31938558
Test: flash and take a boot log
Change-Id: I5c6823614e1df760128519dfb294f3a44efa6bac
2016-10-04 14:50:48 -07:00
Elliott Hughes
5c54bb548a Merge "Log failed load_properties_from_file calls." am: 57513bd5a3 am: 9abb85ebe0
am: 6d60731271

Change-Id: I603025e42824e11817042d98ad7a7387b83fe99c
2016-10-01 01:23:18 +00:00
Elliott Hughes
5a7ad84ede Log failed load_properties_from_file calls.
These events are _somewhat_ normal, in that not all devices have all
partitions, but not logging anything makes it unnecessarily hard for
folks to debug simple failures.

Bug: http://b/31186390
Test: booted, checked dmesg
Change-Id: I403377c585ea35cfe73b0bed9443b75e3a84dc8d
2016-09-30 16:30:00 -07:00
Wei Wang
d61a7e2da4 Split fstab mount into 2 phases
This will make it possible to start some key services before mounting
data partition

Bug: 30118894
Change-Id: Ia9f8cc035de6cc0df9a61605864915efa0266d7f
(cherry picked from commit abfbec342f)
2016-09-06 21:04:26 +00:00
Wei Wang
254f44363b Split fstab mount into 2 phases
This will make it possible to start some key services before mounting
data partition

(cherry picked from commit abfbec342f)

Bug: 30118894
Change-Id: Ia9f8cc035de6cc0df9a61605864915efa0266d7f
2016-09-06 11:39:05 -07:00
Elliott Hughes
87e43e1627 Merge "Use android::base::Readlink in init." am: 31ea86327e am: 72887a3ff4
am: 0a2148e34d

Change-Id: Ifcd35961c8bf6e5a34f70dbf1717190a519f0b3b
2016-09-02 19:46:38 +00:00
Treehugger Robot
31ea86327e Merge "Use android::base::Readlink in init." 2016-09-02 19:37:02 +00:00
Marco Nelissen
558217ed43 Merge "Allow setting oom_score_adj for services spawned from init" am: b7aef300c4 am: 5969a3f780
am: 25e26708f6

Change-Id: I55c46391eb357a84fb9f1afc66227ef90a82d30b
2016-09-02 14:59:25 +00:00
Josh Gao
fe64538014 Merge "Revert "init: create /dev/urandom, /dev/random in first stage."" am: 37686d446d am: 8196f4cdd9
am: 1181a4a54c

Change-Id: Ib1080f9749ebca0aa7eb73380b1903d170b918bd
2016-09-02 08:52:05 +00:00
Josh Gao
4c8a76e250 Revert "init: create /dev/urandom, /dev/random in first stage."
This reverts commit ab4fbe1b4f.

Bug: http://b/31251721
Change-Id: I43e68d1bd819d0f9f7d107865a33ec892975d956
2016-09-02 08:39:39 +00:00
Josh Gao
b093053868 Merge "init: create /dev/urandom, /dev/random in first stage." am: 9baf4e94fa am: 344e2b307b
am: b9cd3c2213

Change-Id: Ief1121d9e0c8161dd975b9a9f4ce33fb0313cecf
2016-09-01 23:08:30 +00:00
Marco Nelissen
310f6704d0 Allow setting oom_score_adj for services spawned from init
(cherry picked from commit f7adf8e4739812a2a4f194b17f84f4b9df42d04b)

Bug: 29831602
Change-Id: I4d24264bb6e879935a0b2adbb2e49ddf458980cf
2016-09-01 08:23:28 -07:00
Josh Gao
ab4fbe1b4f init: create /dev/urandom, /dev/random in first stage.
Create /dev/random and /dev/urandom in the first stage, so that when we
reexec, arc4random is available for libc initialization.

Bug: http://b/29622562
Change-Id: I5b2071539a17eec609faac91dc28b08eba5ff89b
2016-08-31 15:36:37 -07:00
Elliott Hughes
f39f7f1428 Use android::base::Readlink in init.
Bug: http://b/30988271
Change-Id: Ia0000e9dd7883c31ccbd54fc01bf585c3f8b3fa7
2016-08-31 14:44:41 -07:00
Jorge Lucangeli Obes
6ccc8323b2 Merge "Add description of 'namespace' option." am: 4588ed7b5f am: 52807711fe
am: ce44aa8487

Change-Id: Ib2ef76efd778706992057d8ecbc868e1a1bf65c5
2016-08-31 21:11:18 +00:00
Jorge Lucangeli Obes
cd2518c19c Add description of 'namespace' option.
Bug: None
Change-Id: Ib71005eb9823c7511b07d4060d08411ce3d0a8f0
2016-08-31 15:23:44 -04:00
Elliott Hughes
0426ecaf82 Merge "Most accept/accept4 calls in system/core don't actually want the remote address." am: 299d64144b am: 8615d79d85
am: 66e5e2432a

Change-Id: I5d7b98fa3e9c2d8c16a1aa73e3d5a197dc150c2b
2016-08-23 23:14:44 +00:00
Elliott Hughes
8615d79d85 Merge "Most accept/accept4 calls in system/core don't actually want the remote address."
am: 299d64144b

Change-Id: I3fb9678dfed08f0b1d6e90e547ecae6cdcabc9a1
2016-08-23 23:03:20 +00:00
Elliott Hughes
3dcfa3fb1c Most accept/accept4 calls in system/core don't actually want the remote address.
So don't write the extra code for it or waste the kernel's time
copying it around.

Change-Id: I93de64064c2d4fe58ba5b5322cfa69bf31a76dad
2016-08-23 12:50:00 -07:00
Hung-ying Tyan
1263097328 Merge "Mount /vendor and /odm early" am: 35569e9d68 am: 46bfc918d0
am: d1f49a43fd

Change-Id: I6dc53f60771ad0e660e248efdc1b13734fba3061
2016-08-18 05:10:41 +00:00
Hung-ying Tyan
46bfc918d0 Merge "Mount /vendor and /odm early"
am: 35569e9d68

Change-Id: I9b5360bf3036fa88e770d686ab06b8f4cff80d7c
2016-08-18 05:04:43 +00:00
Hung-ying Tyan
99c4a8a6b3 Mount /vendor and /odm early
Right now these two partitions are mounted in the fs stage of the init
process. As a result, many vendor/ODM files needed earlier in the boot
process (e.g., init.<hardware>.rc, fstab.<hardware>.rc,
uevent.<hardware>.rc, SELinux policy files etc) can only live on the root
partition.

To prevent vendors/ODMs from polluting the root partition, this patch makes
it possible to mount the vendor and ODM partitions in the first stage of the
init process. The fstab info of both partitions to be mounted early is
composed from new kernel cmdline arguments android.early.prefix and
android.early.fstab.

For example, with:
android.early.prefix=/sys/devices/1010000.msdc0/mmc_host/mmc0/mmc0:0001/block/mmcblk0/
android.early.fstab=mmcblk0p10+/odm+ext4+ro+verify\nmmcblk0p09+/vendor+ext4+ro+verify

the final fstab string will be:
/sys/devices/1010000.msdc0/mmc_host/mmc0/mmc0:0001/block/mmcblk0/mmcblk0p10 /odm ext4 ro verify
/sys/devices/1010000.msdc0/mmc_host/mmc0/mmc0:0001/block/mmcblk0/mmcblk0p09 /vendor ext4 ro verify

The android.early.prefix is optional. When it is missing, the final fstab
string will be directly converted from android.early.fstab.

This patch also makes sure that the early mounted partitions are dm-verity
enabled so that they are trust worthy to store system files.

BUG=27805372

Change-Id: I3cf32482a5ec65445ba3aedab2164c7ba8f12694
2016-08-17 17:21:35 +08:00
Josh Gao
7480771909 Merge "libcrypto_utils: convert to Soong." am: c1a9a21ffe am: 87ef590bc1
am: a1da027a3c

Change-Id: Ie693d3de13b0df24ea83e70af3fa385a77ed8b33
2016-08-08 18:39:23 +00:00
Josh Gao
87ef590bc1 Merge "libcrypto_utils: convert to Soong."
am: c1a9a21ffe

Change-Id: I9cf76646d4537750c4d4080234d3384fb307e610
2016-08-08 18:33:49 +00:00
Josh Gao
c1a9a21ffe Merge "libcrypto_utils: convert to Soong." 2016-08-08 18:29:10 +00:00
Josh Gao
47763c3a09 libcrypto_utils: convert to Soong.
Bug: http://b/30708454
Change-Id: Iaad64272ced766f87e67f2877e990afccc558065
2016-08-05 18:07:36 -07:00
Elliott Hughes
3ad2ffc474 Move init's kernel logging into libbase. am: 7bc87a5a78 am: e2a7eb17b5
am: b7252fc35a

Change-Id: Ibfba937cede98ceb8f4b76d3a636e5b8035689c0
2016-08-05 00:35:29 +00:00
Elliott Hughes
e2a7eb17b5 Move init's kernel logging into libbase.
am: 7bc87a5a78

Change-Id: Ie5e359e8bd7dee4c0549072c7e955eeefe57d785
2016-08-05 00:30:00 +00:00