Commit graph

1001 commits

Author SHA1 Message Date
Josh Gao
c1a9a21ffe Merge "libcrypto_utils: convert to Soong." 2016-08-08 18:29:10 +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
7bc87a5a78 Move init's kernel logging into libbase.
This will let other stuff (such as adbd and recovery) use it too.

Bug: http://b/28467098
Change-Id: Idab51f438ed3edd6fe65a56c4b396eaff5f3833e
2016-08-04 16:09:39 -07:00
Elliott Hughes
1e73024653 Have init kill the process group.
killProcessGroup actually works on cgroups. Kill the POSIX process
group ourselves.

Bug: http://b/29751426
Change-Id: I1a2808488510f4262811b6407bcd0948ad23bc60
2016-08-02 14:20:40 -07:00
Treehugger Robot
4efbce14b5 Merge "Fix clang-tidy performance warnings in syste/core." 2016-08-01 20:13:54 +00:00
Chih-Hung Hsieh
8f7b9e3d39 Fix clang-tidy performance warnings in syste/core.
* Use const reference type for parameters to avoid unnecessary copy.
* Suppress warning of not using faster overloaded string find function.

Bug: 30407689
Bug: 30411878
Change-Id: I6cfdbbd50cf5e8f3db6e5263076d3a17a9a791ee
Test: build with WITH_TIDY=1
Merged-In: Ie79dbe21899867bc62031f8618bb1322b8071525
2016-08-01 11:55:42 -07:00
Chih-hung Hsieh
6dc68cb5f9 Merge "Fix google-explicit-constructor warnings in system/core." 2016-07-29 16:57:17 +00:00
Dmitry Shmidt
7eed474db4 ueventd: Remove verbose restorecon_recursive: message
Bug: 30478300

Change-Id: Ife69bb5644c3f65f3a256dc042ae1c7fbfb77729
Signed-off-by: Dmitry Shmidt <dimitrysh@google.com>
2016-07-28 13:55:39 -07:00
Treehugger Robot
6d232ab4de Merge "Fix early init logging." 2016-07-27 15:28:18 +00:00
Chih-Hung Hsieh
034c475931 Fix google-explicit-constructor warnings in system/core.
* Declare explicit conversion constructors.
* Add NOLINT for implicit conversion constructors.
* Fix also some misaligned indendations.

Bug: 28341362
Change-Id: Idf911f35923b408d92285cc1a053f382ba08c63e
Test: build with clang-tidy
2016-07-26 11:26:01 -07:00
Elliott Hughes
35f5d04620 Fix early init logging.
Remove the /dev/__kmsg__ workarounds (which can then be removed
from sepolicy), and fix confusion in the translation between
android-base logging and kernel logging priorities (in particular,
where 'notice' comes in the hierarchy).

Bug: http://b/30317429
Change-Id: I6eaf9919904b6b55bc402c20bf1a4ae269014bc7
Test: adb shell dmesg | grep init
2016-07-26 09:32:33 -07:00
Elliott Hughes
e18e7e5c43 Improve init Service logging.
Say which service.

Don't ignore setpgid failures.

Change-Id: Ifa8eba583cc3cbf3d26763977bf8c3c9835271c6
2016-07-25 18:18:16 -07:00
Amit Pundir
d2e74db475 init: select usb gadget controller at run time
Right now we set sys.usb.controller property in init.$platform.usb.rc
to enable ConfigFS gadgets.

Let system detect and set UDC driver name from /sys/class/udc instead.

Change-Id: I99ad49d24dc53b543c5573e209bf00d6c2d91dd4
Signed-off-by: Amit Pundir <amit.pundir@linaro.org>
2016-07-15 15:01:43 -07:00
Treehugger Robot
82d2bcc21e Merge "Refactor Service::Start method." 2016-07-11 17:08:45 +00:00
Jorge Lucangeli Obes
344d01f99f Refactor Service::Start method.
This CL extracts code from Service::Start into four helper functions,
bringing Service::Start down to 134 lines vs 212 lines originally. This
makes the method a lot easier to follow. There is no change in behaviour.

Also, make error messages consistent (start with lowercase) and
format Service::Start to fit in 100 cols.

Bug: 30035168

Change-Id: If979976fba4d339a336d030f802ca9f169fd012c
2016-07-11 09:57:17 -04:00
Elliott Hughes
171a829c39 Make klog_fd thread-safe and make klog_init a no-op.
I'll come back and remove klog_init when I've removed other calls to it.

Change-Id: Iad7fd26d853b4ddc54e9abd44516b6f138cbbfcb
Test: booted N9, looked at "adb shell dmesg" output.
2016-06-29 16:16:41 -07:00
Jorge Lucangeli Obes
177b27d4f5 Rename "Handle(r)" to "Parse(r)" in Android init.
The code in question parses config files, so use the right terminology.

Bug: 29872991
Change-Id: Id9644d9a98c1d702d2990f62b3020a27d073141e
2016-06-29 16:29:53 -04:00
Jorge Lucangeli Obes
1b3fa3d650 init: Add option to run a service in a new PID/mount namespace.
Namespaces are a more consistent isolation primitive than e.g. hiding
/proc.

Bug: 29635190

Change-Id: I7c39975813fb13b3d06be35a24c0854f16549c0a
2016-06-29 14:49:11 -04:00
Elliott Hughes
f86b5a6b90 Move init to libbase logging.
Change-Id: Ibfbefeff587a69e948978a037c555fd12a5ade6a
2016-06-27 08:11:31 -07:00
Elliott Hughes
3195116e97 Remove MTD cruft from init.
Bug: http://b/29250988
Change-Id: I38ab263192944e4ff291fd91b25db163a8848d75
2016-06-24 18:26:30 -07:00
Treehugger Robot
aa9f37185f Merge "Remove more obsolete MTD stuff." 2016-06-24 17:19:48 +00:00
Elliott Hughes
01e5a6c971 Remove more obsolete MTD stuff.
Bug: http://b/29250988
Change-Id: Ic2d0514fcdbe26526e87bc681b71efcc90eda678
Test: still builds.
2016-06-24 09:13:51 -07:00
Hung-ying Tyan
66277db8d0 Merge "Add -f to insmod" 2016-06-24 04:34:56 +00:00
Hung-ying Tyan
bfa6d75c60 Add -f to insmod
When the flag is on, insmod will bypass vermagic and symbol version
checking in the kernel. This is to make it possible to update kernel
without recompiling kernel modules.

BUG=28803994

Change-Id: Ib4be6999ef52baefd4210ee0d242360e43318907
2016-06-24 11:10:46 +08:00
Chih-Hung Hsieh
cdb2ca5d9f Fix misc-macro-parentheses warnings in system/core.
Add parentheses around macro arguments used beside operators.
Bug: 28705665

Change-Id: I9226f319e283be640eddc31687f75b51a8ef0ac6
2016-06-22 14:33:13 -07:00
Elliott Hughes
ad8e94e017 init: report createProcessGroup failure.
Also directly kill the initial pid for safety, like other libprocessgroup
users.

Change-Id: Ib28936aea19cceaeaa54734759d5ae0c252c7905
2016-06-15 14:49:57 -07:00
Treehugger Robot
95428817d6 Merge "ueventd: only relabel devices if there's a delta" 2016-06-09 19:07:27 +00:00
Tom Cherry
86cd314af3 Merge "init: expand arguments of services when they start" 2016-06-08 22:42:11 +00:00
Vitalii Tomkiv
081705c258 Add process priority to service definition.
This change allows to set prioirrity of the process to be set through
*.rc file.

Bug: 28866384
Change-Id: If0108ef05c8a151749c43d2d7de1187653255ce8
2016-06-08 13:22:14 -07:00
Tom Cherry
bac3536cc9 init: expand arguments of services when they start
Arguments of commands are expanded based on properties if they contain
${property.name}, however this is not currently done for arguments of
services.

This patch makes it that arguments of services are expanded each time
that the service starts at the point immediately before execve().

Change-Id: Iba581a8377e25a6478d4d2ec2e8b29e181d8640c
2016-06-07 11:22:00 -07:00
Mark Salyzyn
4b56162a33 init: Add support for ${x.y:-default} expansion
commit 00ede7d262 (init: do
expand_props before calling the builtins) broke logpersist

Bug: 28120456
Bug: 22654233
Change-Id: Ib4d8231665b26ac083b02243177493fab41c8978
2016-06-07 18:09:17 +00: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
William Roberts
397de1494f ueventd: only relabel devices if there's a delta
Since commit: 24a3cbfa73
ueventd is attempting to relabel devices on calls to
make_device() when the device already exists. However, it
should only be called if the contexts for relabelfrom and
relabelto are different.

When this condition occurs, one will see denials like this:

[   14.409448] type=1400 audit(978307239.225:26): avc: denied { relabelfrom } for pid=1572 comm="ueventd" name="ttyS0" dev="tmpfs" ino=9613 scontext=u:r:ueventd:s0 tcontext=u:object_r:hci_attach_dev:s0 tclass=chr_file permissive=1
[   14.428107] type=1400 audit(978307239.225:27): avc: denied { relabelto } for pid=1572 comm="ueventd" name="ttyS0" dev="tmpfs" ino=9613 scontext=u:r:ueventd:s0 tcontext=u:object_r:hci_attach_dev:s0 tclass=chr_file permissive=1

Bug: 29106809

Change-Id: I2105b169206f0b26420f3c4b0ba5c49aeb98da92
Signed-off-by: William Roberts <william.c.roberts@intel.com>
2016-06-03 17:40:18 +00:00
Chih-Hung Hsieh
c713bce901 Fix misc-macro-parentheses warnings in init and other core modules.
Bug: 28705665
Change-Id: Ice67cebb8c42538f8fb9cf1756678f41a9d68a31
2016-05-18 18:11:49 -07: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
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
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
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
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
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
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
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
ad575e04a1 init: watchdog restarted during shutdown fsck
Bug: 27506425
Change-Id: I40967068d18ce1a8cbaf0b750e7a7af6eab3e4e8
2016-04-05 11:31:14 -07: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
7f84a0700c Merge "Address const issues in preparation for libcxx rebase." 2016-03-28 22:35:51 +00:00
Dan Austin
dce9b61d25 Merge "Fix const issues in preparation for libcxx rebase." 2016-03-28 21:41:10 +00:00