Commit Graph

1051 Commits

Author SHA1 Message Date
Rob Herring ad300bf987 Merge "init: support matching sysfs class paths in ueventd.rc" am: faa14b94d5 am: 0da9f42f2c am: a0c90085ec
am: 9582b1a3f1

* commit '9582b1a3f16e3bf492af38ec166eb6d23f65cedf':
  init: support matching sysfs class paths in ueventd.rc

Change-Id: Id1d9a1db1d677164347f5d3092b4d3c33292dd30
2016-05-13 22:00:25 +00: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 8b7d2a24da Merge "init: rework fixup_sys_perms to use perm_path_matches" am: 0504a94cd9 am: e7028e3d38 am: 7aef62751b
am: fe56b450e9

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

Change-Id: I90e7f682752919699259a1871a7f5014249b64eb
2016-05-13 20:38:27 +00: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 bc2ba2ad45 Merge "Wipe device on policy error" into nyc-dev am: 8a59fa8524 am: 2b2e3f1130
am: 31a09f6475

* commit '31a09f6475d47a13b4f96d0d269b658558600470':
  Wipe device on policy error

Change-Id: If85080813869c6630c6a9cec43474f4103d3ad27
2016-05-10 22:22:16 +00:00
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 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 5709c1cf0f Merge "Fix google-explicit-constructor warnings." am: 7bdd6a8b5a am: 427d8d840f am: fb44ca5178
am: 6dd5dbd41b

* commit '6dd5dbd41b8d6197618ad3672f67615b9f14bf64':
  Fix google-explicit-constructor warnings.

Change-Id: I4f96a29cdc89aeaa9db1abbe0d0ce88c457f56ee
2016-04-30 05:21:02 +00: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 d1c5f9bec3 Merge "ueventd: relabel block devices nodes when processing subsequent add events" am: 94b0f37 am: 51cdf14 am: 355e4c8
am: ad0dd58

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

Change-Id: If9cd2cfce33de7c53e54b22186caf0b7ff43ce2a
2016-04-28 12:16:24 +00: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 77e05cd29a Merge "Don\'t start defaultcrypto twice" into nyc-dev am: fe5d55a am: 1a920d7
am: fa3e4ea

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

Change-Id: I7d225afe784949d96e5a628d97c18f90c1038721
2016-04-19 14:52:45 +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 c6ae43ef8e Merge "Remove undocumented functionality from init." into nyc-dev am: 27fe8c9
am: 8bcb7ca

* commit '8bcb7caf0eed34bd5ea1a6f1e119ebcb7f4501a5':
  Remove undocumented functionality from init.

Change-Id: Ifbf18244bc463ad7f9477309188da67236f0e306
2016-04-13 14:54:28 +00: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
Mattias Nissler e21165406f Merge changes from topic \'boringssl_conversion\' am: 52eb93c am: 0781351
am: 9c4a0e0

* commit '9c4a0e021607f9da6130658530110e84eefc8ed9':
  Switch fs_mgr and adb to libcrypto_utils.
  Add libcrypto_utils.

Change-Id: Ifc84a632bfc58b6d7034d3feb3cc435ef706c54f
2016-04-13 01:50:10 +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 41524c164d Merge "init: write bootloader message directly." into nyc-dev am: a3a7a88
am: 52a302d

* commit '52a302d1e62c35112d8599e1b9ff20dc26b60970':
  init: write bootloader message directly.

Change-Id: Iba4bc39834c18a31272948493710238a0c0bf959
2016-04-09 22:46:06 +00: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
William Roberts 034ff0ab52 Merge "ueventd: convert to use pwd family of functions" am: 2c78f62 am: 1397e7a
am: c7f5af5

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

Change-Id: I5deb10d8cdf6c37bba20c6b7f15f283b4d0009ec
2016-04-08 01:59:22 +00:00
William Roberts 17be71c511 Merge "property_service: drop unused header" am: 1134925 am: b627a01
am: 2a651e6

* commit '2a651e603a945e8ae10ddddb889ee654779769bc':
  property_service: drop unused header

Change-Id: I7345729982ee9a1c45e2ae690f36a78619fa017c
2016-04-08 01:59:22 +00:00
William Roberts 5427980c81 Merge "init: drop unused header android_filesystem_config.h" am: 54c27c7 am: 8cb6a9c
am: 6ba3710

* commit '6ba371065181d556ce8988b361f6a2816df1f696':
  init: drop unused header android_filesystem_config.h

Change-Id: I1f5428f144aec520f547152f9bab7aafffed290c
2016-04-08 01:59:21 +00:00
William Roberts 3401117acb Merge "init: switch from android_ids to getpwnam" am: 171504f am: 43cbd05
am: ff37c38

* commit 'ff37c38bac299914712852e92d88c74d9b78aa27':
  init: switch from android_ids to getpwnam

Change-Id: Ie976999e308ec7625a02cb2b5c0ab1fd21645669
2016-04-08 01:59:21 +00: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 f8355eaba7 Merge "init: turn off backlight when performing shutdown cleanup" am: adf1cde am: 23702b5
am: 24f79be

* commit '24f79bed760db1d074e77f82201fced057d41d80':
  init: turn off backlight when performing shutdown cleanup

Change-Id: I8bd73eb7ce19b7b80558ce05a70895062b70d909
2016-04-05 23:30:22 +00: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 a648a6b726 Merge "init: watchdog restarted during shutdown fsck" am: 3443caa am: 34dcdd8
am: e4c8b31

* commit 'e4c8b31fed15d1e246450d6e7821ca07915b888c':
  init: watchdog restarted during shutdown fsck

Change-Id: I6814deb12ee788928db734852098873e6d732067
2016-04-05 18:48:04 +00:00