From: Alice Ryhl <aliceryhl@google.com>
To: Adhyansh Verma <adhyanshverma2010@gmail.com>
Cc: "Alice Ryhl" <aliceryhl@google.com>,
"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
"Carlos Llamas" <cmllamas@google.com>,
"Arve Hjønnevåg" <arve@android.com>,
"Todd Kjos" <tkjos@android.com>,
"Christian Brauner" <brauner@kernel.org>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] rust_binder: fix process leak on proc file creation failure
Date: Fri, 27 Nov 2026 11:26:08 +0000 [thread overview]
Message-ID: <20261127112608.1537695-1-aliceryhl@google.com> (raw)
In-Reply-To: <20261127100846.67589-1-adhyanshverma2010@gmail.com>
On Fri, Nov 27, 2026 at 03:38:46PM +0530, Adhyansh Verma wrote:
> In rust_binder_open(), Process::open() allocates and initializes a new
> Process struct, registering it into the binder context's process list
> (Context::manager.all_procs) via Context::register_process(). Because
> Context holds an Arc<Process> in all_procs, and Process holds an
> Arc<Context>, a cyclic reference is established.
>
> Immediately following Process::open(), rust_binder_open() attempts to
> create the proc file via BinderfsProcFile::new(). If this call fails
> (e.g. under memory pressure when allocating the proc file dentry or
> inode), rust_binder_open() returns err.to_errno() immediately.
>
> Because open() returned an error, VFS drops the struct file and will
> never invoke the ->release() file operation (rust_binder_release()).
> Consequently, Process::deferred_release() is never scheduled, and
> Context::deregister_process() is never called to remove the Process
> from all_procs.
>
> As a result, the cyclic reference prevents the Process from being
> dropped, permanently leaking the Process struct, credentials, and task
> references in kernel memory, while leaving a stale entry in all_procs.
>
> Fix this by explicitly calling process.ctx.deregister_process(&process)
> on the BinderfsProcFile::new() failure path to break the reference
> cycle and allow the Process to be freed when exiting rust_binder_open().
>
> Fixes: eafedbc7c050 ("rust_binder: add Rust Binder driver")
> Signed-off-by: Adhyansh Verma <adhyanshverma2010@gmail.com>
Reviewed-by: Alice Ryhl <aliceryhl@google.com>
Thanks!
Alice
prev parent reply other threads:[~2026-11-27 11:26 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-27 10:08 Adhyansh Verma
2026-11-27 11:26 ` Alice Ryhl [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261127112608.1537695-1-aliceryhl@google.com \
--to=aliceryhl@google.com \
--cc=adhyanshverma2010@gmail.com \
--cc=arve@android.com \
--cc=brauner@kernel.org \
--cc=cmllamas@google.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=tkjos@android.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®