Commit Graph

23100 Commits

Author SHA1 Message Date
Mark Salyzyn a3692040fa Merge "liblog: logcat -g readable size wrong" am: 7f18790bd7
am: 7a5b8c7f53

* commit '7a5b8c7f53ca79f99e74655b2f68356c7184532a':
  liblog: logcat -g readable size wrong

Change-Id: I1461a41dc0b1bff3394caa5a107d7ad80cc7d068
2016-04-29 14:53:23 +00:00
Mark Salyzyn 78786da116 liblog: O_CLOEXEC flag on opens
Bug: 28455828
Change-Id: Ic00101a6192aab7271cb0c3461e249a77d7f29ed
2016-04-29 07:52:36 -07:00
Mark Salyzyn 7a5b8c7f53 Merge "liblog: logcat -g readable size wrong"
am: 7f18790bd7

* commit '7f18790bd7968522452eb88e670afe3736e0dcb7':
  liblog: logcat -g readable size wrong

Change-Id: I57a8890383b90a41d548784bfddeecc879e83702
2016-04-29 14:50:00 +00: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
Mark Salyzyn 7f18790bd7 Merge "liblog: logcat -g readable size wrong" 2016-04-29 14:44:03 +00:00
Mark Salyzyn ccfb244b36 liblog: logcat -g readable size wrong
Bug: 28451229
Change-Id: I4bbc2bed933d69416c23cc7af617be3fb55d0b62
2016-04-29 07:39:51 -07:00
Colin Cross e26f826c24 Silently ignore duplicate heap entries
am: cecd64012d

* commit 'cecd64012db013331ff1071254ab543dcdf327bd':
  Silently ignore duplicate heap entries

Change-Id: Ia3b5ed641451e832ccbbbfd625bec467ac54b2e3
2016-04-29 00:15:22 +00:00
Colin Cross 5a964afd56 Handle segfaults while walking native heap
am: ba5d9ff6d9

* commit 'ba5d9ff6d9674a0f1e985b49f53863045aff558d':
  Handle segfaults while walking native heap

Change-Id: Ib6f7cdbcec00446cc290f26ed7876f577ec15cce
2016-04-29 00:15:20 +00: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 0d16057755 ueventd: relabel block devices nodes when processing subsequent add events
am: 721c9ce

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

Change-Id: I5c72f4a2e22a8a139aae51d2dace183a63ab85e1
2016-04-28 16:36:39 +00: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 51cdf140db Merge "ueventd: relabel block devices nodes when processing subsequent add events"
am: 94b0f37

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

Change-Id: I9cfab12e0844991bd875d049e3e6ed3c50a27084
2016-04-28 12:06:41 +00:00
Treehugger Robot 94b0f3763f Merge "ueventd: relabel block devices nodes when processing subsequent add events" 2016-04-28 12:04:24 +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
Dimitry Ivanov 1010ef94a6 native_loader: Use ANDROID_ROOT environment variable
am: 0b5651e

* commit '0b5651e1588c2fee6a587314993a166a77068974':
  native_loader: Use ANDROID_ROOT environment variable

Change-Id: I51e37fcc25686890b72a3aacfca208c30f06e8b5
2016-04-27 23:54:32 +00:00
Dimitry Ivanov 5bcdfd107e Enable namespaces for all target sdk versions
am: 5539db0

* commit '5539db0b4f915bf15de742d1378904a553dc80dc':
  Enable namespaces for all target sdk versions

Change-Id: I5dc1a47efac24e151b923c631582b46836c37a8e
2016-04-27 23:54:31 +00:00
Treehugger Robot 78440e8689 Merge "Change remaining Android logging macros to use C99 varidaic syntax" am: 3abd032
am: 499cfed

* commit '499cfed160bb3c0893880de7860f2a78394d4a1d':
  Change remaining Android logging macros to use C99 varidaic syntax

Change-Id: I74c5808315835069067dc2f68eac044d74247dc1
2016-04-27 22:49:05 +00:00
Alex Vakulenko 499cfed160 Merge "Change remaining Android logging macros to use C99 varidaic syntax"
am: 3abd032

* commit '3abd03232efd53bb3a73d1e76f6f72754457e18d':
  Change remaining Android logging macros to use C99 varidaic syntax

Change-Id: Icc7457e9b883650d7ec15c0463405eb0565e31b3
2016-04-27 22:46:25 +00:00
Treehugger Robot 3abd03232e Merge "Change remaining Android logging macros to use C99 varidaic syntax" 2016-04-27 22:39:20 +00:00
Alex Vakulenko 3b0d65ad10 Change remaining Android logging macros to use C99 varidaic syntax
Most of the system/core/include/log/log.h file uses the C99 syntax of
variadic macros (that is, '...' in parameter list and __VA_ARGS__
in arguments). Except for andoid_printLog and android_printAssert
which still uses GCC custom extension syntax.

Switched the remaining macros to use C99 syntax. GCC extension syntax
makes my editor's code parser puke.

BUG: None
Change-Id: Ia6ebc0f2044b64182c425b179da0229c7046be4a
2016-04-27 14:44:40 -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 1bfa519f76 Merge "native_loader: Use ANDROID_ROOT environment variable" am: 6d28ae7
am: e40d65f

* commit 'e40d65fa8ef4a10838ba687c4af4a1f80977bddf':
  native_loader: Use ANDROID_ROOT environment variable

Change-Id: I7f674e1a1c5f19e7ec4d9947c2aac51ca6389621
2016-04-27 20:27:10 +00:00
Dimitry Ivanov d7735d9694 Merge "Enable namespaces for all target sdk versions" am: 581beeb
am: ced603d

* commit 'ced603d5dadbce6d00280be27d1b4431ba8038b8':
  Enable namespaces for all target sdk versions

Change-Id: I51a9f47d5fdebe10e6ccbc79f0bb75bb47f1fecb
2016-04-27 20:27:10 +00: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
Dimitry Ivanov e40d65fa8e Merge "native_loader: Use ANDROID_ROOT environment variable"
am: 6d28ae7

* commit '6d28ae7b0dfb486b3d7840185cdcbde5aec76a04':
  native_loader: Use ANDROID_ROOT environment variable

Change-Id: I1cda059bc87629f52077a33d18b2f8cdc4707dd2
2016-04-27 18:41:57 +00:00
Dimitry Ivanov ced603d5da Merge "Enable namespaces for all target sdk versions"
am: 581beeb

* commit '581beebc98e9f420db30e7ff031302fea8ce4af2':
  Enable namespaces for all target sdk versions

Change-Id: I7b0c37717942d0d743e9f877bfba0a29ac0d9c7c
2016-04-27 18:41:57 +00:00
Dimitry Ivanov 6d28ae7b0d Merge "native_loader: Use ANDROID_ROOT environment variable" 2016-04-27 18:24:33 +00:00
Dimitry Ivanov 581beebc98 Merge "Enable namespaces for all target sdk versions" 2016-04-27 18:24:04 +00:00
Treehugger Robot 600511a212 Merge "Fix google-explicit-constructor warnings." am: bf1767f
am: 96dbbbb

* commit '96dbbbb7b4e3c2be2d016eaf15a159622312a56d':
  Fix google-explicit-constructor warnings.

Change-Id: I948158330b745cedd679eab32b2bc15266ef3c59
2016-04-27 15:54:59 +00:00
Chih-Hung Hsieh 96dbbbb7b4 Merge "Fix google-explicit-constructor warnings."
am: bf1767f

* commit 'bf1767fbed903c2dee46fda8aac4f4023177ee4c':
  Fix google-explicit-constructor warnings.

Change-Id: I668e4ff4466b1ff5dd5a21ff9d1d430072216ca8
2016-04-27 15:50:51 +00:00
Treehugger Robot bf1767fbed Merge "Fix google-explicit-constructor warnings." 2016-04-27 15:44:07 +00:00
Yabin Cui cc526288f2 Merge "adb: fix adb usb operations on device." into nyc-dev
am: f92838c

* commit 'f92838ca1d5e315943022b7225a6c97c6c1283f4':
  adb: fix adb usb operations on device.

Change-Id: I852d27c8eccf2536f3733d59c9d712eeb6bef6f9
2016-04-27 03:43:09 +00: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 2282c76857 Merge "adb: use a custom thread to poll for usb devices on mac." into nyc-dev
am: f7c31b9

* commit 'f7c31b9552da778ebea5ac3c2bd3c5260b5e7705':
  adb: use a custom thread to poll for usb devices on mac.

Change-Id: I6fb6686525a9e67f2a12be955d4a1692eeb5ab6a
2016-04-27 00:51:38 +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
Treehugger Robot 02e8b642af Merge "adb: decrease the number of fds used in fd_count test." am: c296440
am: dbb3e3b

* commit 'dbb3e3ba92b090afa32808cbb504d4c653f5311c':
  adb: decrease the number of fds used in fd_count test.

Change-Id: Id48542904272ac506eec121fa21cbed374b9408d
2016-04-27 00:11:26 +00:00
Josh Gao dbb3e3ba92 Merge "adb: decrease the number of fds used in fd_count test."
am: c296440

* commit 'c2964402b6ff91126bbbf7dd453adca40a13bd64':
  adb: decrease the number of fds used in fd_count test.

Change-Id: Id078e3b319bdd8591b78898e543a636f9eac6bf0
2016-04-27 00:07:46 +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
Treehugger Robot c2964402b6 Merge "adb: decrease the number of fds used in fd_count test." 2016-04-26 23:55:11 +00:00
Yabin Cui 6b9de913cc resolve merge conflicts of 550ad20d to nyc-dev-plus-aosp
Change-Id: I28eec373673fc8ff5e77e8689277559fbf00dfb7
2016-04-26 16:49:59 -07:00
Yabin Cui 550ad20d64 Merge "Fix kick_transport test." into nyc-dev 2016-04-26 23:18:20 +00:00
Daniel Rosenberg d4f91171bd Add support for FUSE_CANONICAL_PATH
am: 2abee9e

* commit '2abee9e063d1549fb006853b27f378c7d22192af':
  Add support for FUSE_CANONICAL_PATH

Change-Id: I47a41bc0b5b3a013e59932cbf66ae6852e15b1c3
2016-04-26 23:05:23 +00:00
Josh Gao 858f133d41 adb: decrease the number of fds used in fd_count test.
Default limit is 1024 fds, which means 512 socketpairs will hit the
limit.

Bug: http://b/28386497
Change-Id: Ib36404c050e4be3db51378e250f300f7ec5aab13
2016-04-26 15:45:23 -07:00
Treehugger Robot 023dc9ab5c Merge "adb: fix test_device.py shell protocol checks." am: 52eb602
am: 8a77b30

* commit '8a77b300bead94a90a62dce2e53526cd2d2071ae':
  adb: fix test_device.py shell protocol checks.

Change-Id: I92176c64aeabb9195b69efc2ced1b2c38a70de6c
2016-04-26 21:48:12 +00:00
David Pursell 8a77b300be Merge "adb: fix test_device.py shell protocol checks."
am: 52eb602

* commit '52eb6025edad892b7e346ad87dd52101a0ef1a6a':
  adb: fix test_device.py shell protocol checks.

Change-Id: Ie3dfde1bfda3172125df7f1487755e720f43133f
2016-04-26 21:44:23 +00:00
Treehugger Robot 52eb6025ed Merge "adb: fix test_device.py shell protocol checks." 2016-04-26 21:35:55 +00:00
Treehugger Robot 3bee0a2d55 Merge "Don\'t hardcode gtest paths." am: 6b617c7
am: 50db67e

* commit '50db67ef973547d6c2c0c3af39f78760fdf3d0f3':
  Don't hardcode gtest paths.

Change-Id: I422395f16dab27d992b4514e5d8b238e0e4f8675
2016-04-26 21:34:02 +00:00