Commit graph

1027 commits

Author SHA1 Message Date
Paul Crowley
31a09f6475 Merge "Wipe device on policy error" into nyc-dev am: 8a59fa8524
am: 2b2e3f1130

* commit '2b2e3f1130e90797e89cf3477db29c413a494778':
  Wipe device on policy error

Change-Id: Id77730e5da423be2b86a1ebf5d05efabf7e5feb5
2016-05-10 22:19:42 +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