[Android] Implement exit info extraction and process crash parsing - #5454
[Android] Implement exit info extraction and process crash parsing#5454IvanBM18 wants to merge 5 commits into
Conversation
2ee401b to
06ad0cc
Compare
0d0746c to
0081f44
Compare
0081f44 to
4e5b219
Compare
1c4eb3d to
926e938
Compare
| PID of the package's latest process if found, None otherwise. | ||
| """ | ||
| if not app_package: | ||
| return None |
There was a problem hiding this comment.
it might be helpful to log these cases. When would you expect app_package or logcat_output to be None?
There was a problem hiding this comment.
Sure, adding log!
the app's package should never be empty in a blackbox android fuzzing session, its catched very early into the session execution(top of my mind, in bad build check)
But i added this validations if someone ever calls this method in a CG fuzzing session.
There was a problem hiding this comment.
on the contrary logcat output shouldn't be empty if we are launching activities... but again in CG fuzzing this may not be the case, would have to monitor this changes for CG once they land
| ProcessExitInfo object if metadata for target_pid is found and parsed, | ||
| None otherwise. | ||
| """ | ||
| if not app_package or target_pid is None: |
There was a problem hiding this comment.
Dito ^.
BUT worth noting that if a pkg doesn't have exit info it means that is still running
| Returns: | ||
| Dumpsys output for the application package. | ||
| """ | ||
| dumpsys_output = run_shell_command( |
There was a problem hiding this comment.
how long is the dumpsys activity kept around? And is it written to immediately following a crash?
This approach seems like it would work but it's a bit indirect
There was a problem hiding this comment.
Is persistent in the disk, but it can be deleted using:
adb shell am clear-exit-info [<PACKAGE>]
adb uninstall <app>
926e938 to
52bdb16
Compare
dylanjew
left a comment
There was a problem hiding this comment.
LGTM, same question about checking with GOSST for the Android instance
| try: | ||
| return enum_cls(int(raw_value)) | ||
| except (ValueError, TypeError): | ||
| return None |
There was a problem hiding this comment.
nit: add a log so that this doesn't silently lose the input
c3e42ea to
756a828
Compare
Bug: b/553141628
Overview
Since Android API level 30 (and all apps targeting Android 11+), Android introduced
ApplicationExitInfoto report process exit reasons and historical diagnostic metadata viadumpsys activity exit-info.Testcase execution using
am startalmost 99% of the time returns exit code 0 regardless of whether the activity crashed or failed. To overcome this, this PR introduces core helper utilities to fetchdumpsys activity exit-infovia ADB, extract process PIDs from ActivityManager logcat output, parse termination metadata, and evaluate activity crashes.Learn more:
• https://developer.android.com/reference/android/app/ApplicationExitInfo
Changes
src/clusterfuzz/_internal/platforms/android/adb.py: Addedget_activity_exit_info()to fetch dumpsys exit metadata for a package.src/clusterfuzz/_internal/platforms/android/logger.py: Addedlog_activity_manager_output()helper to read ActivityManager logcat entries.src/clusterfuzz/_internal/platforms/android/util.py: Implementedget_latest_pid_for_package(),get_exit_info_for_pid(),activity_crashed(), andactivity_crashed_by_package().src/clusterfuzz/_internal/tests/core/platforms/android/util_test.py: Added comprehensive unit tests for PID retrieval, exit-info parsing, and crash evaluation.Tests performed
When this happen now CF correctly determines that the app crashed due to runtime issues not related to memory errors.
PR stack
masterfeature/android-exit-code-constantsfeature/android-exit-code-core👈feature/android-exit-code-process-handlerfeature/android-bad-build-check