mirror of
https://github.com/torvalds/linux.git
synced 2026-09-23 05:04:02 +02:00
rust_binder: Implement BINDER_DEBUG_USER_ERROR for freezer-related operation
This adds dynamic debug logs for: - Requesting freeze notifications on invalid references, duplicate cookies, or already active registrations. - Completing freeze notifications that are not pending or not found. - Clearing freeze notifications on invalid references, inactive notifications, or cookie mismatches. Reviewed-by: Carlos Llamas <cmllamas@google.com> Reviewed-by: Alice Ryhl <aliceryhl@google.com> Signed-off-by: Jahnavi MN <jahnavimn@google.com> Link: https://patch.msgid.link/20260716-rust_binder_debug_mask-v4-2-3d7436c2d2f2@google.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
2847d9ab08
commit
d8f87e4ede
|
|
@ -189,12 +189,15 @@ pub(crate) fn request_freeze_notif(
|
|||
info = match node_refs.by_handle.get_mut(&handle) {
|
||||
Some(info) => info,
|
||||
None => {
|
||||
pr_warn!("BC_REQUEST_FREEZE_NOTIFICATION invalid ref {}\n", handle);
|
||||
binder_debug!(
|
||||
UserError,
|
||||
"BC_REQUEST_FREEZE_NOTIFICATION invalid ref {handle}"
|
||||
);
|
||||
return Err(EINVAL);
|
||||
}
|
||||
};
|
||||
if info.freeze().is_some() {
|
||||
pr_warn!("BC_REQUEST_FREEZE_NOTIFICATION already set\n");
|
||||
binder_debug!(UserError, "BC_REQUEST_FREEZE_NOTIFICATION already set");
|
||||
return Err(EINVAL);
|
||||
}
|
||||
let node_ref = info.node_ref();
|
||||
|
|
@ -202,7 +205,7 @@ pub(crate) fn request_freeze_notif(
|
|||
|
||||
if let rbtree::Entry::Occupied(ref dupe) = freeze_entry {
|
||||
if !dupe.get().allow_duplicate(&node_ref.node) {
|
||||
pr_warn!("BC_REQUEST_FREEZE_NOTIFICATION duplicate cookie\n");
|
||||
binder_debug!(UserError, "BC_REQUEST_FREEZE_NOTIFICATION duplicate cookie");
|
||||
return Err(EINVAL);
|
||||
}
|
||||
}
|
||||
|
|
@ -267,7 +270,11 @@ pub(crate) fn freeze_notif_done(self: &Arc<Self>, reader: &mut UserSliceReader)
|
|||
let mut node_refs_guard = self.node_refs.lock();
|
||||
let node_refs = &mut *node_refs_guard;
|
||||
let Some(freeze) = node_refs.freeze_listeners.get_mut(&cookie) else {
|
||||
pr_warn!("BC_FREEZE_NOTIFICATION_DONE {:016x} not found\n", cookie.0);
|
||||
binder_debug!(
|
||||
UserError,
|
||||
"BC_FREEZE_NOTIFICATION_DONE {:016x} not found",
|
||||
cookie.0
|
||||
);
|
||||
return Err(EINVAL);
|
||||
};
|
||||
let mut clear_msg = None;
|
||||
|
|
@ -277,8 +284,9 @@ pub(crate) fn freeze_notif_done(self: &Arc<Self>, reader: &mut UserSliceReader)
|
|||
freeze.num_cleared_duplicates += 1;
|
||||
} else {
|
||||
if !freeze.is_pending {
|
||||
pr_warn!(
|
||||
"BC_FREEZE_NOTIFICATION_DONE {:016x} not pending\n",
|
||||
binder_debug!(
|
||||
UserError,
|
||||
"BC_FREEZE_NOTIFICATION_DONE {:016x} not pending",
|
||||
cookie.0
|
||||
);
|
||||
return Err(EINVAL);
|
||||
|
|
@ -307,19 +315,31 @@ pub(crate) fn clear_freeze_notif(self: &Arc<Self>, reader: &mut UserSliceReader)
|
|||
let mut node_refs_guard = self.node_refs.lock();
|
||||
let node_refs = &mut *node_refs_guard;
|
||||
let Some(info) = node_refs.by_handle.get_mut(&handle) else {
|
||||
pr_warn!("BC_CLEAR_FREEZE_NOTIFICATION invalid ref {}\n", handle);
|
||||
binder_debug!(
|
||||
UserError,
|
||||
"BC_CLEAR_FREEZE_NOTIFICATION invalid ref {handle}"
|
||||
);
|
||||
return Err(EINVAL);
|
||||
};
|
||||
let Some(info_cookie) = info.freeze() else {
|
||||
pr_warn!("BC_CLEAR_FREEZE_NOTIFICATION freeze notification not active\n");
|
||||
binder_debug!(
|
||||
UserError,
|
||||
"BC_CLEAR_FREEZE_NOTIFICATION freeze notification not active"
|
||||
);
|
||||
return Err(EINVAL);
|
||||
};
|
||||
if *info_cookie != cookie {
|
||||
pr_warn!("BC_CLEAR_FREEZE_NOTIFICATION freeze notification cookie mismatch\n");
|
||||
binder_debug!(
|
||||
UserError,
|
||||
"BC_CLEAR_FREEZE_NOTIFICATION freeze notification cookie mismatch"
|
||||
);
|
||||
return Err(EINVAL);
|
||||
}
|
||||
let Some(listener) = node_refs.freeze_listeners.get_mut(&cookie) else {
|
||||
pr_warn!("BC_CLEAR_FREEZE_NOTIFICATION invalid cookie {}\n", handle);
|
||||
binder_debug!(
|
||||
UserError,
|
||||
"BC_CLEAR_FREEZE_NOTIFICATION invalid cookie {handle}"
|
||||
);
|
||||
return Err(EINVAL);
|
||||
};
|
||||
listener.is_clearing = true;
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user