[PATCH 0/3] Fix race condition in Devres

Danilo Krummrich posted 3 patches 6 months, 2 weeks ago
There is a newer version of this series
rust/bindings/bindings_helper.h |   1 +
rust/helpers/completion.c       |   8 +++
rust/helpers/helpers.c          |   1 +
rust/kernel/devres.rs           |  33 ++++++++--
rust/kernel/revocable.rs        |  18 ++++--
rust/kernel/sync.rs             |   2 +
rust/kernel/sync/completion.rs  | 111 ++++++++++++++++++++++++++++++++
7 files changed, 163 insertions(+), 11 deletions(-)
create mode 100644 rust/helpers/completion.c
create mode 100644 rust/kernel/sync/completion.rs
[PATCH 0/3] Fix race condition in Devres
Posted by Danilo Krummrich 6 months, 2 weeks ago
This patch series fixes a race condition in Devres.

Please see patch 3 "rust: devres: fix race in Devres::drop()" for a detailed
description of the race and how it is fixed.

None of the upstream users of Devres is prone to this race, hence we do not
necessarily have to backport this -- yet, it must be fixed.

Thanks to Alice for catching and reporting this!

A branch containing those patches can be found in [1].

[1] https://git.kernel.org/pub/scm/linux/kernel/git/dakr/linux.git/log/?h=rust/devres-race

Danilo Krummrich (3):
  rust: completion: implement initial abstraction
  rust: revocable: indicate whether `data` has been revoked already
  rust: devres: fix race in Devres::drop()

 rust/bindings/bindings_helper.h |   1 +
 rust/helpers/completion.c       |   8 +++
 rust/helpers/helpers.c          |   1 +
 rust/kernel/devres.rs           |  33 ++++++++--
 rust/kernel/revocable.rs        |  18 ++++--
 rust/kernel/sync.rs             |   2 +
 rust/kernel/sync/completion.rs  | 111 ++++++++++++++++++++++++++++++++
 7 files changed, 163 insertions(+), 11 deletions(-)
 create mode 100644 rust/helpers/completion.c
 create mode 100644 rust/kernel/sync/completion.rs


base-commit: cd2e103d57e5615f9bb027d772f93b9efd567224
-- 
2.49.0
Re: [PATCH 0/3] Fix race condition in Devres
Posted by Miguel Ojeda 6 months, 2 weeks ago
On Tue, Jun 3, 2025 at 10:54 PM Danilo Krummrich <dakr@kernel.org> wrote:
>
> None of the upstream users of Devres is prone to this race, hence we do not
> necessarily have to backport this -- yet, it must be fixed.

We generally backport even soundness fixes when they do not affect
actual upstream code, so we should probably try.

On the other hand, v6.14.y may go out of support soon (a few weeks I
assume) and this does not affect LTSs.

Cheers,
Miguel