Re: [PATCH] rust_binder: do not query current thread for all ioctls
Alice Ryhl <[email protected]> Mon, 27 Jul 2026 14:48:14 +0200
| Newsgroups | org.kernel.vger.rust-for-linux,org.kernel.vger.linux-kernel |
|---|---|
| Message-ID | <CAH5fLghGicr4SsLadpNGn3qwRTSUzAPxABAUon23sj27QuEA+A@mail.gmail.com> |
On Mon, Jul 27, 2026 at 2:29 PM Alice Ryhl <[email protected]> wrote: > > The get_current_thread() method is currently called for every ioctl to > ensure that a Thread struct exists for the thread calling into the > driver. However, not all ioctls require a Thread object, so this means > we are unnecessarily creating these objects in cases where we don't need > to. If said thread does not invoke BINDER_THREAD_EXIT on exit, Binder's > Thread struct stays around until the fd is closed. For long-lived > processes the Thread object is effectively leaked. > > Furthermore, when the BINDER_GET_NODE_DEBUG_INFO ioctl is invoked by > libmemunreachable to ensure that objects reachable only through the > Binder driver are not considered leaked, this is done from a fork of the > process owning the fd, which means that it fails the group_leader check > inside get_current_thread(). This results in EINVAL errors for this > ioctl, causing libmemunreachable to report a false positive memory leak. > > Thus, do not invoke get_current_thread() for ioctls that do not require > it. > > Signed-off-by: Alice Ryhl <[email protected]> Oh I forgot to mark this as Fixes Cc: [email protected] Fixes: eafedbc7c050 ("rust_binder: add Rust Binder driver") Greg let me know if you need a version for this.