Commit graph

1335 commits

Author SHA1 Message Date
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
Elliott Hughes
7bc87a5a78 Move init's kernel logging into libbase.
This will let other stuff (such as adbd and recovery) use it too.

Bug: http://b/28467098
Change-Id: Idab51f438ed3edd6fe65a56c4b396eaff5f3833e
2016-08-04 16:09:39 -07:00
Elliott Hughes
54c7d892a1 Merge "Have init kill the process group." am: 9a5300fcb8 am: 963de55342
am: cb647e9318

Change-Id: I4e100673a6104adee4a2414fd694fd350013b934
2016-08-02 23:15:03 +00:00
Elliott Hughes
963de55342 Merge "Have init kill the process group."
am: 9a5300fcb8

Change-Id: I692c5fabfaea39e7ed6c9de5f6ad245330e3442c
2016-08-02 23:10:29 +00:00
Elliott Hughes
1e73024653 Have init kill the process group.
killProcessGroup actually works on cgroups. Kill the POSIX process
group ourselves.

Bug: http://b/29751426
Change-Id: I1a2808488510f4262811b6407bcd0948ad23bc60
2016-08-02 14:20:40 -07:00
Chih-Hung Hsieh
b143c9708c resolve merge conflicts of d072ed3 to nyc-mr1-dev-plus-aosp
Change-Id: Ifdd67548e252fcd73833a9d017aa8205bf749f70
2016-08-01 13:44:54 -07:00
Chih-Hung Hsieh
4c4fa90462 Merge \"Fix clang-tidy performance warnings in syste/core.\"
am: 4efbce14b5

Change-Id: I84f6b0134fae6e9f40710f243f4825e3f31fa15f
2016-08-01 20:23:10 +00:00
Treehugger Robot
4efbce14b5 Merge "Fix clang-tidy performance warnings in syste/core." 2016-08-01 20:13:54 +00:00
Chih-Hung Hsieh
8f7b9e3d39 Fix clang-tidy performance warnings in syste/core.
* Use const reference type for parameters to avoid unnecessary copy.
* Suppress warning of not using faster overloaded string find function.

Bug: 30407689
Bug: 30411878
Change-Id: I6cfdbbd50cf5e8f3db6e5263076d3a17a9a791ee
Test: build with WITH_TIDY=1
Merged-In: Ie79dbe21899867bc62031f8618bb1322b8071525
2016-08-01 11:55:42 -07:00
Chih-Hung Hsieh
cfa32e2d5d Merge \\\"Fix google-explicit-constructor warnings in system/core.\\\" am: 6dc68cb5f9 am: 89cc78b77f
am: e59bc67fa4

Change-Id: I28613acd85ddcbd0b6f285cdfe046b283b49bd83
2016-07-29 17:06:44 +00:00
Chih-Hung Hsieh
89cc78b77f Merge \"Fix google-explicit-constructor warnings in system/core.\"
am: 6dc68cb5f9

Change-Id: I5a010465364b6e14423b19e8c0f9cffa58ee3152
2016-07-29 17:01:17 +00:00
Chih-hung Hsieh
6dc68cb5f9 Merge "Fix google-explicit-constructor warnings in system/core." 2016-07-29 16:57:17 +00:00
Felipe Leme
704fe2d628 resolve merge conflicts of 4acdde9 to nyc-mr1-dev-plus-aosp
Change-Id: I2ed3041dd979368f149b6fccc84621e56c118db8
2016-07-29 16:12:40 +00:00
Dmitry Shmidt
16efc4d63e Merge \\\"ueventd: Remove verbose restorecon_recursive: message\\\" am: 345754313e am: 2d5dfa89ae
am: 45d9f24cd4

Change-Id: I4f981f795101ab784dfa42aa7de698d66a39baac
2016-07-28 22:25:40 +00:00
Dmitry Shmidt
2d5dfa89ae Merge \"ueventd: Remove verbose restorecon_recursive: message\"
am: 345754313e

Change-Id: I8a65176acc859b59e96f22d39e095ce2d154d9cd
2016-07-28 22:19:18 +00:00
Felipe Leme
c64c982e72 Improved keychord logging.
Often a bugreport is accidentally triggered by the combo keys, but there
is nothing in the bugreport to confirm that action because init's
klog level is KLOG_NOTICE_LEVEL.

This change change keychord's INFO messages to NOTICE, and also logs the
case where a service was not launched because ADB was disabled.

BUG: 30440213
BUG: 30345559

Change-Id: I6ccadef1621cb41dcd15e7c1660366f0e147dc7a
2016-07-28 14:11:32 -07:00
Dmitry Shmidt
7eed474db4 ueventd: Remove verbose restorecon_recursive: message
Bug: 30478300

Change-Id: Ife69bb5644c3f65f3a256dc042ae1c7fbfb77729
Signed-off-by: Dmitry Shmidt <dimitrysh@google.com>
2016-07-28 13:55:39 -07:00
Elliott Hughes
a9f814239b Merge \\\"Fix early init logging.\\\" am: 6d232ab4de am: 1cbd1f5016
am: 7e336c8fe5

Change-Id: Id22974510c241cc8b62c3737de36c1e5941420e3
2016-07-27 15:36:13 +00:00
Elliott Hughes
1cbd1f5016 Merge \"Fix early init logging.\"
am: 6d232ab4de

Change-Id: I437dd3b5243ca7854439c438093e94733579279e
2016-07-27 15:30:45 +00:00
Treehugger Robot
6d232ab4de Merge "Fix early init logging." 2016-07-27 15:28:18 +00:00
Chih-Hung Hsieh
034c475931 Fix google-explicit-constructor warnings in system/core.
* Declare explicit conversion constructors.
* Add NOLINT for implicit conversion constructors.
* Fix also some misaligned indendations.

Bug: 28341362
Change-Id: Idf911f35923b408d92285cc1a053f382ba08c63e
Test: build with clang-tidy
2016-07-26 11:26:01 -07:00
Elliott Hughes
35f5d04620 Fix early init logging.
Remove the /dev/__kmsg__ workarounds (which can then be removed
from sepolicy), and fix confusion in the translation between
android-base logging and kernel logging priorities (in particular,
where 'notice' comes in the hierarchy).

Bug: http://b/30317429
Change-Id: I6eaf9919904b6b55bc402c20bf1a4ae269014bc7
Test: adb shell dmesg | grep init
2016-07-26 09:32:33 -07:00
Elliott Hughes
ef6975b675 Merge \\\"Improve init Service logging.\\\" am: c1d9ac1f85 am: b49e54b1d7
am: 3fca6fba2b

Change-Id: I63433c19e5cdad2299f39118d063d2067c5cd6d6
2016-07-26 15:27:04 +00:00
Elliott Hughes
b49e54b1d7 Merge \"Improve init Service logging.\"
am: c1d9ac1f85

Change-Id: I5eca381c0883015f1d043946db71c20635cc1784
2016-07-26 15:21:38 +00:00
Elliott Hughes
e18e7e5c43 Improve init Service logging.
Say which service.

Don't ignore setpgid failures.

Change-Id: Ifa8eba583cc3cbf3d26763977bf8c3c9835271c6
2016-07-25 18:18:16 -07:00
Jeff Sharkey
91404d9481 Merge \"Only restorecon CE storage after unlocked.\" into nyc-mr1-dev
am: 96f387e8c0

Change-Id: I3a1c31334d32e7bdff8e05558356d2833fcfb831
2016-07-18 16:06:34 +00:00
Amit Pundir
114a00ea03 Merge \\\"init: select usb gadget controller at run time\\\" am: 916f5e873e am: 91272bd435
am: aff2347646

Change-Id: Idbb3ed146b147300d8f472958a5b888c07f5a684
2016-07-15 23:01:34 +00:00
Amit Pundir
91272bd435 Merge \"init: select usb gadget controller at run time\"
am: 916f5e873e

Change-Id: Ifc4ec86c56df0de1ca498f3de392405490690809
2016-07-15 22:53:21 +00:00
Jeff Sharkey
1635afe83d Only restorecon CE storage after unlocked.
On FBE devices, the filenames inside credential-encrypted directories
are mangled until the key is installed.  This means the initial
restorecon at boot needs to skip these directories until the keys
are installed.

This CL changes the implementation of the "restorecon_recursive"
built-in command to use the new SKIPCE flag to avoid labeling files
in CE directories.  vold will request a restorecon when the keys
are actually installed.

Bug: 30126557
Change-Id: I320584574a4d712c493b5bbd8a79b56c0c04aa58
2016-07-15 16:21:42 -06:00
Amit Pundir
d2e74db475 init: select usb gadget controller at run time
Right now we set sys.usb.controller property in init.$platform.usb.rc
to enable ConfigFS gadgets.

Let system detect and set UDC driver name from /sys/class/udc instead.

Change-Id: I99ad49d24dc53b543c5573e209bf00d6c2d91dd4
Signed-off-by: Amit Pundir <amit.pundir@linaro.org>
2016-07-15 15:01:43 -07:00
Mark Salyzyn
109d7d23c5 init: Add support for ${x.y:-default} expansion
commit 00ede7d262 (init: do
expand_props before calling the builtins) broke logpersist

Bug: 28120456
Bug: 22654233
Bug: 28788401
Change-Id: Ib4d8231665b26ac083b02243177493fab41c8978
2016-07-13 23:55:34 +00:00
Tom Cherry
b79e076e5e init: expand arguments of services when they start
Arguments of commands are expanded based on properties if they contain
${property.name}, however this is not currently done for arguments of
services.

This patch makes it that arguments of services are expanded each time
that the service starts at the point immediately before execve().

Bug: 28788401
Change-Id: Iba581a8377e25a6478d4d2ec2e8b29e181d8640c
2016-07-13 23:54:42 +00:00
Jorge Lucangeli Obes
67410f8578 Merge \\\"Refactor Service::Start method.\\\" am: 82d2bcc21e am: f2ffdac47a
am: 77dbaad7b9

Change-Id: Ief7f4cc5b95b018d8476dd9a35cc76dd384fcbc5
2016-07-11 17:21:18 +00:00
Jorge Lucangeli Obes
f2ffdac47a Merge \"Refactor Service::Start method.\"
am: 82d2bcc21e

Change-Id: Icccd918f1dc02010c9aceb4560dc5ff18849d8a5
2016-07-11 17:13:26 +00:00
Treehugger Robot
82d2bcc21e Merge "Refactor Service::Start method." 2016-07-11 17:08:45 +00:00
Jorge Lucangeli Obes
344d01f99f Refactor Service::Start method.
This CL extracts code from Service::Start into four helper functions,
bringing Service::Start down to 134 lines vs 212 lines originally. This
makes the method a lot easier to follow. There is no change in behaviour.

Also, make error messages consistent (start with lowercase) and
format Service::Start to fit in 100 cols.

Bug: 30035168

Change-Id: If979976fba4d339a336d030f802ca9f169fd012c
2016-07-11 09:57:17 -04:00
Elliott Hughes
6605b0b23a Merge \\\"Make klog_fd thread-safe and make klog_init a no-op.\\\" am: 588b770063 am: 73d363bbc1
am: 7288ac3982

Change-Id: I46bbcb64eecc01ec7bd8bb502237c1b9057befc4
2016-07-08 17:12:48 +00:00
Elliott Hughes
73d363bbc1 Merge \"Make klog_fd thread-safe and make klog_init a no-op.\"
am: 588b770063

Change-Id: I884276a8f8b8209f6e956c5fb410e8265184e1b5
2016-07-08 17:05:25 +00:00
Yabin Cui
1b8159e7ab Merge \"init: use libbootloader_message.\" into nyc-mr1-dev
am: ca4cf4e4af

Change-Id: I8234e796a8b35115ef1ecf33c987882f8fe286cd
2016-06-30 22:55:42 +00:00
Yabin Cui
ca4cf4e4af Merge "init: use libbootloader_message." into nyc-mr1-dev 2016-06-30 21:08:30 +00:00
Yabin Cui
0b1252cca0 init: use libbootloader_message.
Bug: 29582118
Change-Id: I6285b29774a11d6dda8496c7c73e4c1d17a672bd
2016-06-29 16:44:02 -07:00
Elliott Hughes
171a829c39 Make klog_fd thread-safe and make klog_init a no-op.
I'll come back and remove klog_init when I've removed other calls to it.

Change-Id: Iad7fd26d853b4ddc54e9abd44516b6f138cbbfcb
Test: booted N9, looked at "adb shell dmesg" output.
2016-06-29 16:16:41 -07:00
Alex Light
40095a6eae Add umount call to init to unmount a filesystem
am: 68ab20febd

Change-Id: I1166f88814193092f10dad8a2fa841028613e03e
2016-06-29 22:56:40 +00:00
Jorge Lucangeli Obes
69e6dde7c6 Merge \"Rename \"Handle(r)\" to \"Parse(r)\" in Android init.\"
am: b0d062a497

Change-Id: If3b070c3ec8599e065980bec123bf8c2cf160222
2016-06-29 21:51:08 +00:00
Jorge Lucangeli Obes
177b27d4f5 Rename "Handle(r)" to "Parse(r)" in Android init.
The code in question parses config files, so use the right terminology.

Bug: 29872991
Change-Id: Id9644d9a98c1d702d2990f62b3020a27d073141e
2016-06-29 16:29:53 -04:00
Jorge Lucangeli Obes
5b951eebec Merge \"init: Add option to run a service in a new PID/mount namespace.\"
am: e71cedf450

Change-Id: I963b61c06922ae017fdb27b4a3a99d6519505329
2016-06-29 20:29:07 +00:00
Jorge Lucangeli Obes
1b3fa3d650 init: Add option to run a service in a new PID/mount namespace.
Namespaces are a more consistent isolation primitive than e.g. hiding
/proc.

Bug: 29635190

Change-Id: I7c39975813fb13b3d06be35a24c0854f16549c0a
2016-06-29 14:49:11 -04:00
Alex Light
68ab20febd Add umount call to init to unmount a filesystem
Bug: 29278988
Change-Id: Ia14ab1bcad9513688df97f7b4d9162a9ab282480
2016-06-29 17:36:13 +00:00
Elliott Hughes
7f5b29ff1e resolve merge conflicts of 54c1219 to stage-aosp-master
Change-Id: I4b3b2a8690cfe147929fd096de380a9d4b79f1ec
2016-06-27 09:54:25 -07:00
Elliott Hughes
f86b5a6b90 Move init to libbase logging.
Change-Id: Ibfbefeff587a69e948978a037c555fd12a5ade6a
2016-06-27 08:11:31 -07:00
Elliott Hughes
80744d867f Merge \"Remove MTD cruft from init.\"
am: 90db709a2f

Change-Id: I027708dd324000cbfad1a2a6e970f742db97bae5
2016-06-25 02:25:38 +00:00
Elliott Hughes
3195116e97 Remove MTD cruft from init.
Bug: http://b/29250988
Change-Id: I38ab263192944e4ff291fd91b25db163a8848d75
2016-06-24 18:26:30 -07:00
Elliott Hughes
e9a7f52ce5 Merge \"Remove more obsolete MTD stuff.\"
am: aa9f37185f

Change-Id: I7952147c2115d1e205737277376726507aed8447
2016-06-24 17:31:59 +00:00
Treehugger Robot
aa9f37185f Merge "Remove more obsolete MTD stuff." 2016-06-24 17:19:48 +00:00
Elliott Hughes
01e5a6c971 Remove more obsolete MTD stuff.
Bug: http://b/29250988
Change-Id: Ic2d0514fcdbe26526e87bc681b71efcc90eda678
Test: still builds.
2016-06-24 09:13:51 -07:00
Hung-ying Tyan
23a574a195 resolve merge conflicts of 66277db to stage-aosp-master
Change-Id: I58b1f7fec779c707ac4048ae5401087ec4b7c8b0
2016-06-24 13:21:09 +08:00
Hung-ying Tyan
66277db8d0 Merge "Add -f to insmod" 2016-06-24 04:34:56 +00:00
Hung-ying Tyan
bfa6d75c60 Add -f to insmod
When the flag is on, insmod will bypass vermagic and symbol version
checking in the kernel. This is to make it possible to update kernel
without recompiling kernel modules.

BUG=28803994

Change-Id: Ib4be6999ef52baefd4210ee0d242360e43318907
2016-06-24 11:10:46 +08:00
Chih-Hung Hsieh
65828a0ec9 Merge \"Fix misc-macro-parentheses warnings in system/core.\"
am: 495541c5bb

Change-Id: I021b653779c5119398c31ee354372366ba029328
2016-06-22 22:39:07 +00:00
Chih-Hung Hsieh
cdb2ca5d9f Fix misc-macro-parentheses warnings in system/core.
Add parentheses around macro arguments used beside operators.
Bug: 28705665

Change-Id: I9226f319e283be640eddc31687f75b51a8ef0ac6
2016-06-22 14:33:13 -07:00
Elliott Hughes
32cc6c9908 Merge \"init: report createProcessGroup failure.\"
am: 2d690a920f

Change-Id: I4ec8df459aefa4aebb3cdf9ec5aa40bc4e727f39
2016-06-17 04:16:21 +00:00
Elliott Hughes
ad8e94e017 init: report createProcessGroup failure.
Also directly kill the initial pid for safety, like other libprocessgroup
users.

Change-Id: Ib28936aea19cceaeaa54734759d5ae0c252c7905
2016-06-15 14:49:57 -07:00
William Roberts
787468260d Merge \\"ueventd: only relabel devices if there\\'s a delta\\" am: 95428817d6
am: 807fa4bd5c

Change-Id: I41a8c02332ae12dc1c4fbc9c45ee627a37ce6b77
2016-06-09 19:18:40 +00:00
Treehugger Robot
95428817d6 Merge "ueventd: only relabel devices if there's a delta" 2016-06-09 19:07:27 +00:00
Tom Cherry
39b1d2043e Merge \\"init: expand arguments of services when they start\\" am: 86cd314af3
am: f6ee6e16d9

Change-Id: I995a23e3eaa19bca1c4dc7880d786b806bd53306
2016-06-08 22:55:40 +00:00
Tom Cherry
86cd314af3 Merge "init: expand arguments of services when they start" 2016-06-08 22:42:11 +00:00
Vitalii Tomkiv
69cfeabfc0 Merge \\"Add process priority to service definition.\\" am: 14b00baaae
am: 20cc2787cb

Change-Id: I12993eed4953a7bdd832de0c263ce8d4c2476969
2016-06-08 21:42:31 +00:00
Vitalii Tomkiv
081705c258 Add process priority to service definition.
This change allows to set prioirrity of the process to be set through
*.rc file.

Bug: 28866384
Change-Id: If0108ef05c8a151749c43d2d7de1187653255ce8
2016-06-08 13:22:14 -07:00
Mark Salyzyn
5e2beeb8da Manually fix automerger error on 4ab7548
am: a6f1c46fa0

* commit 'a6f1c46fa04cf6b35b77bf249af11a3ffbe562e3':
  init: Add support for ${x.y:-default} expansion

Change-Id: If03b9453ed461e5878ecefc8863b164a683c10a4
2016-06-07 20:42:24 +00:00
Tom Cherry
bac3536cc9 init: expand arguments of services when they start
Arguments of commands are expanded based on properties if they contain
${property.name}, however this is not currently done for arguments of
services.

This patch makes it that arguments of services are expanded each time
that the service starts at the point immediately before execve().

Change-Id: Iba581a8377e25a6478d4d2ec2e8b29e181d8640c
2016-06-07 11:22:00 -07:00
Mark Salyzyn
4b56162a33 init: Add support for ${x.y:-default} expansion
commit 00ede7d262 (init: do
expand_props before calling the builtins) broke logpersist

Bug: 28120456
Bug: 22654233
Change-Id: Ib4d8231665b26ac083b02243177493fab41c8978
2016-06-07 18:09:17 +00:00
Elliott Hughes
8d532e4737 resolve merge conflicts of cea1d04 to nyc-dev-plus-aosp
Change-Id: I41cdca717664a16f00fd1b28076dd752fa96653d
2016-06-06 21:19:55 -07:00
Collin Mulliner
f7e79b99c1 use process groups for processes started by init
Put every service into a process group, kill the process group
and all child processes created within the group when killing the
service. Removed libutil dependency in libprocessgroup.

Bug: 25355957
Change-Id: Ieed60ec41579f638ab9b1e66a7e6330ed578ab05
Signed-off-by: Collin Mulliner <collinrm@squareup.com>
2016-06-06 16:31:01 -07:00
William Roberts
397de1494f ueventd: only relabel devices if there's a delta
Since commit: 24a3cbfa73
ueventd is attempting to relabel devices on calls to
make_device() when the device already exists. However, it
should only be called if the contexts for relabelfrom and
relabelto are different.

When this condition occurs, one will see denials like this:

[   14.409448] type=1400 audit(978307239.225:26): avc: denied { relabelfrom } for pid=1572 comm="ueventd" name="ttyS0" dev="tmpfs" ino=9613 scontext=u:r:ueventd:s0 tcontext=u:object_r:hci_attach_dev:s0 tclass=chr_file permissive=1
[   14.428107] type=1400 audit(978307239.225:27): avc: denied { relabelto } for pid=1572 comm="ueventd" name="ttyS0" dev="tmpfs" ino=9613 scontext=u:r:ueventd:s0 tcontext=u:object_r:hci_attach_dev:s0 tclass=chr_file permissive=1

Bug: 29106809

Change-Id: I2105b169206f0b26420f3c4b0ba5c49aeb98da92
Signed-off-by: William Roberts <william.c.roberts@intel.com>
2016-06-03 17:40:18 +00:00
Chih-Hung Hsieh
5fb629a212 resolve merge conflicts of e845c04 to nyc-dev-plus-aosp
Change-Id: I423f722dcc3821b9be52613d68640b49cbac70a6
2016-05-27 16:04:21 -07:00
Chih-Hung Hsieh
c713bce901 Fix misc-macro-parentheses warnings in init and other core modules.
Bug: 28705665
Change-Id: Ice67cebb8c42538f8fb9cf1756678f41a9d68a31
2016-05-18 18:11:49 -07:00
Rob Herring
a0c90085ec Merge "init: support matching sysfs class paths in ueventd.rc" am: faa14b94d5
am: 0da9f42f2c

* commit '0da9f42f2c2ec6985018ad45603b32532d096a60':
  init: support matching sysfs class paths in ueventd.rc

Change-Id: Ifc85ba3205a5207a4285da94b483164490dbde4d
2016-05-13 21:54:48 +00:00
Rob Herring
6de783af07 init: support matching sysfs class paths in ueventd.rc
Currently, ueventd.rc files only support /sys/devices/... paths
and don't support symlinked paths, specifically /sys/class/...
Supporting the class paths is necessary to have non-hardware
dependent paths. Some subsystems like IIO use /sys/bus/iio/, so
support that as well.

Change-Id: I29f3bf67b41664d1d75ac1820c46e13afe336d56
Signed-off-by: Rob Herring <robh@kernel.org>
2016-05-13 13:46:46 -07:00
Rob Herring
7aef62751b Merge "init: rework fixup_sys_perms to use perm_path_matches" am: 0504a94cd9
am: e7028e3d38

* commit 'e7028e3d382ee4099cfc4c1cbfa650fd2f820410':
  init: rework fixup_sys_perms to use perm_path_matches

Change-Id: Iaebea1a143b053ee1c41c47cb5eb2329f992330f
2016-05-13 20:33:28 +00:00
Rob Herring
e5636a3fce init: rework fixup_sys_perms to use perm_path_matches
fixup_sys_perms does the same matching as the function perm_path_matches
other than the leading '/sys'. Adjust the path and use the common
matching function. Replace the fixed length C strings with std::string.

Change-Id: Ic09d91aa4ac1f1096018617537d782b82ee9ef63
Signed-off-by: Rob Herring <robh@kernel.org>
2016-05-11 09:20:19 -05:00
Paul Crowley
71bac3fa4b Merge "Wipe device on policy error" into nyc-dev
am: 8a59fa8524

* commit '8a59fa85243a5f748108279f6d30b01292518b0a':
  Wipe device on policy error

Change-Id: I35205b2ddf8b3e8d049525e3717d27836d6c59a2
2016-05-10 22:17:08 +00:00
Paul Crowley
af8be58ca2 Wipe device on policy error
If we fail to set a crypto policy on a system-DE directory, this is a
serious and unrecoverable condition; the only way forward is to erase
the entire device. In a future commit we will also allow users the
option of booting again.

Bug: 28318405
Change-Id: Iff1e52c5bbee1beed29dc4b609d24bfeb7d138da
2016-05-10 11:04:39 -07:00
Nick Kralevich
f2049163a4 init/builtins.cpp: Switch to finit_module
Switch insmod from using init_module to finit_module. From
"man finit_module":

  The finit_module() system call is like init_module(), but reads the
  module to be loaded from the file descriptor fd. It is useful when the
  authenticity of a kernel module can be determined from its location in
  the file system; in cases where that is possible, the overhead of
  using cryptographically signed modules to determine the authenticity
  of a module can be avoided.

finit_module is preferred over init_module because it allows LSMs, such
as SELinux, to perform a permission check on kernel module loads based on
the file from which the module is loaded. This functionality is not yet
implemented in the Linux kernel, but is on the SEAndroid TODO list.
See https://bitbucket.org/seandroid/wiki/wiki/ToDo

Bug: 27824855

(cherry picked from commit 124a9c97e9)

Change-Id: I5e87de1a7b8c3d8849bf757c71b08e81c378b021
2016-05-04 07:01:46 -07:00
Chih-hung Hsieh
fb44ca5178 Merge "Fix google-explicit-constructor warnings." am: 7bdd6a8b5a
am: 427d8d840f

* commit '427d8d840f6ec5ce5767b2ee521e4ac5b7ebd619':
  Fix google-explicit-constructor warnings.

Change-Id: I26dc45aca83f991aa7993f6d4233e0439dd44a22
2016-04-30 05:16:35 +00:00
Chih-hung Hsieh
7bdd6a8b5a Merge "Fix google-explicit-constructor warnings." 2016-04-30 05:10:05 +00:00
Chih-Hung Hsieh
1c563d96f0 Fix google-explicit-constructor warnings.
Bug: 28341362
Change-Id: I4504e98a8db31e0edcbe63c23f9af43eb13e9d86
2016-04-29 15:44:04 -07:00
Mihai Serban
721c9ce4a5 ueventd: relabel block devices nodes when processing subsequent add events
There is a race in ueventd's coldboot procedure that permits creation
of device block nodes before platform devices are registered. This happens
when the kernel sends events for adding block devices during ueventd's
coldboot /sys walk.
In this case the device node links used to compute the SELinux context
are not known and the node is created under the generic context:
u:object_r:block_device:s0.
A second add event for block device nodes is triggered after the platform
devices are handled by ueventd and the SELinux context is correctly computed
but the mknod call fails because the node already exists. This patch handles
this error case and updates the node's security context.

The race is introduced by the uevent sent from the sdcard device probe
function. The issue appears when this uevent is triggered during ueventd's
coldboot procedure but before the /sys/devices recursive walk reached the
corresponding sdcard platform device path.
The backtrace looks something like:
1. ueventd_main()
2. device_init()
3. coldboot("/sys/devices");
4. do_coldboot()
5. handle_device_fd()
6. handle_device_event()
6.1 handle_block_device_event()
6.2 handle_platform_device_event()

Because handle_device_fd() reads all events from the netlink socket it may
handle the add events for the sdcard partition nodes send occasionally by the
kernel during coldboot /sys walk procedure.
If handle_device_event() continues with handle_block_device_event()
before handle_platform_device_event() registers the sdcard platform device then
handle_block_device_event() will create device nodes without knowing all block
device symlinks (get_block_device_symlinks()):
1. handle_device(path=/dev/block/mmcblk0p3, links = NULL)
2. make_device(path=/dev/block/mmcblk0p3, links = NULL)
3. selabel_lookup_best_match(path=/dev/block/mmcblk0p3, links = NULL)
  returns the default context (u:object_r:block_device:s0) for
  /dev/block/mmcblk0p3 instead of more specific context like:
  u:object_r:boot_block_device:s0
4. setfscreatecon(u:object_r:block_device:s0)
5. mknod(/dev/block/mmcblk0p3)

So the node is create with the wrong context. Afterwards the coldboot /sys walk
continues and make_device() will be called with correct path and links.
But even if the secontext is computed correctly this time it will not be
applied to the device node because mknod() fails.
I see this issue randomly appearing (one time in 10 reboots) on a Minnoboard
Turbot with external sdcard as the boot device.

BUG=28388946

Signed-off-by: Mihai Serban <mihai.serban@intel.com>

(cherry picked from commit 24a3cbfa73)

Change-Id: I2d217f1c8d48553eb4a37457dbf27fff54051cf9
2016-04-28 06:27:39 -07:00
Treehugger Robot
355e4c8350 Merge "ueventd: relabel block devices nodes when processing subsequent add events" am: 94b0f37
am: 51cdf14

* commit '51cdf140db1ab9254ba7c67fe74f9d9c81dcbd21':
  ueventd: relabel block devices nodes when processing subsequent add events

Change-Id: Ic7589319810d12918937f429ab9488344f0e0962
2016-04-28 12:09:55 +00:00
Mihai Serban
24a3cbfa73 ueventd: relabel block devices nodes when processing subsequent add events
There is a race in ueventd's coldboot procedure that permits creation
of device block nodes before platform devices are registered. This happens
when the kernel sends events for adding block devices during ueventd's
coldboot /sys walk.
In this case the device node links used to compute the SELinux context
are not known and the node is created under the generic context:
u:object_r:block_device:s0.
A second add event for block device nodes is triggered after the platform
devices are handled by ueventd and the SELinux context is correctly computed
but the mknod call fails because the node already exists. This patch handles
this error case and updates the node's security context.

The race is introduced by the uevent sent from the sdcard device probe
function. The issue appears when this uevent is triggered during ueventd's
coldboot procedure but before the /sys/devices recursive walk reached the
corresponding sdcard platform device path.
The backtrace looks something like:
1. ueventd_main()
2. device_init()
3. coldboot("/sys/devices");
4. do_coldboot()
5. handle_device_fd()
6. handle_device_event()
6.1 handle_block_device_event()
6.2 handle_platform_device_event()

Because handle_device_fd() reads all events from the netlink socket it may
handle the add events for the sdcard partition nodes send occasionally by the
kernel during coldboot /sys walk procedure.
If handle_device_event() continues with handle_block_device_event()
before handle_platform_device_event() registers the sdcard platform device then
handle_block_device_event() will create device nodes without knowing all block
device symlinks (get_block_device_symlinks()):
1. handle_device(path=/dev/block/mmcblk0p3, links = NULL)
2. make_device(path=/dev/block/mmcblk0p3, links = NULL)
3. selabel_lookup_best_match(path=/dev/block/mmcblk0p3, links = NULL)
  returns the default context (u:object_r:block_device:s0) for
  /dev/block/mmcblk0p3 instead of more specific context like:
  u:object_r:boot_block_device:s0
4. setfscreatecon(u:object_r:block_device:s0)
5. mknod(/dev/block/mmcblk0p3)

So the node is create with the wrong context. Afterwards the coldboot /sys walk
continues and make_device() will be called with correct path and links.
But even if the secontext is computed correctly this time it will not be
applied to the device node because mknod() fails.
I see this issue randomly appearing (one time in 10 reboots) on a Minnoboard
Turbot with external sdcard as the boot device.

BUG=28388946

Change-Id: I96e239af29d82b753e5d349b3ecefaad09edee87
Signed-off-by: Mihai Serban <mihai.serban@intel.com>
2016-04-28 10:45:03 +00:00
Paul Lawrence
1a920d72dc Merge "Don\'t start defaultcrypto twice" into nyc-dev
am: fe5d55a

* commit 'fe5d55a68b9dc3a593d3f6ee5be919b8a9de710c':
  Don't start defaultcrypto twice

Change-Id: I0e9a27208ea046a2cf738992ba97141da9026c08
2016-04-19 14:46:48 +00:00
Paul Lawrence
1f99218612 Don't start defaultcrypto twice
The old way (using triggers) starts defaultcrypto twice because
queue_property_triggers_action retriggers the action.

Bug: 27452459
Change-Id: I48c844836f551673d0dbfed6c33bd8ee1e035f40
2016-04-18 15:37:31 -07:00
Elliott Hughes
bdeac39a42 Remove undocumented functionality from init.
(cherry-pick of a3cc6026301db08285028c760af2665a66b3cc44.)

Bug: http://b/28151340
Change-Id: I5360502c79d9113a13055bf017b39c099033e947
2016-04-13 07:56:51 -07:00
Elliott Hughes
8bcb7caf0e Merge "Remove undocumented functionality from init." into nyc-dev
am: 27fe8c9

* commit '27fe8c904b0e63b047ac90380b6b2433fcec930d':
  Remove undocumented functionality from init.

Change-Id: I3893df1ca5d16e72368f8990baea2395781af24d
2016-04-13 14:51:01 +00:00
Elliott Hughes
9c4a0e0216 Merge changes from topic \'boringssl_conversion\' am: 52eb93c
am: 0781351

* commit '07813516502d12cfeabef94838e916c0cf4f3b46':
  Switch fs_mgr and adb to libcrypto_utils.
  Add libcrypto_utils.

Change-Id: Ib50abd66d546a2b2c7a1249043e1b39c2147c674
2016-04-12 23:22:11 +00:00
Mattias Nissler
097b6bbc76 Switch fs_mgr and adb to libcrypto_utils.
Update code and dependencies to use BoringSSL + libcrypto_utils
instead of mincrypt.

Change-Id: Ic75164bd50c84b81b6310e27a67d4b3c174984f9
2016-04-12 23:04:11 +00:00
Elliott Hughes
a3cc602630 Remove undocumented functionality from init.
Bug: http://b/28151340
Change-Id: I5360502c79d9113a13055bf017b39c099033e947
2016-04-12 15:38:51 -07:00
Yabin Cui
52a302d1e6 Merge "init: write bootloader message directly." into nyc-dev
am: a3a7a88

* commit 'a3a7a886f5277b6223140761e58cea0753854225':
  init: write bootloader message directly.

Change-Id: I764e0288b40264b8e48fc09011c3c0475b71a04e
2016-04-09 00:35:26 +00:00
Yabin Cui
46e037980b init: write bootloader message directly.
Bug: 27176738
Change-Id: I8c95a193f3436c0893d5103760b700f3052888db
2016-04-08 11:05:56 -07:00
Elliott Hughes
c7f5af58d9 Merge "ueventd: convert to use pwd family of functions" am: 2c78f62
am: 1397e7a

* commit '1397e7af4b432d174dbbc7400cca9a00ce34ea5d':
  ueventd: convert to use pwd family of functions

Change-Id: I02c1d78835054bd296ce84586410bbcee1760a9c
2016-04-08 01:55:36 +00:00
Elliott Hughes
2a651e603a Merge "property_service: drop unused header" am: 1134925
am: b627a01

* commit 'b627a014b97a4ffdfe6d4ca4c2e47b61cd87321d':
  property_service: drop unused header

Change-Id: I44b28ece5694d811d55a3de963e95ca14ff68cb0
2016-04-08 01:55:36 +00:00
Elliott Hughes
6ba3710651 Merge "init: drop unused header android_filesystem_config.h" am: 54c27c7
am: 8cb6a9c

* commit '8cb6a9cdb7cb1feaff29914aa88c68399e32f14f':
  init: drop unused header android_filesystem_config.h

Change-Id: I1cc001c883199e8355e97d93a2f6ce0d46bdd767
2016-04-08 01:55:36 +00:00
Elliott Hughes
ff37c38bac Merge "init: switch from android_ids to getpwnam" am: 171504f
am: 43cbd05

* commit '43cbd0585b50996e1601dc6ed56e723aded810c8':
  init: switch from android_ids to getpwnam

Change-Id: I100993cfb07f23bb5b3079846d4e00f31d1a9794
2016-04-08 01:55:35 +00:00
William Roberts
5b5a8ace61 ueventd: convert to use pwd family of functions
Switch ueventd to use the grp.h and pwd.h family of
functions for converting strings to uids. This removes the
need for using android_filesystem_config.h.

Change-Id: I25a6f536bb11683d5cd69a0d7b348d25a272dd3b
Bug: 27999086
Signed-off-by: William Roberts <william.c.roberts@intel.com>
2016-04-07 13:38:43 -07:00
William Roberts
8e1dce8ba0 property_service: drop unused header
Remove android_filesystem_config.h since it was not being used.

Change-Id: I691513d50a3fdb7563a63aee7551137ba983825c
Bug: 27999086
Signed-off-by: William Roberts <william.c.roberts@intel.com>
2016-04-07 13:38:43 -07:00
William Roberts
6df15704bd init: drop unused header android_filesystem_config.h
Change-Id: I66e637bc2d7fd5f385f40f150becfe515c53c19a
Bug: 27999086
Signed-off-by: William Roberts <william.c.roberts@intel.com>
2016-04-07 13:38:43 -07:00
William Roberts
3792e6cf21 init: switch from android_ids to getpwnam
Start to move users of android_filesystem_config.h to use the
standard grp and pwd interface functions.

Advantages:
  * one copy of android_ids in libc, removing it from init objects.
  * immediately starts oem_xxx users and groups in rc.
  * future will support _named_ oem ids via backend improvements.

Change-Id: Ib1ae1e0cbdcaaf60deb3759681a6030b615c069c
Bug: 27999086
Signed-off-by: William Roberts <william.c.roberts@intel.com>
2016-04-07 13:38:36 -07:00
Mark Salyzyn
402fb79d43 init: turn off backlight when performing shutdown cleanup
(cherry pick from commit a98cc9c202)

Try writing a "0" into:

- /sys/class/leds/lcd-backlight/brightness
- /sys/class/backlight/*/brightness

to turn off the backlight during shutdown cleanup.

Bug: 27506425
Change-Id: Ic8a44dc8909b303f24e14f71cfb43292df60efde
2016-04-05 16:20:59 -07:00
Mark Salyzyn
24f79bed76 Merge "init: turn off backlight when performing shutdown cleanup" am: adf1cde
am: 23702b5

* commit '23702b538b3a02ca35f24c55d406a7cc7b14641f':
  init: turn off backlight when performing shutdown cleanup

Change-Id: I249106a3b6c22e77d06bca5aee1d92184b00ba33
2016-04-05 23:14:28 +00:00
Mark Salyzyn
a98cc9c202 init: turn off backlight when performing shutdown cleanup
Try writing a "0" into:

- /sys/class/leds/lcd-backlight/brightness
- /sys/class/backlight/*/brightness

to turn off the backlight during shutdown cleanup.

Bug: 27506425
Change-Id: Ic8a44dc8909b303f24e14f71cfb43292df60efde
2016-04-05 15:56:27 -07:00
Mark Salyzyn
0fcc2ee4e4 init: watchdog restarted during shutdown fsck
(cherry pick from commit ad575e04a1)

Bug: 27506425
Change-Id: I40967068d18ce1a8cbaf0b750e7a7af6eab3e4e8
2016-04-05 12:44:24 -07:00
Mark Salyzyn
e4c8b31fed Merge "init: watchdog restarted during shutdown fsck" am: 3443caa
am: 34dcdd8

* commit '34dcdd8075a0c12de552219d4f326bccd1c8fe62':
  init: watchdog restarted during shutdown fsck

Change-Id: I28e3a730f2d854c51f1d760a5400faecd3f1fafc
2016-04-05 18:44:59 +00:00
Mark Salyzyn
ad575e04a1 init: watchdog restarted during shutdown fsck
Bug: 27506425
Change-Id: I40967068d18ce1a8cbaf0b750e7a7af6eab3e4e8
2016-04-05 11:31:14 -07:00
Nick Kralevich
d87a1747aa Merge "init/builtins.cpp: Switch to finit_module" am: b3cf2e0
am: 699b115

* commit '699b115be3c79547e9cc6d8bca771d77eb384915':
  init/builtins.cpp: Switch to finit_module

Change-Id: Iab21b9e058fe9435847ba9bca4cb2d1c0f50c88f
2016-03-30 02:17:56 +00:00
Nick Kralevich
124a9c97e9 init/builtins.cpp: Switch to finit_module
Switch insmod from using init_module to finit_module. From
"man finit_module":

  The finit_module() system call is like init_module(), but reads the
  module to be loaded from the file descriptor fd. It is useful when the
  authenticity of a kernel module can be determined from its location in
  the file system; in cases where that is possible, the overhead of
  using cryptographically signed modules to determine the authenticity
  of a module can be avoided.

finit_module is preferred over init_module because it allows LSMs, such
as SELinux, to perform a permission check on kernel module loads based on
the file from which the module is loaded. This functionality is not yet
implemented in the Linux kernel, but is on the SEAndroid TODO list.
See https://bitbucket.org/seandroid/wiki/wiki/ToDo

Bug: 27824855
Change-Id: Id0ea88cd1930393c8c73ce38e63d5b2eeadf946a
2016-03-29 16:53:08 -07:00
Dan Austin
d219b4eff4 Merge "Address const issues in preparation for libcxx rebase."
am: 7f84a07

* commit '7f84a0700ca49cfdf650d46b383d6e5aaae05fdc':
  Address const issues in preparation for libcxx rebase.
2016-03-28 22:43:26 +00:00
Dan Austin
7f84a0700c Merge "Address const issues in preparation for libcxx rebase." 2016-03-28 22:35:51 +00:00
Dan Austin
427fb7216d Merge "Fix const issues in preparation for libcxx rebase."
am: dce9b61

* commit 'dce9b61d253675fc5067b76eb166de66dc8fd367':
  Fix const issues in preparation for libcxx rebase.
2016-03-28 21:48:38 +00:00
Dan Austin
dce9b61d25 Merge "Fix const issues in preparation for libcxx rebase." 2016-03-28 21:41:10 +00:00
Dan Austin
60b976db85 Address const issues in preparation for libcxx rebase.
Change-Id: If9bf6c3ee57c3476a5661401853506551e2150cb
2016-03-28 14:22:12 -07:00
Dan Austin
a27bbd2728 Fix const issues in preparation for libcxx rebase.
Change-Id: Id57474eb63334873ee5383f61eb918941dbb0984
2016-03-28 13:43:15 -07:00
Daniel Cashman
2a1c430ff4 Merge "Revert "Set mmap_rnd_bits to maximum value.""
am: bb296fd

* commit 'bb296fdaecb3c90c21797dab6abb3add4f84d938':
  Revert "Set mmap_rnd_bits to maximum value."
2016-03-25 18:48:14 +00:00
Daniel Cashman
c8f026fc9c Revert "Set mmap_rnd_bits to maximum value."
Prebuilt kernels have not been updated with the requisite patches.

This reverts commit c819e78e7f.

Change-Id: I8e63373a9b8a1e5adcb2471dfe43bde28e3f8e65
2016-03-25 10:45:20 -07:00
Kees Cook
a0218d9c09 Merge "init: improve mmap ASLR failure reporting"
am: b27026f

* commit 'b27026f9253fd66cf85fe4ab519a6781a7cddb0b':
  init: improve mmap ASLR failure reporting
2016-03-24 02:53:10 +00:00
Kees Cook
39caeb5bee init: improve mmap ASLR failure reporting
This should help people track down the reason for entropy setting
failures.

Bug: 27681085
Change-Id: I6bde342ca0215e32c1f851365a1723630c7d4372
2016-03-23 10:00:11 -07:00
dcashman
7b094b759e init: Fix typo.
am: 9261ad1

* commit '9261ad13ed8a6bf5d43450f3eb5a48ecd65587f1':
  init: Fix typo.
2016-03-22 23:24:21 +00:00
dcashman
754dd9660f init: Fix typo.
Bug: 27681085
Change-Id: I4308435a5b58189852c991d1bec65ed11933566a
2016-03-22 16:15:24 -07:00
dcashman
9261ad13ed init: Fix typo.
Bug: 27681085
Change-Id: I4308435a5b58189852c991d1bec65ed11933566a
2016-03-22 16:04:26 -07:00
dcashman
3396b4b665 Temporarily add set_mmap_rnd_bits brillo exception
(cherry-picked from internal commit: 69022e03d8)
Bug: 27794137
Change-Id: Idc6fc1e208bdb19556173d40215feb66e235c6d6
2016-03-22 15:37:19 -07:00
dcashman
0f80d8cd4e Temporarily add set_mmap_rnd_bits brillo exception
am: 69022e0

* commit '69022e03d81e43455cf7c21555314c4d08664311':
  Temporarily add set_mmap_rnd_bits brillo exception
2016-03-22 22:33:54 +00:00
dcashman
69022e03d8 Temporarily add set_mmap_rnd_bits brillo exception
Bug: 27794137
Change-Id: Idc6fc1e208bdb19556173d40215feb66e235c6d6
2016-03-22 15:18:29 -07:00
dcashman
c819e78e7f Set mmap_rnd_bits to maximum value.
Also make sure it is above a minimum threshold, else abort.

(cherry-pick of internal commit: 5d36813dc8)

Bug: 27681085
Change-Id: Ia1d9583254fd64828092533298a99ec64b8233f7
2016-03-22 13:16:26 -07:00
dcashman
8aacc03cc3 Set mmap_rnd_bits to maximum value.
am: 5d36813

* commit '5d36813dc8d3be3f62856cf5147b828a7a8594a7':
  Set mmap_rnd_bits to maximum value.
2016-03-22 19:31:21 +00:00
dcashman
5d36813dc8 Set mmap_rnd_bits to maximum value.
Also make sure it is above a minimum threshold, else abort.

Bug: 27681085
Change-Id: Id03ede491e5e013a2a7a090abb306d00cb74f901
2016-03-22 12:11:51 -07:00
Viorel Suman
4492dd2f9c Merge "Multiple consoles"
am: a01de8f

* commit 'a01de8fee1fa47ef4893d2017ac8c390c3c08a00':
  Multiple consoles
2016-03-21 16:55:58 +00:00
Viorel Suman
70daa67062 Multiple consoles
This CL allows enabling of multiple consoles. A service can be
mapped to a specific console by providing the optional argument,
IE "tty0", to "console" service attribute as follows:

service fbconsole /system/bin/sh
    class core
    console tty0
    disabled
    user shell
    group shell log readproc
    seclabel u:r:shell:s0

Bug: None
Change-Id: I3b24e7f6848bbe5c6475f11334c04ec536e6af88
Tracked-On: https://jira01.devtools.intel.com/browse/BP-289
Signed-off-by: Viorel Suman <viorel.suman@intel.com>
2016-03-21 08:50:01 -07:00
Viorel Suman
441c076630 Merge "Revert "Enable multiple consoles""
am: ba44383

* commit 'ba44383197c8d5e1ca6ad32b67837c9aaf7ee224':
  Revert "Enable multiple consoles"
2016-03-21 15:28:16 +00:00
Viorel Suman
efc7275172 Revert "Enable multiple consoles"
This reverts commit caafe5c620.

Bug: None
Change-Id: Iea2a80003d996ce542393242f87dc658ac6d01c9
Tracked-On: https://jira01.devtools.intel.com/browse/BP-289
Signed-off-by: Viorel Suman <viorel.suman@intel.com>
2016-03-21 11:21:19 +02:00
Viorel Suman
f50b165a4e Merge "Enable multiple consoles"
am: f3f7d64

* commit 'f3f7d64035ca7225437b54bed43e0282b0758682':
  Enable multiple consoles
2016-03-18 01:19:18 +00:00
Viorel Suman
caafe5c620 Enable multiple consoles
This CL allows enabling of multiple consoles. The expected format
of "androidboot.console" kernel parameter is a list of available
consoles, as follows:

  androidboot.console=tty0:ttyS0

A service can be mapped to a specific console by providing the
optional argument, IE "tty0", to "console" service attribute as follows:

service fbconsole /system/bin/sh
    class core
    console tty0
    disabled
    user shell
    group shell log readproc
    seclabel u:r:shell:s0

Bug: None
Change-Id: I3f8556425c8651bd121995869700f18b23365d55
Tracked-On: https://jira01.devtools.intel.com/browse/BP-289
2016-03-17 21:00:15 +02:00
Janis Danisevskis
0af61f0024 Merge "Leftovers of the SELinux policy update mechanism"
am: b9c0788806

* commit 'b9c078880644b51bc9e6c314eed157f230fce43c':
  Leftovers of the SELinux policy update mechanism
2016-03-13 14:53:00 +00:00
Janis Danisevskis
3d1dff2231 Leftovers of the SELinux policy update mechanism
Remove references to SELinux policy files in /data/security
from libselinux/android.c. In the process all code that is
apparently related to handling an alternate policy and/or
reloading the policy has been removed.

Bug: 26544104
Change-Id: I47bf76ac3c26c5d71f92a21ffac2b17ba14262ea
2016-03-11 17:47:30 +00:00
George Burgess IV
02f689e11a Merge "Cleanup uses of sprintf so we can deprecate it." am: 2c5b89a64a
am: 3368bdebba

* commit '3368bdebba02316710bafc5bce120eec388365fb':
  Cleanup uses of sprintf so we can deprecate it.
2016-03-08 07:41:39 +00:00
George Burgess IV
2c5b89a64a Merge "Cleanup uses of sprintf so we can deprecate it." 2016-03-08 04:14:06 +00:00
George Burgess IV
e7aa2b2c83 Cleanup uses of sprintf so we can deprecate it.
Also cleans up two instances of open() with useless mode params, and
changes a few uses of snprintf to use sizeof(buffer) instead of
hardcoded buffer sizes.

Change-Id: If11591003d910c995e72ad8f75afd072c255a3c5
2016-03-07 18:40:40 -08:00
Paul Lawrence
bdd5908766 Merge "Distinguish between unencrypted and unencryptable" into nyc-dev
am: 72d2e06f4e

* commit '72d2e06f4e10d0d11526eb9bb09a3ef23302729c':
  Distinguish between unencrypted and unencryptable
2016-03-07 16:56:51 +00:00
Paul Lawrence
1098aacde4 Distinguish between unencrypted and unencryptable
Set ro.crypto.state flag to unencrypted and unsupported accordingly

Bug: 18002358
Change-Id: I1f88ce9704c5505d7b63256e2ebe5f8441c79ad0
2016-03-04 15:52:33 -08:00
Nick Kralevich
3ae908e906 Merge "Mount selinuxfs when other filesystems are mounted" am: ad5dc479cd
am: 59c8d5e2bf

* commit '59c8d5e2bf31aa5340a563e74af74ad1e11b3e13':
  Mount selinuxfs when other filesystems are mounted
2016-03-03 22:00:23 +00:00
Nick Kralevich
3d9e273359 Mount selinuxfs when other filesystems are mounted
Be consistent when mounting filesystems, and mount selinuxfs
at the same time other filesystems are mounted. In particular,
this ensures that a /sys/fs/selinux/null is available at early
boot, avoiding an unnecessary mknod call.

Change-Id: I01e6b3900f48b4cb3f12d8a928e1e95911524252
2016-03-03 11:26:24 -08:00
Nick Kralevich
9bcfd64b59 init: harden socket creation against symlinks
Instead of using chown, use the symlink safe lchown.

Instead of using chmod, use the symlink safe fchmodat
with AT_SYMLINK_NOFOLLOW.

Fix a bug where the SELinux filesystem creation context may
not be restored, and some memory not freed, if bind() fails.

Check the return values from the chown/chmod calls and unlink
the files if it ever fails.

(cherrypicked from commit ab5629c197)

Bug: 27337831
Change-Id: I28c5f4dee55aa706437eb51ad403c1fbf56138de
2016-02-25 12:38:51 -08:00
Yusuke Sato
c4c8bf4a9c Merge "Use ro.debuggable instead of ro.build.type" am: 37c90df931
am: 4e30b63fc6

* commit '4e30b63fc6049ec728d607b49632f287128074c7':
  Use ro.debuggable instead of ro.build.type
2016-02-25 19:35:52 +00:00
Yusuke Sato
246b0fd0d9 Use ro.debuggable instead of ro.build.type
Change-Id: I4d7c8c353ff47fbeee065b2c4fdd984768d0da00
2016-02-25 10:53:55 -08:00
Nick Kralevich
17e5b23a95 Merge "init: harden socket creation against symlinks" into nyc-dev
am: 53e56b9473

* commit '53e56b9473819fb5058e85e866ac493aaccbae81':
  init: harden socket creation against symlinks
2016-02-25 06:50:49 +00:00
Nick Kralevich
ab5629c197 init: harden socket creation against symlinks
Instead of using chown, use the symlink safe lchown.

Instead of using chmod, use the symlink safe fchmodat
with AT_SYMLINK_NOFOLLOW.

Fix a bug where the SELinux filesystem creation context may
not be restored, and some memory not freed, if bind() fails.

Check the return values from the chown/chmod calls and unlink
the files if it ever fails.

Bug: 27337831
Change-Id: I3343786f5a4eefda7bbb8317f2eca16bd21003c0
2016-02-24 15:50:52 -08:00
James Hawkins
22b6f7a559 resolve merge conflicts of 0f5d443d0c to nyc-dev-plus-aosp
Change-Id: I850bda0808ae17ade5bc0e667211a599d284d6e3
2016-02-19 11:10:30 -08:00
James Hawkins
588a2cad7f system/core: Cleanup direct calls to opendir by containing in a
std::unique_ptr.

Bug: 26643633
Change-Id: Ia3491fdbff086558da694ae949cf08e4c89d0307
2016-02-18 14:52:46 -08:00
Jeff Sharkey
c895f11cf1 Merge "User 0 directories are created by vold now." 2016-02-05 21:01:21 +00:00
Elliott Hughes
be49484810 Merge "init: fix writepid wrong pid written in file(s)" am: 718625010d
am: 880200c9bb

* commit '880200c9bbf8b283b0f6351c1c052bc00d69697d':
  init: fix writepid wrong pid written in file(s)
2016-02-05 19:06:37 +00:00
Anestis Bechtsoudis
b702b46f68 init: fix writepid wrong pid written in file(s)
When child (pid==0) executes fork branch 'pid_str'
will always be 0 writting wrong value to file(s).
Fix by utilizing getpid() to obtain correct pid.

Tracker link provides some insight on why use cases
aren't broken.

Bug: https://code.google.com/p/android/issues/detail?id=200392

Change-Id: I29989365a8bac94502c090918fa30e5cc88eb1ea
Signed-off-by: Anestis Bechtsoudis <anestis@census-labs.com>
2016-02-05 16:49:28 +02:00
Jeff Sharkey
3b9c83a0f6 User 0 directories are created by vold now.
This ensures that all users on device follow a consistent path for
setup and validation of encryption policy.

Also add remaining user-specific directories and fix linking order.

Bug: 25796509
Change-Id: I8c2e42a78569817f7f5ea03f54b743a6661fdb9c
2016-02-04 15:26:23 -07:00
Paul Lawrence
1446f0f318 Merge "Remove code to handle non-default file encryption" 2016-02-02 23:16:02 +00:00
Elliott Hughes
edbc3af294 Merge "init: Fix load_firmware error" am: f330e5462d
am: de0af89c82

* commit 'de0af89c8253ecda179c35cb8c62c592b91e46ae':
  init: Fix load_firmware error
2016-02-02 22:54:32 +00:00
Paul Lawrence
69080180ce Remove code to handle non-default file encryption
Change-Id: I6d986853929c0237c0d958329b8e9aab47907a00
2016-02-02 10:34:40 -08:00
Paul Crowley
5949745534 On FDE devices, initialize user 0
Fix ugly special cases for user 0: initialize them explicitly.

Bug: 26704408
Change-Id: I1b8536b9e5e87ea98b4009a309f2e22c56006651
2016-02-01 16:44:46 +00:00
Biao Lu
dc848566a1 init: Fix load_firmware error
In function 'load_firmware', parameter 'buf' passed to 'write'
is wrong. To fix it, use android::base::WriteFully to replace.

Change-Id: I13f79bdc9be9e5eb669f6bd975535b1dce965ef0
Signed-off-by: Biao Lu <biao.lu@intel.com>
2016-02-01 10:10:28 +08:00
Tom Cherry
6ddde53e8e Merge "init: Update readme.txt to reflect recent changes to init" am: d401eba04c
am: 9262e5fdcd

* commit '9262e5fdcd77e296bd71dbc1c9448a347a851789':
  init: Update readme.txt to reflect recent changes to init
2016-01-25 18:22:24 +00:00
Tom Cherry
1fb20b8377 init: Update readme.txt to reflect recent changes to init
Best practice for services that reside on the system, vendor, and odm
partitions is to have a corresponding init .rc file in the
/{system,vendor,odm}/etc/init directory, which contains its service
entry and any related actions.

Change-Id: I26204f9a0f09ce8069f3791ccd9ee61d164a048f
2016-01-23 05:23:39 +00:00
Paul Crowley
65f54a8e19 Merge "Remove no-longer-needed crypto init builtins" 2016-01-21 11:16:33 +00:00
Hung-ying Tyan
25778dcf5e Merge "Allow paths of .rc files to be specified at mount_all" am: e7f9779886
am: 436a8aa9de

* commit '436a8aa9de9c90a8ee95e02e97bf65e50c80d4f4':
  Allow paths of .rc files to be specified at mount_all
2016-01-21 05:05:09 +00:00
Hung-ying Tyan
e7f9779886 Merge "Allow paths of .rc files to be specified at mount_all" 2016-01-21 04:12:23 +00:00
Hung-ying Tyan
dc738eaf15 Allow paths of .rc files to be specified at mount_all
In current implementation, the mount_all command imports all .rc files
under /{system,vendor,odm}/etc/init/ after mouting filesystems is complete.
There's a need from ODMs to import different .rc files under different boot
modes (e.g., factory mode). Without this support, they will have to fiddle
around the init implementation.

This commit makes mount_all import the .rc files/directories specified
as additional arguments. If no path is given, the original ones are applied
the same way as the current implementation.

BUG: 26549689
Change-Id: Ie67ce13dde4c440ff8bf534826bc392c882a433f
2016-01-21 09:35:43 +08:00
Paul Crowley
558d8f4364 Remove no-longer-needed crypto init builtins
Changes to the way FBE works to support lifecycles mean that these
commands aren't needed any more.

Bug: 22358539
Change-Id: Id73339e0aa8070dd688f35b5d59de75236961395
2016-01-20 11:20:23 +00:00
Nick Kralevich
974bf66088 Merge "logging: avoid unnecessary printfs" am: 542a511f87
am: 5644112b7e

* commit '5644112b7e05372fcda105fa621630c12ec29a6e':
  logging: avoid unnecessary printfs
2016-01-19 18:10:37 +00:00
Nick Kralevich
5db8d6aafa logging: avoid unnecessary printfs
Don't spend CPU cycles formatting a bunch of strings if we're
just going to throw them away later. Maybe make booting faster.

Change-Id: I4d8eb99fb3fa873ca91cf776933d0ad01988abf5
2016-01-16 16:20:24 -08:00
Tom Cherry
363d7cc205 Merge "Remove special case handling of "ro." properties permissions" am: b45f8179be
am: 44e06f5f00

* commit '44e06f5f00c3e0412c85ee5f515ccd0f83abbbc2':
  Remove special case handling of "ro." properties permissions
2016-01-13 18:52:19 +00:00
Tom Cherry
c787cf291a Remove special case handling of "ro." properties permissions
Currently, properties that begin with "ro." are special cased to skip
over the "ro." part of the prefix before matching with entries in
property_contexts.  This is not strictly needed however and it is
causing complications with the separated prop files work from Bug
21852512, so it is now removed.

Bug 26425619

Change-Id: I3cd14fa2176f96b3931e5f6a50c4a7bcd3af3da6
2016-01-11 14:00:40 -08:00
Colin Cross
51aaecea35 Merge "libinit: depend on libselinux" am: 710056efb8
am: f97f11f8c1

* commit 'f97f11f8c14e3efbd3e3840ba8ba1ea8c027e8f7':
  libinit: depend on libselinux
2016-01-08 20:57:18 +00:00
Bertrand Simonnet
530c8c75e2 Merge "init: Allows shutting down cleanly." am: f9f4ee8b72
am: a8c931b7f5

* commit 'a8c931b7f57c8ce74f520d591e99bb367f91dc81':
  init: Allows shutting down cleanly.
2016-01-08 20:54:11 +00:00
Colin Cross
710056efb8 Merge "libinit: depend on libselinux" 2016-01-08 20:49:42 +00:00
Bertrand SIMONNET
b7e03e82b8 init: Allows shutting down cleanly.
When ro.build.shutdown_timeout is set, init will send a SIGTERM signal to
all services on reboot. The normal shutdown process will continue once
all services have exited or after the shutdown timeout
(ro.build.shutdown_timeout).

If ro.build.shutdown_timeout is not set, we assume a 0s timeout.

Bug: 26216447
Test: manual: Ask to reboot. All services exit cleanly.

Change-Id: If921f6e8d87211e500ac9fa86f3e1eabe02d18cf
2016-01-08 11:12:15 -08:00
Colin Cross
c1caf88f25 libinit: depend on libselinux
libinit uses headers from libselinux, add a LOCAL_STATIC_LIBRARIES
dependency.

Change-Id: I6b0a3183058c8593ef40e58abbf2d72bcce59e95
2015-12-21 16:14:08 -08:00
Tom Cherry
bcac4a98d4 Merge "Update init documentation to reflect fs_config changes" am: b11afd7741
am: 80625ed1c3

* commit '80625ed1c3674ab8abf56a7bacd5151215215020':
  Update init documentation to reflect fs_config changes
2015-12-11 14:19:10 -08:00
Tom Cherry
dbddb40c95 Update init documentation to reflect fs_config changes
Change-Id: I00296d90c44af369a51ecb5cbb667567328f0053
2015-12-11 13:20:38 -08:00
Sami Tolvanen
6401e61a6a Merge "Set up dm-verity in EIO mode instead of logging mode" am: 0d1214c68e
am: 42a86f8d1e

* commit '42a86f8d1e918356e86d4eb3fb2444a8c42d25ff':
  Set up dm-verity in EIO mode instead of logging mode
2015-12-10 15:43:02 -08:00
Sami Tolvanen
0d1214c68e Merge "Set up dm-verity in EIO mode instead of logging mode" 2015-12-10 20:12:49 +00:00
Paul Lawrence
c5733cfadb Add createuserkey
Needed so we can make the user0 key on first boot

Change-Id: I4699dbf2efdec44bb09bc4cfa7eeb59e56cb93ab
2015-12-09 15:34:18 -08:00
Sami Tolvanen
9e9efcadc5 init: set ro.boot.flash.locked from ro.boot.verifiedbootstate
If ro.oem_unlock_supported is specified for the device and it supports
verified boot, export lock status in ro.boot.flash.locked.

Bug: 26039090
Change-Id: Ie7844aeb458c97944c72d46ea962b9cfb0a7875d
2015-12-09 10:09:11 +00:00
Tom Cherry
1563d6546c Remove property_area_initialized
This is deadcode as property_init() will only ever be called once and
the only remaining caller of properties_initialized() is
Service::NotifyStateChange() which can only be called after properties
have been initialized.

Change-Id: Ie071af84fcdbead72d259890fc8fb8db624282e7
2015-12-07 17:53:39 -08:00
Tom Cherry
c68998441c Merge "Remove ANDROID_PROPERTY_WORKSPACE" 2015-12-08 01:29:53 +00:00
Elliott Hughes
4f71319df0 Track rename of base/ to android-base/.
Change-Id: Idf9444fece4aa89c93e15640de59a91f6e758ccf
2015-12-04 22:00:26 -08:00
Tom Cherry
265f525e21 Remove ANDROID_PROPERTY_WORKSPACE
Bug 23290008

Change-Id: I95babe735444ada10c67594ace700cae5d1ec0b3
2015-12-04 14:11:02 -08:00
Tom Cherry
6036114f93 Abort if __system_property_area_init fails
If __system_property_area_init() fails, there is a fundamental issue
with the system and we should abort from init.

Bug: 21852512
Change-Id: I05d7978ba3bcc347027a6d9443de7cdd229033d2
2015-12-02 11:29:12 -08:00
Sami Tolvanen
90f52df257 Set up dm-verity in EIO mode instead of logging mode
If the device is corrupted, set up dm-verity in EIO mode instead of
logging mode. This prevents corrupted blocks from being returned to
user space. Note that restart mode is used by default and a warning
will be displayed to the user after corruption is first detected.

Bug: 19277516
Change-Id: I38966d73eb814836bc34b4bad1192583e5010b36
2015-12-02 14:38:01 +00:00
Tom Cherry
e36a85cdcc restorecon /property_contexts
/property_contexts exists before selinux policies are loaded, so we must
restorecon before other processes can access it

Bug: 21852512
Change-Id: Ie983caac635eb928ab19eea996a5625f3673de39
2015-12-01 17:47:35 -08:00
Nick Kralevich
83ccb1c76b init: Don't ignore setsockcreatecon errors
The init language supports setting the creation context of a socket
as the 6th argument to the socket keyword. For example, in the
following service, the context associated with the netd socket
is u:r:netd:s0

service netd /system/bin/netd
    class main
    socket netd stream 0660 root system u:r:netd:s0
    socket dnsproxyd stream 0660 root inet
    socket mdns stream 0660 root system
    socket fwmarkd stream 0660 root inet

The 6 argument form of the socket statement is rarely if ever used,
since the init code supplies a sensible default.

Currently, there's no error checking on the value supplied as
the 6th argument. For example, if you have the following socket
statement:

  socket netd stream 0660 root system graphics

a socket will attempt to get created with an invalid "graphics"
context. When setsockcreatecon fails, it retains the default socket
creation context, which for init is u:r:init:s0. This results in a
socket being created which is in an unexpected context.

Check the return value from the setsockcreatecon() call. If an
invalid context is specified, return early and don't subsequently
attempt to create the socket with the default context.

Bug: 25851205
Change-Id: Ic66cd6f7efe3897fb247b587ddeac5d35e1602b7
2015-11-23 17:09:49 -08:00
Nick Kralevich
2d8f1d4c47 Merge "Enable hidepid=2 on /proc" 2015-11-09 20:05:22 +00:00
Nick Kralevich
c39ba5ae32 Enable hidepid=2 on /proc
Add the following mount options to the /proc filesystem:

  hidepid=2,gid=3009

This change blocks /proc access unless you're in group 3009
(aka AID_READPROC).

Please see
  https://github.com/torvalds/linux/blob/master/Documentation/filesystems/proc.txt
for documentation on the hidepid option.

hidepid=2 is preferred over hidepid=1 since it leaks less information
and doesn't generate SELinux ptrace denials when trying to access
/proc without being in the proper group.

Add AID_READPROC to processes which need to access /proc entries for
other UIDs.

Bug: 23310674
Change-Id: I22bb55ff7b80ff722945e224845215196f09dafa
2015-11-09 09:08:46 -08:00
Rom Lemarchand
1dcf325844 init: skip "name" DT entry
DTs have a standard "name" entry which is not to be
turned into an android property, so skip it.

Change-Id: I79f6638b4123358c8d80510c1666cf5d4561160e
2015-11-08 17:51:50 -08:00
Daniel Cashman
27ff12443d Merge "init/adb: correct static lib dependencies for libselinux"
am: 38aee48fc6

* commit '38aee48fc695c25e15435e4ef235c8bc2e0afde9':
  init/adb: correct static lib dependencies for libselinux
2015-10-22 23:12:22 +00:00
Daniel Cashman
38aee48fc6 Merge "init/adb: correct static lib dependencies for libselinux" 2015-10-22 23:03:51 +00:00
William Roberts
bd2d961cc2 init/adb: correct static lib dependencies for libselinux
Now that libselinux uses libpackagelistparser, in order
for libpackagelistparser to be properly statically linked
liblog must come after libselinux for all the liblog
references to be defined in libpackagelistparser which
is included in libselinux. This patch corrects that order.

Change-Id: I7aee10c9395310919779ed2463aab6b2f8b380cc
Signed-off-by: William Roberts <william.c.roberts@intel.com>
2015-10-22 15:21:26 -07:00
Dan Willemsen
eea68c6f98 Merge "Remove __DATE__/__TIME__ from init and debuggerd"
am: 512b0e60b4

* commit '512b0e60b4fb33ec5535c1784a99a27539787790':
  Remove __DATE__/__TIME__ from init and debuggerd
2015-10-22 22:00:20 +00:00
Dan Willemsen
30622bbb20 Remove __DATE__/__TIME__ from init and debuggerd
Keeping these means that every build has different init and debuggerd
binaries, even if the source was the same. So OTAs that don't touch
these sources would still need to update the binaries.

Both of these messages are only informational, so can be safely removed.
Bootchart already encodes build-specific information from the system
properties.

Bug: 24204119
Change-Id: I7ebd65a20a3e031e7528c9f741616e20b3cd7446
2015-10-22 13:12:18 -07:00
Sami Tolvanen
234aedfaf1 am b8cc70a9: Merge "Error correction: Use libfec in fs_mgr"
* commit 'b8cc70a94bcbf7b920465d92da6889f0db6d6fa5':
  Error correction: Use libfec in fs_mgr
2015-10-16 05:53:55 +00:00
Sami Tolvanen
99e3a927e8 Error correction: Use libfec in fs_mgr
Use libfec to read and parse verity metadata to protect against data
corruption.

Bug: 21893453
Change-Id: I3a3543e0d999316707302b3be8735a7133d22946
2015-10-14 22:12:04 +01:00
Sami Tolvanen
415f1bdcbf am 4bd3148e: Merge "Revert "Error correction: Use libfec in fs_mgr""
* commit '4bd3148e0f509efb75256a01959c9c1af9ffa845':
  Revert "Error correction: Use libfec in fs_mgr"
2015-10-14 19:52:24 +00:00
Sami Tolvanen
0923453462 Revert "Error correction: Use libfec in fs_mgr"
This reverts commit 3de3a0f351.

Change-Id: I1f121cbc4431b8d8ff146eab29832a8dda1eb8ba
2015-10-14 19:46:16 +00:00
Sami Tolvanen
81ef65827c am a2cfddd3: Merge "Error correction: Use libfec in fs_mgr"
* commit 'a2cfddd37e950ed75d72e6a968d7be974aac405f':
  Error correction: Use libfec in fs_mgr
2015-10-14 16:40:33 +00:00
Sami Tolvanen
3de3a0f351 Error correction: Use libfec in fs_mgr
Use libfec to read and parse verity metadata to protect against data
corruption.

Bug: 21893453
Change-Id: Ieee6a1441e2f68148ba635235216e36c69b13db1
2015-10-13 15:53:25 +01:00
Nick Kralevich
545b7c9e39 am 2fb90dc8: Merge changes from topic \'userspace-audit\'
* commit '2fb90dc8b2b590e674c5e433e8bf3d3f08a887c8':
  debuggerd: audit pid, uid and gid on SE Linux denial
  property_service: log pid,uid and gid of setprop client
2015-10-10 20:11:08 +00:00
Nick Kralevich
2fb90dc8b2 Merge changes from topic 'userspace-audit'
* changes:
  debuggerd: audit pid, uid and gid on SE Linux denial
  property_service: log pid,uid and gid of setprop client
2015-10-10 20:07:24 +00:00
Elliott Hughes
17ac480df2 am 55793400: Merge "init shouldn\'t call DumpState by default."
* commit '55793400f20e5160eaab6c85e5df621f48373ec2':
  init shouldn't call DumpState by default.
2015-10-09 21:30:35 +00:00
Elliott Hughes
1946d3bca8 init shouldn't call DumpState by default.
The cost of generating and throwing away a bunch of stuff that no one
normally sees is high enough to be worth avoiding.

Here's AOSP ToT on N9...

 init: (Parsing /system/etc/init/atrace.rc took 0.0112s.)
 init: (Parsing /system/etc/init/bootanim.rc took 0.0094s.)
 init: (Parsing /system/etc/init/crash_reporter.rc took 0.0103s.)
 init: (Parsing /system/etc/init/debuggerd.rc took 0.0090s.)
 init: (Parsing /system/etc/init/debuggerd64.rc took 0.0085s.)
 init: (Parsing /system/etc/init/drmserver.rc took 0.0078s.)
 init: (Parsing /system/etc/init/dumpstate.rc took 0.0073s.)
 init: (Parsing /system/etc/init/gatekeeperd.rc took 0.0063s.)
 init: (Parsing /system/etc/init/installd.rc took 0.0067s.)
 init: (Parsing /system/etc/init/keystore.rc took 0.0060s.)
 init: (Parsing /system/etc/init/lmkd.rc took 0.0060s.)
 init: (Parsing /system/etc/init/logcatd.rc took 0.0059s.)
 init: (Parsing /system/etc/init/logd.rc took 0.0068s.)
 init: (Parsing /system/etc/init/mdnsd.rc took 0.0057s.)
 init: (Parsing /system/etc/init/mediaserver.rc took 0.0064s.)
 init: (Parsing /system/etc/init/metrics_daemon.rc took 0.0063s.)
 init: (Parsing /system/etc/init/mtpd.rc took 0.0055s.)
 init: (Parsing /system/etc/init/netd.rc took 0.0066s.)
 init: (Parsing /system/etc/init/perfprofd.rc took 0.0057s.)
 init: (Parsing /system/etc/init/racoon.rc took 0.0054s.)
 init: (Parsing /system/etc/init/rild.rc took 0.0061s.)
 init: (Parsing /system/etc/init/servicemanager.rc took 0.0063s.)
 init: (Parsing /system/etc/init/surfaceflinger.rc took 0.0061s.)
 init: (Parsing /system/etc/init/uncrypt.rc took 0.0068s.)
 init: (Parsing /system/etc/init/vdc.rc took 0.0065s.)
 init: (Parsing /system/etc/init/vold.rc took 0.0063s.)

0.0112+0.0094+0.0103+0.0090+0.0085+0.0078+0.0073+0.0063+0.0067+0.0060+
0.0060+0.0059+0.0068+0.0057+0.0064+0.0063+0.0055+0.0066+0.0057+0.0054+
0.0061+0.0063+0.0061+0.0068+0.0065+0.0063 = 0.1809

And here it is again with the logging disabled:

 init: (Parsing /system/etc/init/atrace.rc took 0.0021s.)
 init: (Parsing /system/etc/init/bootanim.rc took 0.0006s.)
 init: (Parsing /system/etc/init/crash_reporter.rc took 0.0007s.)
 init: (Parsing /system/etc/init/debuggerd.rc took 0.0004s.)
 init: (Parsing /system/etc/init/debuggerd64.rc took 0.0005s.)
 init: (Parsing /system/etc/init/drmserver.rc took 0.0005s.)
 init: (Parsing /system/etc/init/dumpstate.rc took 0.0005s.)
 init: (Parsing /system/etc/init/gatekeeperd.rc took 0.0005s.)
 init: (Parsing /system/etc/init/installd.rc took 0.0005s.)
 init: (Parsing /system/etc/init/keystore.rc took 0.0013s.)
 init: (Parsing /system/etc/init/lmkd.rc took 0.0006s.)
 init: (Parsing /system/etc/init/logcatd.rc took 0.0013s.)
 init: (Parsing /system/etc/init/logd.rc took 0.0007s.)
 init: (Parsing /system/etc/init/mdnsd.rc took 0.0005s.)
 init: (Parsing /system/etc/init/mediaserver.rc took 0.0009s.)
 init: (Parsing /system/etc/init/metrics_daemon.rc took 0.0008s.)
 init: (Parsing /system/etc/init/mtpd.rc took 0.0011s.)
 init: (Parsing /system/etc/init/netd.rc took 0.0005s.)
 init: (Parsing /system/etc/init/perfprofd.rc took 0.0005s.)
 init: (Parsing /system/etc/init/racoon.rc took 0.0005s.)
 init: (Parsing /system/etc/init/rild.rc took 0.0005s.)
 init: (Parsing /system/etc/init/servicemanager.rc took 0.0005s.)
 init: (Parsing /system/etc/init/surfaceflinger.rc took 0.0005s.)
 init: (Parsing /system/etc/init/uncrypt.rc took 0.0005s.)
 init: (Parsing /system/etc/init/vdc.rc took 0.0005s.)
 init: (Parsing /system/etc/init/vold.rc took 0.0006s.)

0.0021+0.0006+0.0007+0.0004+0.0005+0.0005+0.0005+0.0005+0.0005+0.0013+
0.0006+0.0013+0.0007+0.0005+0.0009+0.0008+0.0011+0.0005+0.0005+0.0005+
0.0005+0.0005+0.0005+0.0005+0.0005+0.0006 = 0.0181

It's less than a second, but one problem is that the cost of the current
dumping is proportional to the number of init.rc files, so the more
cleanly you factor things, the more it would cost.

Change-Id: Id96f59e7d0b082d8cfdba4bdbff43a922ba4eeee
2015-10-09 14:03:14 -07:00
William Roberts
d7aea443d9 property_service: log pid,uid and gid of setprop client
When auditing setprop denials, it is often unclear of who the process is
in a multi-process domain. To help identify the invoker, log the pid, uid,
and gid of the caller.

Before:
avc:  denied  { set } for property=wifi.xxx ...

After:
avc:  denied  { set } for property=wifi.xxx pid=30691 uid=123 gid=345 ...

Change-Id: I5cdcb3d18fbd52e0987b5e1497b9f6620c6c742a
Signed-off-by: William Roberts <william.c.roberts@intel.com>
2015-10-05 11:39:56 -07:00
Yasuhiro Matsuda
4bc228e317 am f656b683: am ada7fa06: Merge "Fix perfboot.py to work with the recent change."
* commit 'f656b683a6a09dd2ed2934de2e1d5c2044c1fbe2':
  Fix perfboot.py to work with the recent change.
2015-09-16 02:58:28 +00:00
Yasuhiro Matsuda
f656b683a6 am ada7fa06: Merge "Fix perfboot.py to work with the recent change."
* commit 'ada7fa063e4d8e2b8014a138bdf58d7729ce0ee9':
  Fix perfboot.py to work with the recent change.
2015-09-16 02:49:31 +00:00
Yasuhiro Matsuda
6ee194013a Fix perfboot.py to work with the recent change.
device.shell() was changed to return a (stdout, stderr) tuple in
the following CL.

https://android-review.googlesource.com/170420

This CL fixes perfboot.py to work with the return value.

Change-Id: I85d72fc63c1f96257fb19c3051482991a7b4049d
2015-09-15 14:00:10 +09:00
Tom Cherry
a2bdc2d91e am f23ef77f: am 4aa9dbab: Merge "init: Update readme.txt to reflect recent changes to init."
* commit 'f23ef77ffe4700221bc47c70ea1b7f1473d0d902':
  init: Update readme.txt to reflect recent changes to init.
2015-09-02 19:48:22 +00:00
Tom Cherry
f23ef77ffe am 4aa9dbab: Merge "init: Update readme.txt to reflect recent changes to init."
* commit '4aa9dbab6f78a1acae02d39b96fa572fbfc7b6ed':
  init: Update readme.txt to reflect recent changes to init.
2015-09-02 19:37:35 +00:00
Tom Cherry
3be66edc59 init: Update readme.txt to reflect recent changes to init.
Updates are as follows:

A detailed explanation of event triggers and property triggers
including how they can now be used

A new section describing .rc files, their locations, and the
intentions for each of these locations

A new section describing the import keyword and how it is not a
command but rather its own section

Removal of deprecated or incorrect text

Change-Id: If0a37375ac92a857900f3303ada4ba742360daff
2015-09-01 15:32:33 -07:00
Tom Cherry
af20a7cb12 resolved conflicts for merge of cda81d01 to mnc-dr-dev-plus-aosp
Change-Id: I747b279bc49f9f82b8f8859c49b3fc2a4e3b4977
2015-09-01 15:30:56 -07:00
Tom Cherry
cda81d01c6 am 54c70ca1: Merge "init: Use classes for parsing and clean up memory allocations"
* commit '54c70ca15660529466b5b4e091209a20a3e75dff':
  init: Use classes for parsing and clean up memory allocations
2015-09-01 21:42:01 +00:00
Tom Cherry
b7349902a9 init: Use classes for parsing and clean up memory allocations
Create a Parser class that uses multiple SectionParser interfaces to
handle parsing the different sections of an init rc.

Create an ActionParser and ServiceParser that implement SectionParser
and parse the sections corresponding to Action and Service
classes.

Remove the legacy keyword structure and replace it with std::map's
that map keyword -> (minimum args, maximum args, function pointer) for
Commands and Service Options.

Create an ImportParser that implements SectionParser and handles the
import 'section'.

Clean up the unsafe memory handling of the Action class by using
std::unique_ptr.

Change-Id: Ic5ea5510cb956dbc3f78745a35096ca7d6da7085
2015-09-01 12:26:02 -07:00