Skip to content

Commit d90eeb8

Browse files
Darksonngregkh
authored andcommitted
binder: remove "invalid inc weak" check
There are no scenarios where a weak increment is invalid on binder_node. The only possible case where it could be invalid is if the kernel delivers BR_DECREFS to the process that owns the node, and then increments the weak refcount again, effectively "reviving" a dead node. However, that is not possible: when the BR_DECREFS command is delivered, the kernel removes and frees the binder_node. The fact that you were able to call binder_inc_node_nilocked() implies that the node is not yet destroyed, which implies that BR_DECREFS has not been delivered to userspace, so incrementing the weak refcount is valid. Note that it's currently possible to trigger this condition if the owner calls BINDER_THREAD_EXIT while node->has_weak_ref is true. This causes BC_INCREFS on binder_ref instances to fail when they should not. Cc: [email protected] Fixes: 457b9a6 ("Staging: android: add binder driver") Reported-by: Yu-Ting Tseng <[email protected]> Signed-off-by: Alice Ryhl <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 2463ae2 commit d90eeb8

File tree

1 file changed

+1
-10
lines changed

1 file changed

+1
-10
lines changed

drivers/android/binder.c

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -851,17 +851,8 @@ static int binder_inc_node_nilocked(struct binder_node *node, int strong,
851851
} else {
852852
if (!internal)
853853
node->local_weak_refs++;
854-
if (!node->has_weak_ref && list_empty(&node->work.entry)) {
855-
if (target_list == NULL) {
856-
pr_err("invalid inc weak node for %d\n",
857-
node->debug_id);
858-
return -EINVAL;
859-
}
860-
/*
861-
* See comment above
862-
*/
854+
if (!node->has_weak_ref && target_list && list_empty(&node->work.entry))
863855
binder_enqueue_work_ilocked(&node->work, target_list);
864-
}
865856
}
866857
return 0;
867858
}

0 commit comments

Comments
 (0)