* [PATCH v2] rust_binder: unregister shrinker if binderfs initialization fails
@ 2026-11-30 8:46 Poil Zero(Shengqiang Zeng)
2026-11-30 9:03 ` Greg Kroah-Hartman
2026-11-30 9:11 ` Alice Ryhl
0 siblings, 2 replies; 3+ messages in thread
From: Poil Zero(Shengqiang Zeng) @ 2026-11-30 8:46 UTC (permalink / raw)
To: Alice Ryhl, Greg Kroah-Hartman
Cc: Arve Hjønnevåg, Todd Kjos, Christian Brauner,
Carlos Llamas, linux-kernel, rust-for-linux
BinderModule::init() registers the Binder shrinker before initializing
binderfs. If init_rust_binderfs() fails, the driver returns an error
but leaves the shrinker registered and its list_lru allocated.
Unregister the shrinker on this error path before destroying its
list_lru so that active reclaim callbacks finish before teardown.
Return the original binderfs error.
Fixes: eafedbc7c050 ("rust_binder: add Rust Binder driver")
Signed-off-by: Poil Zero(Shengqiang Zeng) <poilandgginchi@gmail.com>
---
v2 fixes the line wrapping that prevented git am from applying v1.
I build-tested the patched Rust Binder object on x86_64 at 89a312991dc6
with CONFIG_ANDROID_BINDER_IPC_RUST=y. I checked the failure path by
source inspection on v7.4-rc5 (fe6ff8d5d675).
drivers/android/binder/page_range.rs | 16 ++++++++++++++++
drivers/android/binder/rust_binder_main.rs | 6 +++++-
2 files changed, 21 insertions(+), 1 deletion(-)
diff --git a/drivers/android/binder/page_range.rs
b/drivers/android/binder/page_range.rs
index 52ffbf3..70bb3c7 100644
--- a/drivers/android/binder/page_range.rs
+++ b/drivers/android/binder/page_range.rs
@@ -103,6 +103,22 @@ impl Shrinker {
Ok(())
}
+
+ /// Unregister this shrinker and destroy its LRU.
+ ///
+ /// Must only be called after a successful `register`.
+ pub(crate) fn unregister(&'static self) {
+ // SAFETY: `register` succeeded, so `inner` points at a
registered shrinker and
+ // `list_lru` is initialized.
+ unsafe {
+ let shrinker = *self.inner.get();
+ if !shrinker.is_null() {
+ bindings::shrinker_free(shrinker);
+ self.inner.get().write(ptr::null_mut());
+ }
+ bindings::list_lru_destroy(self.list_lru.get());
+ }
+ }
}
/// A container that manages a page range in a vma.
diff --git a/drivers/android/binder/rust_binder_main.rs
b/drivers/android/binder/rust_binder_main.rs
index 955c4c3..1a4b86e 100644
--- a/drivers/android/binder/rust_binder_main.rs
+++ b/drivers/android/binder/rust_binder_main.rs
@@ -309,7 +309,11 @@ impl kernel::Module for BinderModule {
BINDER_SHRINKER.register(c"android-binder")?;
// SAFETY: The module is being loaded, so we can initialize binderfs.
- unsafe { kernel::error::to_result(binderfs::init_rust_binderfs())? };
+ let ret = unsafe { binderfs::init_rust_binderfs() };
+ if ret != 0 {
+ BINDER_SHRINKER.unregister();
+ return Err(kernel::error::Error::from_errno(ret));
+ }
Ok(Self { _netlink: netlink })
}
base-commit: 89a312991dc6e638a36adc43ccb91dbc25504c04
--
Poil Zero(Shengqiang Zeng)
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH v2] rust_binder: unregister shrinker if binderfs initialization fails
2026-11-30 8:46 [PATCH v2] rust_binder: unregister shrinker if binderfs initialization fails Poil Zero(Shengqiang Zeng)
@ 2026-11-30 9:03 ` Greg Kroah-Hartman
2026-11-30 9:11 ` Alice Ryhl
1 sibling, 0 replies; 3+ messages in thread
From: Greg Kroah-Hartman @ 2026-11-30 9:03 UTC (permalink / raw)
To: Poil Zero(Shengqiang Zeng)
Cc: Alice Ryhl, Arve Hjønnevåg, Todd Kjos,
Christian Brauner, Carlos Llamas, linux-kernel, rust-for-linux
On Mon, Nov 30, 2026 at 08:46:38AM +0000, Poil Zero(Shengqiang Zeng) wrote:
> BinderModule::init() registers the Binder shrinker before initializing
> binderfs. If init_rust_binderfs() fails, the driver returns an error
> but leaves the shrinker registered and its list_lru allocated.
>
> Unregister the shrinker on this error path before destroying its
> list_lru so that active reclaim callbacks finish before teardown.
> Return the original binderfs error.
>
> Fixes: eafedbc7c050 ("rust_binder: add Rust Binder driver")
> Signed-off-by: Poil Zero(Shengqiang Zeng) <poilandgginchi@gmail.com>
Hi,
This is the friendly patch-bot of Greg Kroah-Hartman. You have sent him
a patch that has triggered this response. He used to manually respond
to these common problems, but in order to save his sanity (he kept
writing the same thing over and over, yet to different people), I was
created. Hopefully you will not take offence and will fix the problem
in your patch and resubmit it so that it can be accepted into the Linux
kernel tree.
You are receiving this message because of the following common error(s)
as indicated below:
- It looks like you did not use your "real" name for the patch on either
the Signed-off-by: line, or the From: line (both of which have to
match). Please read the kernel file,
Documentation/process/submitting-patches.rst for how to do this
correctly.
If you wish to discuss this problem further, or you have questions about
how to resolve this issue, please feel free to respond to this email and
Greg will reply once he has dug out from the pending patches received
from other developers.
thanks,
greg k-h's patch email bot
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH v2] rust_binder: unregister shrinker if binderfs initialization fails
2026-11-30 8:46 [PATCH v2] rust_binder: unregister shrinker if binderfs initialization fails Poil Zero(Shengqiang Zeng)
2026-11-30 9:03 ` Greg Kroah-Hartman
@ 2026-11-30 9:11 ` Alice Ryhl
1 sibling, 0 replies; 3+ messages in thread
From: Alice Ryhl @ 2026-11-30 9:11 UTC (permalink / raw)
To: Poil Zero(Shengqiang Zeng)
Cc: Greg Kroah-Hartman, Arve Hjønnevåg, Todd Kjos,
Christian Brauner, Carlos Llamas, linux-kernel, rust-for-linux
On Mon, Nov 30, 2026 at 9:46 AM Poil Zero(Shengqiang Zeng)
<poilandgginchi@gmail.com> wrote:
>
> BinderModule::init() registers the Binder shrinker before initializing
> binderfs. If init_rust_binderfs() fails, the driver returns an error
> but leaves the shrinker registered and its list_lru allocated.
>
> Unregister the shrinker on this error path before destroying its
> list_lru so that active reclaim callbacks finish before teardown.
> Return the original binderfs error.
>
> Fixes: eafedbc7c050 ("rust_binder: add Rust Binder driver")
> Signed-off-by: Poil Zero(Shengqiang Zeng) <poilandgginchi@gmail.com>
Seems like a valid fix, thanks.
> + /// Unregister this shrinker and destroy its LRU.
> + ///
> + /// Must only be called after a successful `register`.
> + pub(crate) fn unregister(&'static self) {
> + // SAFETY: `register` succeeded, so `inner` points at a
> registered shrinker and
This patch is still broken by gmail wrapping.
> + let ret = unsafe { binderfs::init_rust_binderfs() };
> + if ret != 0 {
> + BINDER_SHRINKER.unregister();
> + return Err(kernel::error::Error::from_errno(ret));
Error is in prelude, so this can just be Error::from_errno().
Alice
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-11-30 9:11 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-30 8:46 [PATCH v2] rust_binder: unregister shrinker if binderfs initialization fails Poil Zero(Shengqiang Zeng)
2026-11-30 9:03 ` Greg Kroah-Hartman
2026-11-30 9:11 ` Alice Ryhl
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®