Commit graph

1257 commits

Author SHA1 Message Date
Dimitry Ivanov
70c4ecf2b5 Revert "New protocol for property_service"
This reverts commit dee4bd236b.
Bug: http://b/33926793
Bug: http://b/34670529

Change-Id: Ife3a5a471ee29cb12c2c41efef885ba40b8970e6
2017-01-24 18:38:09 +00:00
Dimitry Ivanov
dee4bd236b New protocol for property_service
New protocol assumes that there is no limit on name or value
and effectively removed limit on property name length.

It also send back a uint32_t with error code (or 0 on success)

Bug: http://b/33926793
Test: mm, boot, run bionic-unit-tests --gtest_filter=prop*
Change-Id: Iac6290398ddc495e03f8fbbc3a79e923eff5df6f
2017-01-23 15:30:05 -08:00
Dave Weinstein
44f7e4f421 Move the kptr_restrict setting from init.rc to init.cpp.
Also ensure that it uses the highest supported value, and
abort if the value is not above a minimum threshold.

Test: Tested against the curent kernel (maximum value of 2,
      set to 0 by the kernel initially) and against a
      modified kernel (maximum value of 4, set to 4 by the
      kernel initially)

Bug: 30368199
Change-Id: I608db577258b68b390ffe96f452e1f7c0bc9ad8a
2017-01-20 09:40:43 -08:00
Treehugger Robot
8dbab358f0 Merge "Load default/build props from each partition" 2017-01-20 03:58:52 +00:00
Treehugger Robot
cfb8800e18 Merge "Enable seccomp in init with generated policy" 2017-01-19 23:26:10 +00:00
Jaekyun Seok
de21de7a42 Load default/build props from each partition
The following files will be loaded additionally.
- /odm/default.prop and /vendor/default.prop for default props.
- /odm/build.prop for build props.

The props files must follow the following priority order.
- /default.prop > /odm/default.prop > /vendor/default.prop
- /system/build.prop > /odm/build.prop > /vendor/buid.prop

Test: tested default/build prop files with enabling early mount, but
didn't test files of odm partition because odm partition doesn't
exist now.
Bug: 34116668
Change-Id: I946d076dae38f2288865dd986fb16d801d4abcc0
2017-01-19 08:45:40 +09:00
Jorim Jaggi
8e81cd6609 Merge "Revert "init: split property context into platform & non-platform components"" 2017-01-18 16:33:32 +00:00
Jorim Jaggi
328cb5d141 Revert "init: split property context into platform & non-platform components"
This reverts commit 871c306855.

Change-Id: I3e14b71e9fc5f37c9691405ce20031451643f9b4
2017-01-18 15:33:26 +00:00
Treehugger Robot
b8e5553887 Merge "init: split property context into platform & non-platform components" 2017-01-18 06:09:02 +00:00
Tao Bao
4c5c9db17b Merge "Revert "init: add ro.boot.init_rc"" 2017-01-17 20:19:23 +00:00
Tao Bao
01519a207c Revert "init: add ro.boot.init_rc"
This reverts commit 7e6d30e5f2.

Bug: 26639863
Bug: 34318089
Change-Id: Ie71d773ee7c6c6a90e8298f8e0798eacba12d0be
2017-01-17 20:16:45 +00:00
Treehugger Robot
0cf5e36c00 Merge "init: add ro.boot.init_rc" 2017-01-14 08:06:09 +00:00
Treehugger Robot
5d05d0e74e Merge "Move to .md files for even trivial documentation." 2017-01-13 19:39:26 +00:00
Elliott Hughes
15f0f504ac Move to .md files for even trivial documentation.
So it's automatically displayed for folks browsing the source.

Bug: N/A
Test: N/A
Change-Id: Ib595ab428054f274a92374728e3e66474ffc5116
2017-01-12 22:40:49 -08:00
Alex Deymo
b0c395955d Remove "_host" and "_static" suffix from libsparse definition.
This now combines all the "libsparse" libraries into the same soong
target. A minor side-effect of this change is that the libsparse
static library depends on the libz shared library instead of the libz
static library. This minor change has no effect since targets using
the static libsparse library need to explicitly include either the
static libz or the shared one.

Bug: 34220783
Change-Id: I8f41586cf4c3336791cfa57ab4f5ae59a76d7ffa
2017-01-11 19:15:11 -08:00
Hung-ying Tyan
7e6d30e5f2 init: add ro.boot.init_rc
SoC vendors and ODMs need a way to run different init scripts under
different boot modes. This patch adds a new ro.boot.init_rc kernel
cmdline argument to support this.

This patch also changes late-init trigger. Now late-init is only
triggered in "normal" boot (where boot mode is not specified). This is
to make AOSP init.rc re-usable in other boot modes as the operations
in late-init are less common.

Bug: 26639863
Test: Tested on bullhead with
  androidboot.init_rc = {non-existent .rc file}
  and/or
  androidboot.init_rc = {none empty string}
  both of which lead to expected boot failures.
  Boot succeeds if androidboot.init_rc is not specified.
Change-Id: Ie5f08c3914f2f825ad3c401fde6741459668c523
2017-01-12 10:08:30 +08:00
Alex Deymo
705353ae27 Remove "_static" and "_host" suffix from libext4_utils.
Bug: 34220783
Change-Id: I967dbaa9c48ad1feed2369c3a40f745b86a350f8
2017-01-11 14:05:42 -08:00
Paul Lawrence
db929bf9b7 Enable seccomp in init with generated policy
Test: Ran script to test performance - https://b.corp.google.com/issues/32313202#comment3
      Saw no significant regression with this change on or off
      Removed chroot from SYSCALLS.TXT - chroot blocked
      Boot time appears reasonable
      Device boots with no SECCOMP blockings
      Measured per syscall time of 100ns
      Empirically counted <100,000 syscalls a second under heavy load

Bug: 32313202
Change-Id: Icfcfbcb72b2de1b38f1ad6a82e8ece3bd1c9e7ec
2017-01-10 10:09:38 -08:00
Sandeep Patil
871c306855 init: split property context into platform & non-platform components
Bug: 33746484
Test: Successfully boot with original service and property contexts.
Test: Successfully boot with split serivce and property contexts.
Test: 'getprop -Z'
Change-Id: I62689b229a67e319c65bf034da804f660f82bd35
Signed-off-by: Sandeep Patil <sspatil@google.com>
2017-01-05 13:19:01 -08:00
Treehugger Robot
4a3b03e9e5 Merge "init/service.cpp: fix access check for console" 2017-01-03 23:27:40 +00:00
Nick Kralevich
8adb4d9d12 Send property_service AVC messages to the kernel audit system
The property service uses an SELinux userspace check to determine if a
process is allowed to set a property. If the security check fails, a
userspace SELinux denial is generated. Currently, these denials are only
sent to dmesg.

Instead of sending these denials to dmesg, send it to the kernel audit
system. This will cause these userspace denials to be treated similarly
to kernel generated denials (eg, logd will pick them up and process
them). This will ensure that denials generated by the property service
will show up in logcat / dmesg / event log.

After this patch, running "setprop asdf asdf" from the unprivileged adb
shell user will result in the following audit message:

  type=1107 audit(39582851.013:48): pid=1 uid=0 auid=4294967295
  ses=4294967295 subj=u:r:init:s0 msg='avc: denied { set } for
  property=asdf pid=5537 uid=2000 gid=2000 scontext=u:r:shell:s0
  tcontext=u:object_r:default_prop:s0 tclass=property_service'

Test: manual
Bug: 27878170
Change-Id: I0b8994888653501f2f315eaa63d9e2ba32d851ef
2017-01-03 13:50:13 -08:00
Adrian Salido
24ef8601c2 init/service.cpp: fix access check for console
Commit 9596d2b95d changes how
availability of console is checked by only checking access bits for
the console device. However, in cases where there is no console it
defaults to /dev/console. This device is always enumerated by tty
driver (i.e. file and access bits may be correct), but it doesn't
always map to an underlying console driver. Because the lookup for the
underlying console driver happens during the open system call, checking
only the access bits is not sufficient and need to make sure open
system call is successful, we can safely close the FD afterwards to
avoid FD leaks.

Test: boot device and check console svc doesn't continuously restart
Bug: 33691649
Change-Id: Ia51a8a2f56c345b70db55e95f61a057a98b52895
2017-01-03 13:11:29 -08:00
Jorge Lucangeli Obes
77f0e9fda8 init: Make 'write_file' return bool to match 'read_file'.
The mismatch of return values makes reasoning about the correctness of
CLs like https://android-review.googlesource.com/317923 quite hard.

Bug: 33941660
Test: Init builds, HiKey boots.
Change-Id: Ia4b8a9af420682997b154a594892740181980921
2016-12-28 14:16:54 -05:00
Paul Crowley
0b8b2303ac Ask the user before wiping if crypto policy fails.
If crypto policy fails, instruct recovery to prompt the user before
wiping all data.

Test: adb shell rmdir /data/ota && adb shell mkdir -p /data/ota/forcefail && adb reboot
Bug: 28693324
Change-Id: I4d09b35a20c513a76c9ba56fe826114449a9ad68
2016-12-21 13:39:23 -08:00
Elliott Hughes
8766ecb78d Merge "Move init bootcharting onto its own thread." 2016-12-17 17:56:15 +00:00
Daniel Cashman
a26a98726e Revert "Compile sepolicy on-device at early boot."
This reverts commit 2fae5d65d5.

Change-Id: Id8bfc0f85d19e98df3759a2fcc6b3a331b4eec29
2016-12-17 00:53:45 +00:00
Elliott Hughes
c249794628 Move init bootcharting onto its own thread.
This reduces the overhead when bootcharting is on (obviously), but also
removes the "do we need to do anything for bootcharting?" check in cases
where we're not bootcharting.

Bug: http://b/23478578
Bug: http://b/33450491
Test: rebooted with bootcharting on/off
Change-Id: Id8746b5023b17d7615679eba0bcd02aee048ef1a
2016-12-16 14:45:17 -08:00
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