Commit graph

1230 commits

Author SHA1 Message Date
dcashman
2fae5d65d5 Compile sepolicy on-device at early boot.
Compile policy from disparate sources at beginning of init and use to load
rather than relying on prebuilt policy.

Bug: 31363362
Test: Policy builds on-device and boots.
Change-Id: I681ec3f7da351d0b24d1f1e81e8a6b00c9c9d20c
2016-12-16 14:02:31 -08:00
Treehugger Robot
044b18cb7f Merge "capabilities: Check ambient caps, last valid runtime cap." 2016-12-16 19:50:34 +00:00
Jorge Lucangeli Obes
f3f824ee42 capabilities: Check ambient caps, last valid runtime cap.
Partners have expressed interest in using the 'capabilities' keyword
in init, so make the code more resilient:
-Check that ambient capabilities are supported by the kernel.
-Check that the last valid cap at runtime is not higher than what's in
kernel headers.
-Check that the user is not requesting a capability present in kernel
headers but not supported by the kernel at runtime.
-Don't attempt to drop bounding set capabilities not supported at
runtime.

This CL also fixes a small bug where < should have been used instead of
<=, and uses 'static' instead of anonymous namespaces.

Bug: 32438163
Test: Use a test service that uses capabilities.
Test: Apply in internal tree and test with angler and rild.

Change-Id: Ia271cc7eb389d1d526d61f897261e4bac4d19e5d
2016-12-16 13:04:52 -05:00
Elliott Hughes
4ee7861ee1 Merge "Improve init bootcharting." 2016-12-16 17:32:27 +00:00
Treehugger Robot
d9b9ebb887 Merge "init: Specify the data wipe reason." 2016-12-14 21:08:40 +00:00
Tao Bao
fdf1a54f45 init: Specify the data wipe reason.
We should say that if the data wipe is triggered by fs_mgr_mount_all.

Test: mmma system/core/init
Change-Id: I3998d9493611ecc286de0913a95cf22fc41100b5
2016-12-14 12:12:32 -08:00
Treehugger Robot
a95e9aff7c Merge "Remove obsolete __BRILLO__ ifdef." 2016-12-14 19:14:08 +00:00
Jorge Lucangeli Obes
405da69b27 Remove obsolete __BRILLO__ ifdef.
Confirmed with Brillo TL this is not needed.

Bug: 33620501
Test: Builds, boots on HiKey.
Change-Id: I8d6b7cc2a94e668d63421c456d38fe23877c3cf0
2016-12-14 13:25:25 -05:00
dcashman
41d0b6d3ca Convert missed ERROR() to LOG(ERROR).
commit: f86b5a6b90 converted init to
libbase logging, but the internal resolution, commit:
4dc40842ba missed one.  Convert it.

Test: builds.
Change-Id: Ic190bd8ce232de0acadd980a349de95fa8aed8ad
2016-12-14 08:38:23 -08:00
Elliott Hughes
99dae54874 Fix include order.
(cherry-pick of commit: 79f2b33594)

Test: builds
Change-Id: I865044c8c54591582e7bb1b7a055cf7ba2f17464
2016-12-14 08:16:07 -08:00
Daniel Cashman
baccc40841 Set mmap_rnd_bits to maximum value.
This is a cherry-pick of internal commit:
f611291688 which was a revert of a
revert, specifically a  revert of commit:
c8f026fc9c.

The above revert was meant only for AOSP, since the kernel prebuilts
were not yet available there.  The revert was reverted internally so
that internal builds, which have the appropriate kernel prebuilts,
operated properly.

The very first commit was originally done in nougat-dev and cherry-picked
to AOSP, so it was not picked up again when nougat landed in master.  Add
it now.

Bug: 27681085
Test: Builds and boots.
Change-Id: If1cb6308e61aaaabca5b5bd30df78aab49e7b0d5
2016-12-14 07:48:36 -08:00
Nick Kralevich
9596d2b95d init/service.cpp: fix FD leak for services with consoles
When init starts a service with a console, it tests for the presence of
a readable/writable console device. The test results in a leaked file
descriptor.

Use access() instead of open() to avoid leaking file descriptors.

Bug introduced in 70daa67062.

Test: compiles and device boots
Change-Id: I4efcfa0bb2cdb09f0455bc04a3a91e784bda7962
2016-12-10 12:20:11 -08:00
Elliott Hughes
a3641af22f Improve init bootcharting.
Most notably, there's no longer any need to guess an end time.

Bug: http://b/23478578
Bug: http://b/33450491
Test: rebooted with bootcharting on/off
Change-Id: Icb7d6859581da5526d77dfc5aa4d57c9bfbfd7e2
2016-12-08 17:35:45 -08:00
Elliott Hughes
422a5128dd Merge "The "net.change" property is no longer needed."
am: e209ed7c44

Change-Id: I45a1ce3a1527a72e7ae974fd4dab7b77c6a899ee
2016-12-06 02:49:59 +00:00
Treehugger Robot
e209ed7c44 Merge "The "net.change" property is no longer needed." 2016-12-06 02:46:43 +00:00
Mark Salyzyn
1f22788f9e Merge "init: service file command only opens existing files"
am: bd3f42016d

Change-Id: Id4c0e6b26e8b3295ebfd5387bfad2e8795531175
2016-12-05 21:37:38 +00:00
Elliott Hughes
4f9158119b The "net.change" property is no longer needed.
bionic was the only listener, and it was doing nothing useful when the
property changed, so we've removed that listener.

Bug: http://b/33308258
Test: DNS still works
Change-Id: I15292e8e58e6b87cdad8f73e449ccaf334dff68b
2016-12-05 13:12:48 -08:00
Mark Salyzyn
978fd0ea25 init: service file command only opens existing files
Mixing open or create, along with attribute(MAC) and permissions(DAC)
is a security and confusion issue.

Fix an issue where fcntl F_SETFD was called to clear O_NONBLOCK, when
it should have been F_SETFL.  Did not present a problem because the
current user of this feature does writes and control messages only.

Test: gTest logd-unit-tests and check dmesg for logd content.
Bug: 32450474
Bug: 33242020
Change-Id: I23cb9a9be5ddb7e8e9c58c79838bc07536e766e6
2016-12-05 11:26:39 -08:00
Elliott Hughes
8cf9d66486 Merge "Replace the "coldboot" timeout with a property."
am: e218fc673f

Change-Id: Ibaf1f7ad3a90e5216db04506288df51258e19f4b
2016-12-05 18:04:27 +00:00
Elliott Hughes
331cf2fb7c Replace the "coldboot" timeout with a property.
Also rename init's existing boot-time related properties so they're
all "ro.*" properties.

Example result:

  # Three properties showing when init started...
  [ro.boottime.init]: [5294587604]
  # ...how long it waited for ueventd...
  [ro.boottime.init.cold_boot_wait]: [646956470]
  # ...and how long SELinux initialization took...
  [ro.boottime.init.selinux]: [45742921]

  # Plus one property for each service, showing when it first started.
  [ro.boottime.InputEventFind]: [10278767840]
  [ro.boottime.adbd]: [8359267180]
  [ro.boottime.atfwd]: [10338554773]
  [ro.boottime.audioserver]: [10298157478]
  [ro.boottime.bootanim]: [9323670089]
  [ro.boottime.cameraserver]: [10299402321]
  [ro.boottime.cnd]: [10335931856]
  [ro.boottime.debuggerd]: [7001352774]
  [ro.boottime.debuggerd64]: [7002261785]
  [ro.boottime.drm]: [10301082113]
  [ro.boottime.fingerprintd]: [10331443314]
  [ro.boottime.flash-nanohub-fw]: [6995265534]
  [ro.boottime.gatekeeperd]: [10340355242]
  [ro.boottime.healthd]: [7856893380]
  [ro.boottime.hwservicemanager]: [7856051088]
  [ro.boottime.imscmservice]: [10290530758]
  [ro.boottime.imsdatadaemon]: [10358136702]
  [ro.boottime.imsqmidaemon]: [10289084872]
  [ro.boottime.installd]: [10303296020]
  [ro.boottime.irsc_util]: [10279807632]
  [ro.boottime.keystore]: [10305034093]
  [ro.boottime.lmkd]: [7863506714]
  [ro.boottime.loc_launcher]: [10324525241]
  [ro.boottime.logd]: [6526221633]
  [ro.boottime.logd-reinit]: [7850662702]
  [ro.boottime.mcfg-sh]: [10337268315]
  [ro.boottime.media]: [10312152687]
  [ro.boottime.mediacodec]: [10306852530]
  [ro.boottime.mediadrm]: [10308707999]
  [ro.boottime.mediaextractor]: [10310681177]
  [ro.boottime.msm_irqbalance]: [7862451974]
  [ro.boottime.netd]: [10313523104]
  [ro.boottime.netmgrd]: [10285009351]
  [ro.boottime.oem_qmi_server]: [10293329092]
  [ro.boottime.per_mgr]: [7857915776]
  [ro.boottime.per_proxy]: [8335121605]
  [ro.boottime.perfd]: [10283443101]
  [ro.boottime.qcamerasvr]: [10329644772]
  [ro.boottime.qmuxd]: [10282346643]
  [ro.boottime.qseecomd]: [6855708593]
  [ro.boottime.qti]: [10286196851]
  [ro.boottime.ril-daemon]: [10314933677]
  [ro.boottime.rmt_storage]: [7859105047]
  [ro.boottime.servicemanager]: [7864555881]
  [ro.boottime.ss_ramdump]: [8337634938]
  [ro.boottime.ssr_setup]: [8336268324]
  [ro.boottime.surfaceflinger]: [7866921402]
  [ro.boottime.thermal-engine]: [10281249924]
  [ro.boottime.time_daemon]: [10322006542]
  [ro.boottime.ueventd]: [5618663938]
  [ro.boottime.vold]: [7003493920]
  [ro.boottime.wificond]: [10316641073]
  [ro.boottime.wpa_supplicant]: [18959816881]
  [ro.boottime.zygote]: [10295295029]
  [ro.boottime.zygote_secondary]: [10296637269]

Bug: http://b/31800756
Test: boots
Change-Id: I094cce0c1bab9406d950ca94212689dc2e15dba5
2016-12-03 10:54:26 -08:00
Wei Wang
c746ecbcbe Merge "init: don't wait if we have more work to do"
am: 32ee9fc24a

Change-Id: Ie260a9e3d491b9108dc7681ede5a0e3ceac9ef79
2016-12-01 03:51:19 +00:00
Wei Wang
16db4346a2 init: don't wait if we have more work to do
Bug: 33212253
Test: On marlin
Change-Id: I8502eaa73fac6953d358af01482760b3249cfd67
2016-11-30 18:09:29 -08:00
Elliott Hughes
65016074c2 Merge "init: Fix sync issue on property trigger."
am: 80d2f01fbf

Change-Id: Iae57b79abeb7a372c0e483316d328d5307c66b73
2016-11-30 17:54:31 +00:00
caozhiyuan
b104c502e1 init: Fix sync issue on property trigger.
This issue reproduces in the following senario.
 1. ("", "") is added to queue;
 2. property_triggers_enabled is set to 1;
 3. user defined property is triggered, like sys.usb.config=adb;
 4. ("sys.usb.config", "adb") is added to queue;
 5. main loop interpret ("", "") and queue all current triggers to execution,
    so ("sys.usb.config", "adb") is queued for execution for the first time.
 6. main loop interpret ("sys.usb.config", "adb"), it is queued for
    execution for a second time.
The second time makes ASIT fail.

Bug: http://b/28218187
Change-Id: I230e175e0dca8989f1e5bd812398da90082d0ec1
Signed-off-by: caozhiyuan <cao.zhiyuan@zte.com.cn>
2016-11-29 20:19:17 +00:00
Elliott Hughes
c509c36892 Merge "Revert "init: Reworked how we wait for COLDBOOT_DONE""
am: a10bd47d60

Change-Id: Ibad56dbe843c16863a70552ea27aa3e7ffca0787
2016-11-29 18:14:19 +00:00
Billy Lau
6be1d976f6 Merge "init: Reworked how we wait for COLDBOOT_DONE"
am: 57c31d0f17

Change-Id: I40c0183e3bc22bc85977e4e8db3b4ce6ad76375e
2016-11-29 16:36:37 +00:00
Elliott Hughes
a452660d92 Revert "init: Reworked how we wait for COLDBOOT_DONE"
This reverts commit d36115ef2f.

Change-Id: I599b0eeebf9c062852323f2a4a986b18dd85288a
2016-11-29 16:34:56 +00:00
Billy Lau
d36115ef2f init: Reworked how we wait for COLDBOOT_DONE
Bug: 31800756

Instead of strictly timing out after 1s waiting for COLDBOOT_DONE,
we wait for a considerably longer period of time, which would also
allow slower non-production heavily instrumented debug builds to
boot up.

Upon successful wait, we measure the time taken and record the
value into a system property: ro.cold_boot.duration.

If timeout is still reached, we log an error message and abandon
boot process, rebooting into recovery mode instead.

Change-Id: Ic1df80546d8721b0e8c998ff294d5c5102de4e98
2016-11-22 21:25:02 +00:00
Evgenii Stepanov
4b1a329309 Merge "Revert "Revert "init: create /dev/urandom, /dev/random in first stage."""
am: b6552f376c

Change-Id: I3291276426ad5e1acb457da7ad938958d7f0f461
2016-11-19 00:51:33 +00:00
Evgenii Stepanov
102daa30a3 Revert "Revert "init: create /dev/urandom, /dev/random in first stage.""
This reverts commit 4c8a76e250.

Test: booted angler-userdebug

Change-Id: I2257a44b7cf624065e5653754062a117f3e44c98
2016-11-18 15:09:18 -08:00
Wei Wang
5514c50292 Merge "init: move empty string check to InitTriggers"
am: 9bf10ff61e

Change-Id: I7190f8bd86707b2adc4dbeffa0085ce3a190d680
2016-11-17 19:32:19 +00:00
Wei Wang
9bf10ff61e Merge "init: move empty string check to InitTriggers" 2016-11-17 19:21:47 +00:00
Paul Lawrence
ffa3689107 Merge "Add flags to restorecon_recursive to traverse filesystems"
am: 5fbd1cfd34

Change-Id: I539d7e9d441c7bb3f5602b892408a85436b857e8
2016-11-17 17:55:06 +00:00
Treehugger Robot
5fbd1cfd34 Merge "Add flags to restorecon_recursive to traverse filesystems" 2016-11-17 17:39:53 +00:00
Mark Salyzyn
809dee506e Merge "libcutils: move cutils/files.h to cutils/android_get_control_file.h"
am: 8c41e791ed

Change-Id: Ifbc00285da734859d590153a7c6cfc8e51c014f9
2016-11-17 15:33:02 +00:00
Mark Salyzyn
8c41e791ed Merge "libcutils: move cutils/files.h to cutils/android_get_control_file.h" 2016-11-17 15:22:14 +00:00
Wei Wang
93df4e18a2 init: move empty string check to InitTriggers
Test: mma
Bug: 32838381
Change-Id: I69203734ef7d3640da75f3e3cbe9254bf468d916
2016-11-16 22:24:43 -08:00
Wei Wang
279f3d593f init: fix undefined behavior in ExecuteCommand
am: d67a4abc64

Change-Id: I1ecbb1d083af62dd5e69b4cff19ec411016054f3
2016-11-17 03:54:57 +00:00
Wei Wang
3567c7c9d9 Revert "Revert "init: warn slow action""
am: 8b1d526a72

Change-Id: Ie067e37758ae28fece1732ab7697e2a1286594dc
2016-11-17 03:54:51 +00:00
Wei Wang
2369b1eb80 Merge changes from topic 'slow_log'
* changes:
  init: fix undefined behavior in ExecuteCommand
  Revert "Revert "init: warn slow action""
2016-11-17 03:46:44 +00:00
Mark Salyzyn
52bd37e633 libcutils: move cutils/files.h to cutils/android_get_control_file.h
files.[h|cpp] is bound to be abused with junk, replace with
android_get_control_file.[h|cpp]. Plus some sundry cleanup.

Test: gTest libcutils-tests, logd-unit-tests, liblog-unit-tests,
      logcat-unit-tests and init_tests
Bug: 32450474
Change-Id: Ibd4a7aa4624ea19a43d1f98a3c71ac37805d36b5
2016-11-16 15:56:56 -08:00
Wei Wang
d67a4abc64 init: fix undefined behavior in ExecuteCommand
ExecuteCommand may change command_ vector which leads undefined behavior
This bug is found when adding logs in ExecuteCommand printing our Command class fields

Bug: 32838381
Test: on emulator
Change-Id: I96468bd2192ca80013871a3a6ac4132149363fff
2016-11-16 15:46:19 -08:00
Paul Lawrence
a8d8434c42 Add flags to restorecon_recursive to traverse filesystems
Use to solve the problem of tracefs conditionally being mounted
under debugfs and needing restorecon'd without boot performance
penalty.

Also move skip-ce to a flag for consistency.

Test: Check that trace_mount has correct attributes after boot
Bug: 32849675
Change-Id: Ib6731f502b6afc393ea5ada96fa95b339f14da49
2016-11-16 22:27:45 +00:00
Jeff Sharkey
d1d3bdd16f 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.

(cherrypicked from commit 1635afe83d)

Bug: 30126557
Test: Cherry-picked from master
Change-Id: I320584574a4d712c493b5bbd8a79b56c0c04aa58
2016-11-16 21:19:17 +00:00
Wei Wang
8b1d526a72 Revert "Revert "init: warn slow action""
This reverts commit 1802d11cc7.

Test: grep init log
Bug: 32712851
2016-11-15 23:58:55 -08:00
Ting-Yuan Huang
1700a162d5 Merge "init: fix memory leaks"
am: a73ba879b1

Change-Id: I3375372ddc23b7440edab0107ff1cbe34d550865
2016-11-16 03:32:40 +00:00
Treehugger Robot
a73ba879b1 Merge "init: fix memory leaks" 2016-11-16 03:25:34 +00:00
Ting-Yuan Huang
09bd41d097 init: fix memory leaks
It's possible that node is not freed before return.

Test: make WITH_TIDY=1 mmma system/core/init

Change-Id: I648eea9dda006d2b2239e169785190817ad31352
2016-11-15 16:55:50 -08:00
Elliott Hughes
3ee9807554 Merge "Switch fastboot/init/libprocessgroup to std::this_thread::sleep_for."
am: f3e731b3c5

Change-Id: I2028bb8835c5e55e1bf8c88c3395253ded9d66d3
2016-11-15 18:09:46 +00:00
Elliott Hughes
f3e731b3c5 Merge "Switch fastboot/init/libprocessgroup to std::this_thread::sleep_for." 2016-11-15 18:02:30 +00:00