Re: [PATCH] rust_binder: Avoid holding lock when dropping delivered_death

From: Alice Ryhl

Date: Sat Apr 04 2026 - 04:10:50 EST


On Fri, Apr 3, 2026 at 8:19 PM Matthew Maurer <mmaurer@xxxxxxxxxx> wrote:
>
> In 6c37bebd8c926, we switched to looping over the list and dropping each
> individual node, ostensibly without the lock held in the loop body.
>
> If the kernel were using Rust Edition 2024, the comment would be
> accurate, and the lock would not be held across the drop. However, the
> kernel is currently using 2021, so tail expression lifetime extension
> results in the lock being held across the drop. Explicitly binding the
> expression result to a variable makes the lockguard no longer part of a
> tail expression, causing the lock to be dropped before entering the loop
> body.
>
> This was detected via `CONFIG_PROVE_LOCKING` identifying an invalid wait
> context at the drop site.
>
> Reported-by: David Stevens <stevensd@xxxxxxxxxx>
> Signed-off-by: Matthew Maurer <mmaurer@xxxxxxxxxx>
> Cc: stable@xxxxxxxxxxxxxxx
> Fixes: eafedbc7c050 ("rust_binder: add Rust Binder driver")

Thanks
Reviewed-by: Alice Ryhl <aliceryhl@xxxxxxxxxx>