Commit graph

21750 commits

Author SHA1 Message Date
Mark Salyzyn
787b4b8ed2 Merge "liblog: O_CLOEXEC flag on opens" into nyc-dev 2016-04-29 16:15:02 +00:00
Mark Salyzyn
2b409c9bc7 liblog: O_CLOEXEC flag on opens
(cherry pick from commit 78786da116)

Bug: 28455828
Change-Id: Ic00101a6192aab7271cb0c3461e249a77d7f29ed
2016-04-29 08:08:39 -07:00
Mark Salyzyn
358cf8a919 liblog: logcat -g readable size wrong
(cherry pick from commit ccfb244b36)

Bug: 28451229
Change-Id: I4bbc2bed933d69416c23cc7af617be3fb55d0b62
2016-04-29 07:45:29 -07:00
Colin Cross
cecd64012d Silently ignore duplicate heap entries
Vendor blobs on ryu mprotect heap pages, causing a single chunk mapping
to appear as multiple mappings.  The heap iterator has to expand the
requested range to cover the beginning of the chunk to find the chunk
metadata, which will lead to duplicate identical allocations being
reported from iterating over each of the split mappings.  Silently
ignore identical allocations, and only warn on non-identical allocations
that overlap.

Bug: 28269332
Change-Id: Ied2ab9270f65d00a887c7ce1a93fbf0617d69be0
2016-04-28 16:20:40 -07:00
Colin Cross
ba5d9ff6d9 Handle segfaults while walking native heap
Vendor blobs on ryu mprotect heap pages, causing segfaults when dumping
unreachable memory.  Handle segfaults within HeapWalker by mapping a
zero page over any unreadable pages.  HeapWalker runs in the forked
process, so the mapping will not affect the original process.

Bug: 28269332
Change-Id: I16245af722123f2ad467cbc6f245a70666c55544
2016-04-28 16:20:40 -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
Dimitry Ivanov
0b5651e158 native_loader: Use ANDROID_ROOT environment variable
Replace "/system" with ANDROID_ROOT environment variable.

Bug: http://b/28320913
Bug: http://b/28082914
Change-Id: Ib039722cb059bae1635b45f6af20ef0180e83ba9
(cherry picked from commit 7e8cee8fb2)
2016-04-27 13:43:33 -07:00
Dimitry Ivanov
5539db0b4f Enable namespaces for all target sdk versions
We previously relied on the fact that target sdk version 0
implies system_server, which is not true, target sdk version
may be set to 0 for other apps and it means 1 - the earliest
version of android. This change enables namespaces for
apps targeting all sdk version and for system_server.

Bug: http://b/27702070
Change-Id: I16fbdeb6868c7035aec71132c80c150c08ea2cc3
(cherry picked from commit 213676b880)
2016-04-27 11:44:42 -07:00
Yabin Cui
f92838ca1d Merge "adb: fix adb usb operations on device." into nyc-dev 2016-04-27 03:05:40 +00:00
Yabin Cui
9b53e4c42c adb: fix adb usb operations on device.
Problem: For devices using /dev/usb-ffs/adb, Run
`while true; do adb reconnect device; sleep 1; done`. And the
device soon becomes offline. The adbd log shows that calling
adb_read(h->bulk_out) in usb_ffs_read() gets EOVERFLOW error.

Reason: When kicking a transport using usb-ffs, /dev/usb-ffs/adb/ep0
is not closed, and the device will not notify a usb connection reset
to host. So the host will continue to send unfinished packets even
if a new transport is started on device. The unfinished packets may
not have the same size as what is expected on device, so adbd on
device gets EOVERFLOW error. At the worst case, adbd has to create new
transports for each unfinished packet.

Fixes:
The direct fix is to make the usb connection reset when kicking transports,
as in https://android-review.googlesource.com/#/c/211267/1. And I think
we can make following improvements beside that.
1. Close a file that is used in other threads isn't safe. Because the file
descriptor may be reused to open other files, and other threads may operate
on the wrong file. So use dup2(dummy_fd) to replace close() in kick function,
and really close the file descriptor after the read/write threads exit.

2. Open new usb connection after usb_close() instead of after
usb_kick(). After usb_kick(), the transport may still exist and
reader/writer for the transport may be still running. But after
usb_close(), the previous transport is guaranteed to be destroyed.

Bug: 25935458
Change-Id: I1eff99662d1bf1cba66af7e7142f4c0c4d82c01b
(cherry picked from commit 005bf1e05b)
2016-04-26 17:43:14 -07:00
Yabin Cui
f7c31b9552 Merge "adb: use a custom thread to poll for usb devices on mac." into nyc-dev 2016-04-27 00:38:58 +00:00
Yabin Cui
71bddf842d adb: use a custom thread to poll for usb devices on mac.
On mac, if the adb server kicks a transport on some error, mac usb driver
will not report a new usb device. So instead of relying on mac usb driver
to report new usb devices, this CL uses a loop to search for usb devices
not exist before. Note that this is also the behavior on windows and linux
host.
`adb reconnect` can be used to verity this CL.

Bug: 25935458
Change-Id: I890e0eb1fae173f2e7a0c962ededa294d821e015
(cherry picked from commit 48d4c0c42a)
2016-04-26 17:00:49 -07:00
Yabin Cui
550ad20d64 Merge "Fix kick_transport test." into nyc-dev 2016-04-26 23:18:20 +00:00
Daniel Rosenberg
2abee9e063 Add support for FUSE_CANONICAL_PATH
This allows inotify requests on FUSE to be alerted when any
other stacked filesystem would trigger an inotify for the
same file.

Bug: 23904372
Change-Id: I4289b38230c314432eaf2c0d20d4ccefc058f59e
2016-04-25 20:42:57 -07:00
Yabin Cui
a28918cf30 Fix kick_transport test.
Fix broken kick_transport test, and make it not access atransport
internal variables.

Bug: 25935458
Change-Id: I91b4d32a222b2f369f801bbe3903acac9c8ea4f7
(cherry picked from commit 7f27490e7f)
2016-04-25 17:37:08 -07:00
TreeHugger Robot
595efd04db Merge "Remove workaround for libart greylist." into nyc-dev 2016-04-25 21:53:31 +00:00
Martijn Coenen
0e54903c73 Merge "Move gatekeeperd to system-background cpuset." into nyc-dev 2016-04-25 17:46:01 +00:00
Christopher Ferris
0fc89f34b9 Connect to activity manager as root.
Before dropping root privileges, connect to the activity manager.
Also, only connect to the activity manager if this is a crash.

Bug: 28210681
Change-Id: Ie266031910519fa2aa6835644a95c1fc56e24d8d
2016-04-20 11:30:33 -07:00
TreeHugger Robot
ded0f36822 Merge "liblog: android_log_isloggable failing apct" into nyc-dev 2016-04-19 17:05:37 +00:00
Paul Lawrence
fe5d55a68b Merge "Don't start defaultcrypto twice" into nyc-dev 2016-04-19 14:44:26 +00:00
Mark Salyzyn
504daa654e liblog: android_log_isloggable failing apct
(cherry pick from commit efe8ecc1d9)

- periodic failures in apct, dropped second serial test
  in refresh_cache, trusting check_cache or global.
- The retry loop to see if is_loggable recovers of 1000
  was hiding subsequent tests, drop to 10 retries.
- On the whole, the average performance remains the same.

Bug: 25792367
Change-Id: I4110440ef46671d7a1c128689bde623808bed04f
2016-04-19 07:23:17 -07:00
TreeHugger Robot
a9e818f463 Merge changes Ia4a2ff77,I970806e3,I47daa338 into nyc-dev
* changes:
  adb: increase the FD table size on Win32.
  adb: bump the server version to 36.
  adb: add reconnect command.
2016-04-19 00:51:22 +00:00
Josh Gao
d1e2300a71 adb: increase the FD table size on Win32.
128 maximum FDs is a pretty low limit, which can easily be exhausted by
port forwarding. Bump the maximum up to 2048, and add a test that checks
whether we can actually use a few hundred sockets.

Bug: https://code.google.com/p/android/issues/detail?id=12141
Bug: http://b/28246942
Change-Id: Ia4a2ff776e8e58ec13378756f19d80392679ece9
(cherry picked from commit b31e17107c)
2016-04-18 15:46:25 -07:00
Josh Gao
988e9bc1f8 adb: bump the server version to 36.
The recent `adb root` changes are incompatible with older versions of
the server. Bump the version number to force the server to restart.

Bug: http://b/28194507
Change-Id: I970806e3b68c1f8e3273a4b1f0ecc4aca5086be9
(cherry picked from commit 057095d207)
2016-04-18 15:46:25 -07:00
Yabin Cui
03468c8c50 adb: add reconnect command.
Add reconnect command for debugging. `reconnect` kicks a transport
from the host side, `reconnect device` kicks a transport from
the device side. They can be used to produce transport errors.

Bug: 25935458

Change-Id: I47daa338796b561941e7aba44a51a6dd117d1e98
(cherry picked from commit 1f4ec19e49)
2016-04-18 15:46:25 -07: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
Jeff Sharkey
e4f870a0bb Merge "Create legacy /data/system/user directory." into nyc-dev 2016-04-18 19:43:18 +00:00
Alex Light
3150fa2514 Remove workaround for libart greylist.
Bug: 27775991

Change-Id: I77f03b95f70957df58e666b011a07cfc2a33b480
2016-04-15 12:42:44 -07:00
Jeff Sharkey
c9b84a362a Create legacy /data/system/user directory.
We create per-user directories under this location, so it should
only be created once by init, similar to all the other user-specific
directories.

Bug: 27896918
Change-Id: I9ec55e4fd763c0eda6c6e50483694a6377344586
2016-04-15 13:42:29 -06:00
Mark Salyzyn
3c535de75e logcat: apct test failures
(cherry pick from 3842b1a5f6)

Change-Id: I100a5071c059fe9fa85bbdc33db552b16d7bdf60
2016-04-15 16:38:42 +00:00
Martijn Coenen
0fd19760a1 Move gatekeeperd to system-background cpuset.
Bug: 24949295
Change-Id: I3c68bf1c604f0e8eb8155a4615802847a9a8604d
2016-04-15 14:29:40 +02:00
Yabin Cui
578bc039dc libbacktrace: only build libbacktrace_offline static library.
As device may not have libbacktrace_offline shared library, simpleperf
no longer rely on it. So there is no reason to keep libbacktrace_offline
shared library.

Bug: 28152982
Change-Id: If8e31b1434646dbbfed60264eb25f034bc5d6946
(cherry picked from commit 51e607056d)
2016-04-14 14:37:37 -07:00
Daniel Rosenberg
f80d64f9d1 Fix overflow in path building am: 6ea6c04 am: 9c44027 am: 4830087 am: ad431d2 am: 20bf84e am: 0b35da7 am: 945228b am: aa7db31 am: cebac70 am: 5e7d964
am: 251e360

* commit '251e3609a485950de59d3aef08959f24a81f9e65':
  Fix overflow in path building

Change-Id: Icd03d8477acf5cd30fd034ed50deba6f1ee7a361
2016-04-14 20:01:24 +00:00
Daniel Rosenberg
251e3609a4 Fix overflow in path building am: 6ea6c04 am: 9c44027 am: 4830087 am: ad431d2 am: 20bf84e am: 0b35da7 am: 945228b am: aa7db31 am: cebac70
am: 5e7d964

* commit '5e7d964871fe7217bc9042adc181232a4e3c1f38':
  Fix overflow in path building

Change-Id: I2318464de6db3c058022f042c57840124f72a5e8
2016-04-14 19:58:14 +00:00
Daniel Rosenberg
5e7d964871 Fix overflow in path building am: 6ea6c04 am: 9c44027 am: 4830087 am: ad431d2 am: 20bf84e am: 0b35da7 am: 945228b am: aa7db31
am: cebac70

* commit 'cebac700aa133744b2b0b586d71d38d7de64f45a':
  Fix overflow in path building

Change-Id: I4d15a213045eb9293638ed1bafcb3137c7994fce
2016-04-14 19:54:47 +00:00
Daniel Rosenberg
cebac700aa Fix overflow in path building am: 6ea6c04 am: 9c44027 am: 4830087 am: ad431d2 am: 20bf84e am: 0b35da7 am: 945228b
am: aa7db31

* commit 'aa7db31fbd39d90e387b71c41e87a0d37b98882c':
  Fix overflow in path building

Change-Id: Id971b55ed73ad4f6b7160f4e9c014e5007d92262
2016-04-14 19:51:41 +00:00
Daniel Rosenberg
aa7db31fbd Fix overflow in path building am: 6ea6c04 am: 9c44027 am: 4830087 am: ad431d2 am: 20bf84e am: 0b35da7
am: 945228b

* commit '945228bdde777ad3aa814d480d37513db24699fb':
  Fix overflow in path building

Change-Id: I6bf39ad97ffeaf70c347fad4166ba239f93f5449
2016-04-14 19:48:22 +00:00
Daniel Rosenberg
945228bdde Fix overflow in path building am: 6ea6c04 am: 9c44027 am: 4830087 am: ad431d2 am: 20bf84e
am: 0b35da7

* commit '0b35da7165e9b78a5e35200bac3df4b2c6bc7c36':
  Fix overflow in path building

Change-Id: I07a7bb64ae3174fb8f36cfa1d3651473e5b2f6bf
2016-04-14 19:44:46 +00:00
Daniel Rosenberg
0b35da7165 Fix overflow in path building am: 6ea6c04 am: 9c44027 am: 4830087 am: ad431d2
am: 20bf84e

* commit '20bf84eca094e813fa445b60d22bcf0c27148cd4':
  Fix overflow in path building

Change-Id: Ia4639f0a0dbcb848a6d9c59319c12cd9bd952c8f
2016-04-14 19:41:32 +00:00
Daniel Rosenberg
20bf84eca0 Fix overflow in path building am: 6ea6c04 am: 9c44027 am: 4830087
am: ad431d2

* commit 'ad431d2e2e15cc47b78fa62e4ab362bfdaa77070':
  Fix overflow in path building

Change-Id: Ifa2970afd2862bef780904f2b91a307c16f7a7b8
2016-04-14 19:37:48 +00:00
Daniel Rosenberg
ad431d2e2e Fix overflow in path building am: 6ea6c04 am: 9c44027
am: 4830087

* commit '4830087b3755b4c3498880369ccbe918aa136cd0':
  Fix overflow in path building

Change-Id: Ie2044be5b1c31b1fe128c90eda1c5df169dc0a3d
2016-04-14 19:34:33 +00:00
Daniel Rosenberg
4830087b37 Fix overflow in path building am: 6ea6c04
am: 9c44027

* commit '9c440272192d600c72659da5bfbe0c2e0a133cfe':
  Fix overflow in path building

Change-Id: Idb39dfc88adb854ffbc3bd40be0d28409248fc85
2016-04-14 19:31:17 +00:00
Daniel Rosenberg
9c44027219 Fix overflow in path building
am: 6ea6c04

* commit '6ea6c04ca695e0f0b6bcf3ea4529b9fd74fee8e4':
  Fix overflow in path building

Change-Id: Ia4388b694ddb12083e0d5a67a3a5f3f5bba2fb12
2016-04-14 19:27:58 +00:00
Josh Gao
9ea7795d38 adb: after adb root, wait for the device in any state.
Otherwise, `adb root` while the device is in recovery will hang.

Bug: http://b/28168212
Change-Id: Ibc8038b1745139fb505e466c74c605b9df474c8c
(cherry picked from commit 48a348183f)
2016-04-13 13:13:20 -07:00
Josh Gao
5863fb61e1 adb: add support for 'wait-for-any'.
Allow waiting for a device in any state.

Bug: http://b/28168212
Change-Id: I1876ecd70089ca88f2da5de4182e13724ec50501
(cherry picked from commit 86441c31fe)
2016-04-13 13:13:17 -07:00
Josh Gao
3d8df3cb2a adb: make 'wait-for-{recovery,sideload,bootloader} work.
The help for wait-for-* documents this as working, but we only had a
special case for 'wait-for-device'. Make the others work as well.

Bug: http://b/28170823
Change-Id: I57d70f8b9a383947c4f761919bfbd8515a013520
(cherry picked from commit 08881e72f4)
2016-04-13 13:13:14 -07:00
Daniel Rosenberg
c414027e92 Merge "Fix overflow in path building" into nyc-dev 2016-04-13 18:36:39 +00:00
TreeHugger Robot
e04c9f3436 Merge "Implements 'adb bugreport <ZIP_FILE>'." into nyc-dev 2016-04-13 18:28:19 +00:00
Felipe Leme
44a42677cf Implements 'adb bugreport <ZIP_FILE>'.
Dumpstate now supports zipped bugreport, whose output is more complete
than the flat-file bugreports provided prior to N. As such, adb now has
a 'adb bugreport <ZIP_FILE>' name whose implementation:

- Calls the new bugreportz binary.
- Parses its output, which in case of success is the path of the .zip
  file.
- Pulls the device file and renames it according to the command-line
  argument.

BUG: 27653204

Change-Id: I7169fe157c77bbef1684d0cb4e43095d95ddf2b8
2016-04-13 09:21:23 -07:00
Elliott Hughes
27fe8c904b Merge "Remove undocumented functionality from init." into nyc-dev 2016-04-13 14:45:56 +00:00