Commit graph

97 commits

Author SHA1 Message Date
Treehugger Robot
cfb8800e18 Merge "Enable seccomp in init with generated policy" 2017-01-19 23:26:10 +00: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
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
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
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
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
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
Mark Salyzyn
62767fe29f init: service file keyword
Solve one more issue where privilege is required to open a file and
we do not want to grant such to the service. This is the service side
of the picture, android_get_control_file() in libcutils is the client.
The file's descriptor is placed into the environment as
"ANDROID_FILE_<path>".  For socket and files where non-alpha and
non-numeric characters in the <name/path> are replaced with _.  There
was an accompanying change in android_get_control_socket() to match
in commit 'libcutils: add android_get_control_socket() test'

Add a gTest unit test for this that tests create_file and
android_get_control_file().

Test: gTest init_tests --gtest_filter=util.create_file
Bug: 32450474
Change-Id: I96eb970c707db6d51a9885873329ba1cb1f23140
2016-11-03 13:34:26 -07:00
Jorge Lucangeli Obes
24b29132a0 init: Add support for ambient capabilities.
Ambient capabilities are inherited in a straightforward way across
execve(2):

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

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

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

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

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

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

Bug: 32438163
Test: Use sample service.
Change-Id: I3226cc95769d1beacbae619cb6c6e6a5425890fb
2016-11-01 19:56:14 -04:00
Yabin Cui
1051e107f2 init: use libbootloader_message.
Bug: 29582118
Change-Id: I6285b29774a11d6dda8496c7c73e4c1d17a672bd
(cherry picked from commit 0b1252cca0)
2016-10-18 11:37:52 -07:00
Tao Bao
6d881d6db4 Update the header path for ext4_utils.
Test: `mmma system/core`

Change-Id: I6291d10d6c8d4972aeca55596baa83f555496193
2016-10-09 10:23:36 -07:00
Josh Gao
87ef590bc1 Merge "libcrypto_utils: convert to Soong."
am: c1a9a21ffe

Change-Id: I9cf76646d4537750c4d4080234d3384fb307e610
2016-08-08 18:33:49 +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
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
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
Yabin Cui
46e037980b init: write bootloader message directly.
Bug: 27176738
Change-Id: I8c95a193f3436c0893d5103760b700f3052888db
2016-04-08 11:05:56 -07: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
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
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
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
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
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
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
Nick Kralevich
d717f86a3e am 64c30a79: am 084c00b8: Merge "init: add LOCAL_SANITIZE := integer"
* commit '64c30a79def4dc29749a86c00a970243a2a45f1e':
  init: add LOCAL_SANITIZE := integer
2015-08-17 01:15:17 +00:00
Nick Kralevich
f90b653667 init: add LOCAL_SANITIZE := integer
Call abort() on undefined or sketchy integer behavior.
Protects against integer overflow attacks.

Change-Id: If73e6b382f2ee645fec406805739f9684ddbb5f0
2015-08-15 15:24:23 +00:00
Nick Kralevich
1deb03179c am 51ffedd2: am 1efef4c4: Merge "Revert "init: add LOCAL_SANITIZE := integer""
* commit '51ffedd264389730a76470408a122589f7ce3488':
  Revert "init: add LOCAL_SANITIZE := integer"
2015-08-13 18:27:36 +00:00
Nick Kralevich
c307b5b7f8 Revert "init: add LOCAL_SANITIZE := integer"
flounder isn't booting

This reverts commit aea73db1e3.

Bug: 23166814
Change-Id: I36c811d1ca30e2366066142d9282bb713dae315f
2015-08-13 18:10:50 +00:00
Nick Kralevich
864d4985ed am 4d74f2cb: am 0b973da5: Merge "init: add LOCAL_SANITIZE := integer"
* commit '4d74f2cb4c30aaf4dfd176b2f970dbf54e5c697d':
  init: add LOCAL_SANITIZE := integer
2015-08-12 19:22:11 +00:00
Nick Kralevich
aea73db1e3 init: add LOCAL_SANITIZE := integer
Call abort() on undefined or sketchy integer behavior.
Protects against integer overflow attacks.

Change-Id: I5f542089753c8fcf7596fd70cfaa48a3caa5b140
2015-08-11 16:55:56 -07:00
Tom Cherry
841066e778 am 4036f5ab: am 4bf3dc93: Merge "Create Service and ServiceManager classes"
* commit '4036f5ab2ffbe5a2e47d46aa376e9791385cc31b':
  Create Service and ServiceManager classes
2015-08-07 21:17:02 +00:00
Tom Cherry
bac3299720 Create Service and ServiceManager classes
Change-Id: I363a5e4751ad83d2f4096882a6fbbeddca03acfe
2015-08-07 10:16:39 -07:00
Tom Cherry
97d393bb2d am a21d8562: am d548e30f: Merge "init: Create classes for Action and Command"
* commit 'a21d85620560896bbed0cd43db9ed3224ab4e974':
  init: Create classes for Action and Command
2015-07-30 21:23:00 +00:00
Tom Cherry
d548e30f04 Merge "init: Create classes for Action and Command" 2015-07-30 21:03:48 +00:00
Lee Campbell
7158521377 am 1691d968: am 138c540f: Merge "init: Add C++ tokenizer."
* commit '1691d968f8ae5f25036251fd5978be637bbf0b4a':
  init: Add C++ tokenizer.
2015-07-30 20:43:55 +00:00
Tom Cherry
fa0c21c94c init: Create classes for Action and Command
This creates the concept of 'event_trigger' vs 'property_trigger'

Previously these were merged into one, such that 'on property:a=b &&
property:b=c' is triggered when properties a=b and b=c as expected,
however combinations such as 'on early-boot && boot' would trigger
during both early-boot and boot.  Similarly, 'on early-boot &&
property:a=b' would trigger on both early-boot and again when property
a equals b.

The event trigger distinction ensures that the first example fails to
parse and the second example only triggers on early-boot if
property a equals b.

This coalesces Actions with the same triggers into a single Action object

Change-Id: I8f661d96e8a2d40236f252301bfe10979d663ea6
2015-07-30 13:37:23 -07:00
Lee Campbell
220ca84223 init: Add C++ tokenizer.
Adds a C++ tokenizer along with unit tests.

This tokenizer will replace the current C implementation
which does a poor job of keeping track of pointers.

This CL is a prerequisite for up coming changes to
the parser. This CL does not wire up this tokenizer and
changes no exsiting code. All that builds is the unit tests.

Change-Id: Iec3740bce7153640adc5e5bbdc57e644cedf0038
TEST: Unit tests all pass. No leaks under valgrind
BUG: 22843198
2015-07-30 18:45:17 +00:00
Nick Kralevich
2f2e6cd078 am 4c6269ce: am 106f92f5: Merge "Revert "init: Enable LOCAL_DETECT_INTEGER_OVERFLOWS""
* commit '4c6269ce280f33c7d080dbdbbfd3a8d9681d85ed':
  Revert "init: Enable LOCAL_DETECT_INTEGER_OVERFLOWS"
2015-06-17 00:09:45 +00:00
Nick Kralevich
21d605eff5 Revert "init: Enable LOCAL_DETECT_INTEGER_OVERFLOWS"
Shamu boots, but hammerhead doesn't. Likely cause is this change.

This reverts commit 18ae44bf3d.

Bug: 21880301
Change-Id: I490816060209c15aa07c783d05fe5b141c7c9023
2015-06-16 23:35:37 +00:00
Nick Kralevich
1bc2b09fd3 am 135b6b08: am 6b27b7d6: Merge "init: Enable LOCAL_DETECT_INTEGER_OVERFLOWS"
* commit '135b6b08cd9fec32c266f3981d4af101f6e270f9':
  init: Enable LOCAL_DETECT_INTEGER_OVERFLOWS
2015-06-16 20:58:27 +00:00
Nick Kralevich
18ae44bf3d init: Enable LOCAL_DETECT_INTEGER_OVERFLOWS
Call abort() if an integer overflow or underflow occurs.
See https://android-review.googlesource.com/154831

Change-Id: Icb6bdef55a5899144351b56d683f34f5da32a88d
2015-06-15 20:37:09 -07:00
Elliott Hughes
9371cf0e31 am 67917cf5: am 57bd480c: Merge "Make it clearer to grep that init is built with clang."
* commit '67917cf590ae497ce7700dc7a6b618b3a6700a39':
  Make it clearer to grep that init is built with clang.
2015-06-11 15:25:20 +00:00
Elliott Hughes
1115c25d5e Make it clearer to grep that init is built with clang.
Change-Id: Ic2abffd27e382cb691d772cdf088442645e59bf7
2015-06-10 22:43:51 -07:00
Andres Morales
b7f8b91040 am 86aeb11e: Merge "load ro.recovery_id property from recovery partition" into mnc-dev
* commit '86aeb11ed047b3698948c4eee8fbaccd20131ecb':
  load ro.recovery_id property from recovery partition
2015-05-09 00:46:52 +00:00
Andres Morales
cb3fce80fa load ro.recovery_id property from recovery partition
Change-Id: I9dc1f325e353375d9c1c8ed949636e2404601076
(cherry picked from commit db5f5d4367)
2015-05-08 17:35:13 -07:00
Andres Morales
db5f5d4367 load ro.recovery_id property from recovery partition
Change-Id: I9dc1f325e353375d9c1c8ed949636e2404601076
2015-05-08 17:23:24 -07:00
Nick Kralevich
61c086e54e am 3ef42dd2: am f0d24737: Merge "init: remove support for disabled SELinux"
* commit '3ef42dd20f8d54d98cc5e95995761d2f6b5b4950':
  init: remove support for disabled SELinux
2015-04-28 21:33:36 +00:00