Add an option to defer BC_REQUEST_FREEZE_NOTIFICATION when needed
Before this commit, user space may send BC_REQUEST_FREEZE_NOTIFICATION before receiving BR_CLEAR_FREEZE_NOTIFICATION_DONE for the previous listener session on the same binder node. This leads to a race condition where notifications could be received out of order. Here is an example 1. User space sends BC_REQUEST_FREEZE_NOTIFICATION with cookie A 2. Kernel sends BR_FROZEN_BINDER with frozen=false to user space 3. User space sends BC_CLEAR_FREEZE_NOTIFICATION with cookie A 4. Target process is frozen 5. User space sends BC_REQUEST_FREEZE_NOTIFICATION with cookie A 6. Kernel sends BR_FROZEN_BINDER with frozen=true to user space 7. The two BR_FROZEN_BINDER from step 2 and 6 may be picked up by user space in an arbitrary order. This is undesired. We want the last notification to be frozen=true. The commit adds a new codepath (default off) that fixes this issue by deferring BC_REQUEST_FREEZE_NOTIFICATION until user space receives BR_CLEAR_FREEZE_NOTIFICATION_DONE. This ensures that a new listener session never happens until the previous one is fully completed. Change-Id: Ia026db0b2065ad8ee4cd56c75d49b459c6319ae0 Bug: 425638507 Flag: build.RELEASE_LIBBINDER_DEFER_BC_REQUEST_FREEZE_NOTIFICATION
Loading
Please register or sign in to comment