Re: [PATCH] rust_binder: check context manager before creating node

From: Alice Ryhl

Date: Thu Jun 18 2026 - 07:52:24 EST


On Thu, Jun 18, 2026 at 12:27:49PM +0200, Greg Kroah-Hartman wrote:
> On Thu, Jun 18, 2026 at 03:50:30AM +0530, Keshav Verma wrote:
> > Rust Binder currently creates the Binder node before checking
> > whether a context manager is already registered. If a context manager already
> > exists, set_manager_node() returns -EBUSY after node state has already been
> > created.
>
> Odd line-wrapping :(
>
> >
> > Add a check before creating the node to match the C Binder ordering for
> > the common already registered case. Keep the final checks in set_manager_node()
> > so races with another caller are still handled after node creation.
> >
> > Signed-off-by: Keshav Verma <iganschel@xxxxxxxxx>
>
> What commit id does this "fix"?

There's no need to mark this as a fix. It's nothing more than a
fast-path that does less work when exiting on error. As the commit
message notes, the existing error check after get_node() is still needed
because otherwise two threads could invoke this in parallel leading to
multiple context managers.

> > + pub(crate) fn check_manager(&self, cred: &Credential) -> Result {
> > + let manager = self.manager.lock();
> > + if manager.node.is_some() {
> > + pr_warn!("BINDER_SET_CONTEXT_MGR already set");
>
> How can this be triggered?

If two processes try to register themselves as the context manager of
this context, this occurs. The warning should probably be using
rate-limited printing.

Alice