History

binder: tell userspace to dump current backtrace when detected oneway spamming

When async binder buffer got exhausted, some normal oneway transactions will also be discarded and may cause system or application failures. By that time, the binder debug information we dump may not be relevant to the root cause. And this issue is difficult to debug if without the backtrace of the thread sending spam. This change will send BR_ONEWAY_SPAM_SUSPECT to userspace when oneway spamming is detected, request to dump current backtrace. Oneway spamming will be reported only once when exceeding the threshold (target process dips below 80% of its oneway space, and current process is responsible for either more than 50 transactions, or more than 50% of the oneway space). And the detection will restart when the async buffer has returned to a healthy state.

Hang Lu committed 5 years ago

Commit a7dc1e61 parent 00516915 files · +56 −8Browse files

Showing the changes to include/uapi/linux/android (1 of 5 files). Show all

Unified · Split

include/uapi/linux/android/binder.h+8−0
@@ -241,6 +241,7 @@ struct binder_frozen_status_info { · 240 unmodified lines
241#define BINDER_SET_CONTEXT_MGR_EXT _IOW('b', 13, struct flat_binder_object)241#define BINDER_SET_CONTEXT_MGR_EXT _IOW('b', 13, struct flat_binder_object)
242#define BINDER_FREEZE _IOW('b', 14, struct binder_freeze_info)242#define BINDER_FREEZE _IOW('b', 14, struct binder_freeze_info)
243#define BINDER_GET_FROZEN_INFO _IOWR('b', 15, struct binder_frozen_status_info)243#define BINDER_GET_FROZEN_INFO _IOWR('b', 15, struct binder_frozen_status_info)
244#define BINDER_ENABLE_ONEWAY_SPAM_DETECTION _IOW('b', 16, __u32)
244 245
245/*246/*
246 * NOTE: Two special error codes you should check for when calling247 * NOTE: Two special error codes you should check for when calling
@@ -428,6 +429,13 @@ enum binder_driver_return_protocol { · 181 unmodified lines
428 * The target of the last transaction (either a bcTRANSACTION or429 * The target of the last transaction (either a bcTRANSACTION or
429 * a bcATTEMPT_ACQUIRE) is frozen. No parameters.430 * a bcATTEMPT_ACQUIRE) is frozen. No parameters.
430 */431 */
432
433 BR_ONEWAY_SPAM_SUSPECT = _IO('r', 19),
434 /*
435 * Current process sent too many oneway calls to target, and the last
436 * asynchronous transaction makes the allocated async buffer size exceed
437 * detection threshold. No parameters.
438 */
431};439};
432 440
433enum binder_driver_command_protocol {441enum binder_driver_command_protocol {