Commit graph

58613 commits

Author SHA1 Message Date
Tom Cherry
94b299ab43 logd: consolidate command handling and fix an error check
Consolidate command handling for commands that take a buffer ID as
their first argument.  Further use ParseUint instead of atoi(), since
atoi("bad string") returns `0` is the same as LOG_ID_MAIN.

Test: these commands are handled property
Test: `echo -n 'getLogSize ignoreme!\0' | nc -U /dev/socket/logd`
      returns an error
Change-Id: I3e84a6157e16f4c110681da453e1ae1a920da7c4
2020-08-07 09:48:16 -07:00
Tom Cherry
ca0a46aefa Merge "Query log size properties only within logd" 2020-08-06 22:00:29 +00:00
Tom Cherry
39dc221026 Query log size properties only within logd
liblog exposed __android_logger_get_buffer_size() which queries log
size properties, but that should not be a generic library function.
Logd should be the only process that queries these properties and
other processes should query the actual used log sizes from logd via
the android_logger_get_log_*_size() functions.

Also, always use 1MB for log buffer tests, instead of just on host and
various other clean up related to improper types.

Test: log buffers are correctly sized
Merged-In: I9b7c86bf58e569618737afe9097cf1c4d4e61d95
Change-Id: I9b7c86bf58e569618737afe9097cf1c4d4e61d95
2020-08-06 20:32:45 +00:00
Treehugger Robot
b96cc0bfd2 Merge "Add the rough toybox version numbers to the docs." 2020-08-06 18:30:15 +00:00
Treehugger Robot
30e542983a Merge "cts: Skip CtsInitTestCases over a native bridge." 2020-08-06 17:31:56 +00:00
Elliott Hughes
60dfa184a7 Add the rough toybox version numbers to the docs.
Bug: https://github.com/landley/toybox/issues/230
Test: treehugger
Change-Id: I007cb2fd5fc4b2258394e7472c12df4acb25ebcc
2020-08-06 10:15:25 -07:00
Christopher Ferris
c625ea6137 Merge "Add new caps from kernel 5.8." 2020-08-06 16:31:03 +00:00
Kazuhiro Inaba
c293c58660 cts: Skip CtsInitTestCases over a native bridge.
The set of linked binaries was making it difficult to run
the test over a native bridge. Since init won't usually
run over a native bridge, the test can be skipped.

Bug: 161081809, 142324733, 162288553
Test: Arm build of CtsInitTestCases skips rammus-arc-r Chromebook.
Change-Id: Icdd8b03111d0f3fd6658ee6d9a97fca27181db45
(cherry picked from commit 9cecf8422a)
2020-08-07 01:11:29 +09:00
Tom Cherry
539f5e3880 Merge changes I2dd4ec10,I8b9688a9
* changes:
  logcat: replace write() calls with WriteFully()
  Add android_logger_get_log_consumed_size() and report it in logcat
2020-08-05 23:27:03 +00:00
Eric Biggers
64d1a3d60e Merge "fs_mgr: Revert "Try to recover corrupted ext4 /data with backup superblock"" 2020-08-05 22:28:53 +00:00
Tom Cherry
3e970d430f logcat: replace write() calls with WriteFully()
There is a possibility of data loss if an interrupt occurs in the
middle of these write() calls.

Test: logcat -g/-S/-B work correctly
Change-Id: I2dd4ec10771714fc49b61538d3028983516e106c
2020-08-05 14:01:11 -07:00
Tom Cherry
06e111a148 Add android_logger_get_log_consumed_size() and report it in logcat
There is an existing API, android_logger_get_log_readable_size() which
historically reported the consumed amount of data for the chatty log
buffer, since consumed and readable are synonymous with that buffer
type.

With log compression, readable and consumed are not synonymous, since
the readable log size is the uncompressed log size whereas the
consumed log size is the compressed log size.

This change adds android_logger_get_log_consumed_size() which returns
the consumed log size and makes android_logger_get_log_readable_size()
return the readable log size.  Note that these values are identical if
compression is not used.

It adds both statistics to logcat:

    main: ring buffer is 1 MiB (429 KiB consumed, 817 KiB readable)
    radio: ring buffer is 1 MiB (339 KiB consumed, 715 KiB readable)
    ...

Test: logcat prints the right values with compression and chatty
Change-Id: I8b9688a987736204e2e6026e8635fbd1a5e68bb7
2020-08-05 13:43:31 -07:00
Tom Cherry
368c70daba Merge "liblog: add a timeout for logd command socket operations" 2020-08-05 19:18:07 +00:00
Christopher Ferris
a39e39fe31 Merge "Fix fuzzer so it doesn't add overlapping maps." 2020-08-05 16:32:04 +00:00
Joshua Duong
a65d905b4a Merge "[adb] Correctly read host/user name on Windows." 2020-08-05 15:25:47 +00:00
Christopher Ferris
ab60ca583a Add new caps from kernel 5.8.
Test: Builds and boots on a bonito.
Change-Id: I8dff4818bb98be3d731256be100a1c4aed4d414c
2020-08-04 22:57:44 -07:00
Tom Cherry
0d847fb4cb liblog: add a timeout for logd command socket operations
Add a 2s timeout for logd command socket operations:
  android_logger_clear
  android_logger_get_log_readable_size
  android_logger_get_log_size
  android_logger_set_log_size
  android_logger_get_statistics
  android_logger_get_prune_list
  android_logger_set_prune_list

That correspond to:
  logcat -c
  logcat -g
  logcat -G
  logcat -S
  logcat -p
  logcat -P

These operations should return immediately in typical circumstances,
but if logd is stuck, they would otherwise block indefinitely.  This
allows the commands to gracefully timeout instead.

Test: kill -s STOP `pidof logd`; logcat -g (and other options)
      times out appropriately
Test: logcat -g (and other options) work successfully otherwise
Change-Id: I6c4671a9b3daa4a454c0a14ae7d0b7d3b08be77a
2020-08-04 17:41:47 -07:00
Christopher Ferris
63525c8d6c Fix fuzzer so it doesn't add overlapping maps.
The fuzzer was creating individual maps that overlapped with other maps.
Since this is not possible in the real world unless the kernel is broken,
do not let the fuzzer do this. This resulted in memory leaks, because some
parts of the code have this assumption baked in.

Bug: 160895854

Test: Ran fuzzer test case that leaked memory and verified it no longer does.
Change-Id: I9f3c1e28781093b041b747e1566fb51d40d2bf71
2020-08-04 16:08:12 -07:00
Tom Cherry
03325fb854 Merge "libmodprobe: remove SetMinimumLogSeverity() from constructor" 2020-08-04 21:30:09 +00:00
Eric Biggers
dc3e897a88 fs_mgr: Revert "Try to recover corrupted ext4 /data with backup superblock"
This reverts commit 72abd7b246
(change Ia39af3340c0e241f62557b7c2cc8b800443342f9).

When vold enables either FDE or metadata encryption, it encrypts the
filesystem in-place.  Unfortunately, due to a bug, for ext4 filesystems
it hasn't been encrypting the backup superblocks.

Also, in read_ext4_superblock(), the check for
StartsWith(blk_device, "/dev/block/dm-") can return true even if the
encryption mapping hasn't been added yet, since when a GSI image is
booted the userdata block device is a logical volume using dm-linear.

The result is that read_ext4_superblock() can recognize a backup
superblock when the encryption mapping hasn't been added yet, causing
e2fsck to run without the encryption mapping and corrupt the filesystem.

https://android-review.googlesource.com/c/platform/system/vold/+/1385029
will fix this for new or factory-reset devices.  However, there probably
are many existing devices that already have their backup superblocks
unencrypted.  Therefore, the EncryptInPlace fix isn't enough and we have
to revert the change that started using the backup superblocks too.

Bug: 161871210
Bug: 162479411
Change-Id: I279f84c072bc6c8d3e251a5e95c78f8d6c0d50ba
2020-08-04 11:34:30 -07:00
Steven Moreland
fe8dec0447 Merge "perfboot: significant figures + units for summary" 2020-08-04 18:10:32 +00:00
Tom Cherry
3085d957e8 libmodprobe: remove SetMinimumLogSeverity() from constructor
Only the parent executable, not libraries should set this value.

Note that `modprobe` in toolbox and first stage init, the two primary
users of this library already set this same minimum log severity.

Test: build
Change-Id: I888968deede3323cc270efc3cfd1b40fc521d2da
2020-08-04 08:28:36 -07:00
Jaegeuk Kim
ef2c28bf71 Merge "support f2fs casefolding formatting tool" 2020-08-04 04:18:07 +00:00
Joshua Duong
62a42ec8ca [adb] Correctly read host/user name on Windows.
Bug: 162111908

Test: On linux/mac:
HOSTNAME="" adb keygen mykey; cat mykey.pub # Also LOGNAME
HOSTNAME="测试" adb keygen mykey; cat mykey.pub
HOSTNAME="test" adb keygen mykey; cat mykey.pub

Test: On Windows:
set COMPUTERNAME=&& adb keygen mykey
&& powershell -command "get-content -encoding utf8 mykey.pub" # Also USERNAME
set COMPUTERNAME=测试&& adb keygen mykey
&& powershell -command "get-content -encoding utf8 mykey.pub"
set COMPUTERNAME=test&& adb keygen mykey
&& powershell -command "get-content -encoding utf8 mykey.pub"

Change-Id: I62c952c511a620286aa4e05b1763361406e9f89a
2020-08-03 18:55:17 -07:00
Steven Moreland
18b73dd0b6 perfboot: significant figures + units for summary
This is correct significant figures/units based on the precision of our
measurements, but it does not reflect our actual certainty re the output
data, since in reality, confidence is diminished by temperature, device,
hardware revision, time of day/month/year, spurious activity, data
connectivity, app install list, inherent randomness of multiprogramming,
sensor activity, user interaction, /data caches, build-by-build
differences, charging state, data fragmentation, race-driven sleeps,
cosmic radiation, factory defects, local magnetic or gravitational field
differences, changes in device momentum, or other known and unknown
causes.

Bug: N/A
Test: run perfboot.py, and output has:
    mean: 10801 ms
    median: 10801 ms
    standard deviation: 18 ms
Change-Id: I796396acc203b29e9a14e4d6dffa58db7b8cd9fb
2020-08-04 00:58:40 +00:00
Tom Cherry
001a5df898 Merge "liblog: don't cache property size values and move to own file" 2020-08-03 22:59:03 +00:00
Tom Cherry
d851b2ab07 Merge "liblog: use unique log tags for is_loggable tests" 2020-08-03 20:46:30 +00:00
Tom Cherry
d2743ef5c9 liblog: don't cache property size values and move to own file
Don't cache the property size values since they're only queried at the
start of logd and only once during dumpstate.  Initializing
SerializedLogBuffer, which includes all of the logd queries, takes
under 100us without the cache, certainly fast enough that this cache
is unneeded.

Move these functions to their own file in preparation for removing
them from liblog.

Test: log sizes set appropriately
Change-Id: I15a2fd687dcffb4eab2f22ee0825ca86e40cdba3
2020-08-03 13:17:12 -07:00
Matthew Maurer
0b9a329303 Merge "Add support for tipc_send()" 2020-08-03 19:35:55 +00:00
Elliott Hughes
5c2c72b44b Merge "libdebuggerd: do a to-do." 2020-08-03 18:56:46 +00:00
Elliott Hughes
713ec25103 libdebuggerd: do a to-do.
Until 77fdb22cf6, logd started as
AID_ROOT and then dropped its privileges. Since then, there's been no
reason to use string comparisons rather than checking the uid.

Test: pkill -SEGV logd
Test: treehugger
Change-Id: Ia709f8f59cb0ab9abac7df84c96c701b5d0a83ea
2020-08-03 18:56:35 +00:00
Tom Cherry
50d021ca7b liblog: use unique log tags for is_loggable tests
Apparently these tests are run in parallel, which causes errors since
they use the same log tag.  Use unique log tags based on pid to fix
this.

Also re-enable the previously disabled tests.

Bug: 162669552
Test: run these tests 100x+ and see that they no longer fail
Change-Id: Ib20d638e5e559bca23adec479a5dcf64075e376e
2020-08-03 11:38:59 -07:00
Tom Cherry
86adfc7b0b Merge "liblog: disable property tag tests" 2020-08-03 16:58:06 +00:00
Matthew Maurer
e251fa32fd Add support for tipc_send()
* Supports sending memfds in addition to data from an iovec
* Also add a basic test called send-fd

Bug: 117221195
Test: Run send-fd with corresponding Trusty application.
Change-Id: I562d2ff744938c868323a016659ca1332f6a576b
2020-08-03 09:30:37 -07:00
Tom Cherry
037292424e Merge "SocketClient: don't ignore SIGPIPE" 2020-08-03 15:55:47 +00:00
Elliott Hughes
9d7657b62e Merge "Update language to comply with Android's inclusive language guidance" 2020-08-03 15:38:00 +00:00
Tom Cherry
031d433472 liblog: disable property tag tests
Disable:
liblog_global_state.is_loggable_both_set
liblog_global_state.is_loggable_tag_log_priority_only

Bug: 162633089
Bug: 162669552
Test: these tests don't run
Change-Id: I82b8e6685a321ae03374e86ffbe845608aec93b5
2020-08-03 08:27:54 -07:00
Tom Cherry
3e967861da Merge "logd: Add 'print_all_logs' to replay_messages" 2020-08-03 15:19:05 +00:00
Treehugger Robot
9597f27e1b Merge "Make the udev vs plugdev distinction a bit clearer." 2020-08-01 01:47:56 +00:00
Treehugger Robot
86313d6fdb Merge "libsnapshot: Properly set partial_update_" 2020-07-31 23:02:05 +00:00
Tom Cherry
2b3ebaf5c0 SocketClient: don't ignore SIGPIPE
1) All current users are better off ignoring SIGPIPE at the beginning
   of their process instead of ignoring it just for SocketClient
2) This isn't thread safe if users did want it, since sigaction()
   ignores SIGPIPE for the entire process
3) This costs 5-10% of logd CPU time when logcat is reading logs

Also clean up the error handling in SocketClient::sendDataLockedv().

Test: kill logcat and see that logd doesn't crash
Test: run simpleperf and see that no cycles are going to sigaction
Change-Id: I6532c8a0d71338e534411707b9a9bd785145c730
2020-07-31 15:53:18 -07:00
Jeff Sharkey
7b21637782 Update language to comply with Android's inclusive language guidance
See https://source.android.com/setup/contribute/respectful-code for reference

Bug: 161896447
Change-Id: Iafcccbdbdf3ff1078e87000e2ce560ff09b43f68
2020-07-31 16:36:06 -06:00
Tom Cherry
f1d938a5a4 logd: Add 'print_all_logs' to replay_messages
Add 'print_all_logs' which is equivalent to running `logcat` from the
beginning of the captured log buffers.

Test: all logs can be replayed from the start
Change-Id: If0e25513fb294e61c834f82fbf90468c4b767424
2020-07-31 15:30:52 -07:00
Elliott Hughes
e7edfbc916 Make the udev vs plugdev distinction a bit clearer.
Bug: http://b/162109763
Test: treehugger
Change-Id: Id392d0d87dd6ba098382436062b90e3a5ed79025
2020-07-31 15:09:35 -07:00
Yifan Hong
0403d8d2d5 libsnapshot: Properly set partial_update_
On GKI updates, has_dynamic_partition_metadata() may be false. Even if
it is the case, partial_update_ should be set properly.

Test: apply GKI update
Bug: 162616968

Change-Id: Icf055d8eb3060e36b3e977541a24f62f9fe11a6f
2020-07-31 14:42:14 -07:00
Treehugger Robot
fcaed0effa Merge "logd: disable flaky tests" 2020-07-31 20:18:40 +00:00
Tom Cherry
bd5a283ccd logd: disable flaky tests
Bug: 162600780
Test: build
Change-Id: I1da7531ab1c64d77ba228096913fc23d36ef5793
2020-07-31 11:48:33 -07:00
Treehugger Robot
1c5a205fda Merge "[incremental/adb] fix signature size check" 2020-07-30 22:27:27 +00:00
Tom Cherry
88066a87bf Merge "liblog: don't use a cache for __android_log_is_debuggable()" 2020-07-30 15:20:22 +00:00
Tom Cherry
f83640d65e liblog: don't use a cache for __android_log_is_debuggable()
ro.debuggable is set by init before other processes would possibly
call __android_log_is_debuggable(), so this property can be checked
once and stored without liblog's property caching mechanisms.

Test: this function returns accurately
Change-Id: Idb1e5e10e53ca809b7f9a75164a4982f39827d4e
2020-07-29 14:49:54 -07:00