Skip to content

Commit 6c37beb

Browse files
Darksonngregkh
authored andcommitted
rust_binder: avoid mem::take on delivered_deaths
Similar to the previous commit, List::remove is used on delivered_deaths, so do not use mem::take on it as that may result in violations of the List::remove safety requirements. I don't think this particular case can be triggered because it requires fd close to run in parallel with an ioctl on the same fd. But let's not tempt fate. Cc: stable@vger.kernel.org Fixes: eafedbc ("rust_binder: add Rust Binder driver") Signed-off-by: Alice Ryhl <aliceryhl@google.com> Acked-by: Miguel Ojeda <ojeda@kernel.org> Link: https://patch.msgid.link/20251111-binder-fix-list-remove-v1-2-8ed14a0da63d@google.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 3e0ae02 commit 6c37beb

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

drivers/android/binder/process.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1362,8 +1362,12 @@ impl Process {
13621362
work.into_arc().cancel();
13631363
}
13641364

1365-
let delivered_deaths = take(&mut self.inner.lock().delivered_deaths);
1366-
drop(delivered_deaths);
1365+
// Clear delivered_deaths list.
1366+
//
1367+
// Scope ensures that MutexGuard is dropped while executing the body.
1368+
while let Some(delivered_death) = { self.inner.lock().delivered_deaths.pop_front() } {
1369+
drop(delivered_death);
1370+
}
13671371

13681372
// Free any resources kept alive by allocated buffers.
13691373
let omapping = self.inner.lock().mapping.take();

0 commit comments

Comments
 (0)