| 12d5fc96 | 21-Oct-2026 |
Linus Torvalds <torvalds@linux-foundation.org> |
Merge tag 'rust-7.4' of git://git.kernel.org/pub/scm/linux/kernel/git/ojeda/linux
Pull Rust updates from Miguel Ojeda: "Toolchain and infrastructure:
- Update vendored 'zerocopy' crate to v0.8.
Merge tag 'rust-7.4' of git://git.kernel.org/pub/scm/linux/kernel/git/ojeda/linux
Pull Rust updates from Miguel Ojeda: "Toolchain and infrastructure:
- Update vendored 'zerocopy' crate to v0.8.62 (released 2026-10-08).
This update advances 8 releases, with 3 of them carrying most of the changes. It contains new features as well as fixes. However, almost nothing has changed that requires updates on our side (a move of our non-ASCII change and the addition of an SPDX license identifier).
- Generate Rust KUnit test suites for doctests reusing the '#[kunit_tests]' and '#[test]' attributes instead of C FFI functions, which allows to remove the generated C glue file.
Relatedly, simplify 'kunit_assert!' by using 'file!()' and 'line!()' inside (which doctests override as needed), which allows to remove the 'file' helper and 'CONFIG_RUSTC_HAS_SPAN_FILE'.
- Trim the function names in doctests generated by 'rustdoc' < 1.95.0 when building with 'O=', which were not reproducible.
- Fix the 'VM_MAYSHARE' value in the generated bindings and its blocklist entry, due to typos.
- Build 'core' with '--cfg no_io_statics' to ensure 'core' does not introduce any use of 'core::sync::atomic' into the kernel image since upstream Rust is moving 'std::io::Error' into 'core', which uses a global atomic pointer.
Upstream Rust merged a PR to add a test checking that builds of 'core' are warning-free with that 'cfg' enabled.
- Enable the unstable 'proc_macro_span' feature in 'proc-macro2', which provides 'Span::join' and thus improves the quality of the diagnostics of all our procedural macros, notably 'pin-init'. This is only used for producing diagnostics, thus there is no hard reliance on the feature.
- Globally allow 'clippy::comparison_chain', since its suggestions are not always ideal and upstream downgraded it to 'pedantic' too.
'kernel' crate:
- New 'mem' module: add the 'Align<N>' zero-sized type so that alignment can be specified via const generics ('repr(align(...))' only works with integer literals), e.g.:
const N: usize = 128;
struct S { _align: Align<N>, }
assert_eq!(align_of::<S>(), N);
- New 'ratelimit' module: add the 'Ratelimit' abstraction for 'struct ratelimit_state' and, based on it, the 'pr_*_ratelimited!' printing macros, which can be used for printing that may be triggered by userspace.
In addition, convert Rust Binder to use them.
- 'sync' module: to construct a global 'struct ratelimit_state', add a 'const' constructor for 'raw_spinlock_t'.
In addition, move the lockdep types into a new 'sync::lockdep' submodule, since there were starting to be too many of them.
- 'num' module: add the 'cv!' macro to create constant values ("cv") from an integer constant expression, with validity checked at compile time, inferring the target type from the context. It works for any type that implements the new 'FromConst' trait, e.g.:
let a: Alignment = cv!(4096); let b: Bounded<u32, 4> = cv!(15);
// Any integer constant expression works, not only literals. let m: NonZero<usize> = cv!(usize::MAX);
// Checked narrowing, including in `const` items. const SMALL: u8 = cv!(200u32);
// The target type can be given explicitly. let e = cv!(200u32 => u8);
// With an explicit primitive target, the expression can use // generic parameters. const fn as_u64<const KEY: u16>() -> u64 { cv!(KEY => u64) }
This avoids the verbose turbofish syntax which disincentivized using these types at interface boundaries (e.g. 'Alignment::new::<8>()').
- 'alloc' module:
- Allow different error types in 'KBox::pin_slice()', enabling use of infallible initializers.
- Add 'NumaNode::id()' accessor to retrieve the underlying NUMA node identifier.
- 'time' module:
- Add 'Delta::to_jiffies_timeout()' for use in timeout arguments.
- Add 'Delta::as_jiffies_unsigned()'.
- Make 'Delta::ZERO' generic over the time unit.
- Warn and assert when passing out-of-range inputs to 'fsleep' and 'udelay'.
- Rename 'ClockSource' to 'ClockId' to better align with naming conventions in C kernel.
- Make 'CONFIG_HZ' value available as 'bindings::HZ'.
- Add implementation detail documentation for 'HrTimer'.
- 'bitmap' module:
- Add contiguous area operations ('next_zero_area{,_off}', 'set' and 'clear'), with extra checks compared to the underlying C code, plus additional ones under 'CONFIG_RUST_BITMAP_HARDENED'. It includes tests demonstrating the edge cases.
- Restrict bitmap length to at most 'i32::MAX', matching 'BitmapVec::MAX_LEN' and simplifying a few things. This also fixes 'u32' casts truncating in 'copy_and_extend', which could otherwise lead to OOB writes.
- 'bug' module:
- Fix 'warn_on!' on UML which called 'warn_slowpath_fmt()' with the wrong arguments; and fix its '// SAFETY:' comment too.
- Add a KUnit test for 'warn_on!'.
- 'id_pool' module: add contiguous ID reservation via the new 'reserve_ids' and 'release_ids' methods, built on top of the new bitmap area operations.
- 'sizes' module: add the sub-1K size constants ('SZ_1' to 'SZ_512') and implement 'SizeConstants' for 'Alignment', so that one can write e.g. 'Alignment::SZ_8'.
'macros' crate:
- Add '#[optional]' attribute for optional methods in '#[vtable]' to replace the 'build_error!(VTABLE_DEFAULT_ERROR)' boilerplate, e.g.:
#[vtable] pub trait Operations: Sized { #[optional] fn f(&self) -> Result; }
In addition, apply it to miscdevice and hide generated 'HAS_' constants for required methods.
- Allow non-ASCII characters in the 'authors' field of the 'module!' macro, which was unintentionally restricted when multiple authors support was introduced.
'pin-init' crate:
[ Extra context from Gary's pull request: "This is a cycle packed with feature updates. Two of the most anticipated features, tuple struct support and safe self reference creation, has been included in this pull request.
Safe self reference is a big one and is pushed a bit late in the cycle. The initial plan was to include a minimum subset for this cycle because I was worried about potential soundness issues; however during Plumbers it was agreed that the features should be upstreamed at once. This is because the initial users (Nova, JobQueue) would all need the advanced features, so it is better to ensure that the feature get put into use for real, and it can iterate with users, rather than being fully designed on paper. The existing safety checks are already very comprehensive, and Benno and I are confident that if new ones are discovered, it wouldn't affect the overall design.
That said, the the usage of the advanced features (invariance, existential lifetime) shall be limited to the pre-agreed users only, so even in case where the feature needs to be reworked, the blast radius is limited.
Another theme in this cycle is to improve the developer experience when things are used wrongly. A lot of work has been done to use proper spans from user-provided tokens so error message point to things that cause them. Many common misuse scenarios also gain additional custom diagnostics." ]
- User visible changes:
- Support tuple structs.
- Allow safe creation of self references.
- Vastly improve diagnostics for common misuse scenarios.
- Other changes:
- Use 'mixed_site' hygiene consistently.
'MAINTAINERS':
- Add 'RUST [BUG]' entry for the Rust 'bug' module (i.e. 'warn_on!'), which will be maintained by FUJITA Tomonori -- thank you!
- Add Alice Ryhl as co-maintainer for 'Rust [ALLOC]'.
And some other fixes, cleanups and improvements.
* tag 'rust-7.4' of git://git.kernel.org/pub/scm/linux/kernel/git/ojeda/linux: (91 commits) rust: zerocopy: update to v0.8.62 rust: zerocopy: fix link to upstream `README.md` rust: id_pool: add contiguous ID reservation rust: bitmap: add contiguous area operations rust: sizes: implement SizeConstants for Alignment rust: sizes: add sub-1K size constants rust: bitmap: restrict bitmap length to at most i32::MAX rust: bitmap: use function-level cfg on kunit test rust: num: add cv! macro to create values from constant expressions rust: bug: update the SAFETY comment for warn_slowpath_fmt() on UML rust: time: add Delta::as_jiffies_unsigned() rust: time: make Delta::ZERO generic over the time unit rust_binder: use pr_*_ratelimited! for printing rust: add pr_*_ratelimited! macros for printing rust: sync: add const constructor for raw_spinlock_t rust: sync: move lockdep types to rust/kernel/sync/lockdep.rs rust: pin-init: internal: suppress `explicit_outlives_requirements` MAINTAINERS: add entry for the Rust `bug` module rust: pin-init: internal: pin_data: support existential lifetimes rust: pin-init: internal: pin_data: support shared projection ...
show more ...
|
| 137d6ccf | 16-Sep-2026 |
Carlos Llamas <cmllamas@google.com> |
rust_binderfs: add transaction_report feature entry
rust_binderfs is missing the equivalent of commit f37b55ded8ed ("binder: add transaction_report feature entry"), which adds "transaction_report" t
rust_binderfs: add transaction_report feature entry
rust_binderfs is missing the equivalent of commit f37b55ded8ed ("binder: add transaction_report feature entry"), which adds "transaction_report" to the binderfs feature list. This helps userspace determine if the BINDER_CMD_REPORT from the generic netlink API is supported.
Cc: stable <stable@kernel.org> Fixes: f14e0c8183bc ("rust_binder: report netlink transactions") Signed-off-by: Carlos Llamas <cmllamas@google.com> Link: https://patch.msgid.link/20260916120833.593407-1-cmllamas@google.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
show more ...
|
| 2a74ccd1 | 03-Sep-2026 |
Alice Ryhl <aliceryhl@google.com> |
rust_binder: reschedule node refcount update on thread exit
When a thread exits via BINDER_THREAD_EXIT, its pending work items are cancelled. If a thread exits while holding a pending node refcount
rust_binder: reschedule node refcount update on thread exit
When a thread exits via BINDER_THREAD_EXIT, its pending work items are cancelled. If a thread exits while holding a pending node refcount increment (e.g. pushed as deferred work to that thread), the refcount increment was previously dropped because Node::cancel() and NodeWrapper::cancel() were no-ops.
Dropping the refcount update leaves the node's delivery state and count state desynchronized, and userspace will not receive the notification, which can cause the node to never be freed from the process's nodes tree when all external references are dropped.
Fix this by implementing DeliverToRead::cancel() for Node and NodeWrapper to move the pending refcount update to the process's work queue on thread exit so another thread can deliver it to userspace.
Cc: stable <stable@kernel.org> Fixes: eafedbc7c050 ("rust_binder: add Rust Binder driver") Signed-off-by: Alice Ryhl <aliceryhl@google.com> Link: https://patch.msgid.link/20260903-binder-thread-exit-node-v1-1-be09ff14f6a4@google.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
show more ...
|
| d9e81c71 | 28-Jul-2026 |
Alice Ryhl <aliceryhl@google.com> |
rust_binder: update indentation of failed transaction print
To properly take the changes from commit bb66b1a34525 ("rust_binder: only print failure if error has source") into account, the binder_deb
rust_binder: update indentation of failed transaction print
To properly take the changes from commit bb66b1a34525 ("rust_binder: only print failure if error has source") into account, the binder_debug! statement was moved inside the if {} block, and so there must be one more level of indentation.
Signed-off-by: Alice Ryhl <aliceryhl@google.com> Link: https://patch.msgid.link/20260728061236.198267-1-aliceryhl@google.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
show more ...
|
| 0649be3c | 19-Jul-2026 |
Jahnavi MN <jahnavimn@google.com> |
rust_binder: Update transaction flags to use kernel::impl_flags!
Transaction configuration flags are currently represented as raw integers and manipulated via bitwise operations. This lacks type saf
rust_binder: Update transaction flags to use kernel::impl_flags!
Transaction configuration flags are currently represented as raw integers and manipulated via bitwise operations. This lacks type safety, making it possible to mix up different flag types without compile-time warnings.
Use kernel::impl_flags! to migrate the transaction flags to a strongly-typed bitmask, enforcing compile-time safety.
Key changes: - Define `TransactionFlags(u32)` and `TransactionFlag` with 4 variants. - Change flags field type to `TransactionFlags` in structs. - Add `is_oneway` helper on `TransactionFlags` to simplify checks. - Update `can_replace` logic to use type-safe combined flag checks. - Convert `flags` to `u32` for FFI boundaries and logging.
Reviewed-by: Alice Ryhl <aliceryhl@google.com> Signed-off-by: Jahnavi MN <jahnavimn@google.com> Link: https://patch.msgid.link/20260719-b4-rust_binder_impl_flags-v3-2-f8d0b3ea1b87@google.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
show more ...
|
| d6e8b74f | 19-Jul-2026 |
Jahnavi MN <jahnavimn@google.com> |
rust_binder: Update looper_flags bitmaps to use kernel::impl_flags!
Thread looper states are currently represented as raw integers and manipulated via bitwise operations. This lacks type safety, mak
rust_binder: Update looper_flags bitmaps to use kernel::impl_flags!
Thread looper states are currently represented as raw integers and manipulated via bitwise operations. This lacks type safety, making it possible to mix up different flag types without compile-time warnings.
Use kernel::impl_flags! to migrate looper_flags to a strongly-typed bitmask, enforcing compile-time safety.
Key changes: - Define `LooperFlags(u32)` and `LooperFlag` enum with 7 variants. - Change `InnerThread.looper_flags` type to `LooperFlags`. - Update looper state transitions and checks to use type-safe methods. - Convert `looper_flags` to `u32` for hex formatting in `debug_print`.
Reviewed-by: Alice Ryhl <aliceryhl@google.com> Signed-off-by: Jahnavi MN <jahnavimn@google.com> Link: https://patch.msgid.link/20260719-b4-rust_binder_impl_flags-v3-1-f8d0b3ea1b87@google.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
show more ...
|
| 5d577fa6 | 02-Jul-2026 |
Nicolás Antinori <nico.antinori.7@gmail.com> |
rust_binder: use pin_init::zeroed for file_operations initialization
All types in `bindings` implement `Zeroable` if they can. This enables using `pin_init::zeroed()` for `file_operations` initializ
rust_binder: use pin_init::zeroed for file_operations initialization
All types in `bindings` implement `Zeroable` if they can. This enables using `pin_init::zeroed()` for `file_operations` initialization instead of relying on `unsafe { core::mem::MaybeUninit::zeroed().assume_init() }`.
This change improves readability and removes an unnecessary unsafe block.
Link: https://github.com/Rust-for-Linux/linux/issues/1189 Suggested-by: Benno Lossin <lossin@kernel.org> Signed-off-by: Nicolás Antinori <nico.antinori.7@gmail.com> Link: https://patch.msgid.link/20260702205803.552476-1-nico.antinori.7@gmail.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
show more ...
|
| 0f7f34c6 | 16-Jul-2026 |
Jahnavi MN <jahnavimn@google.com> |
rust_binder: Update defer_work bitmaps to use kernel::impl_flags!
- Define `DeferWorks(u8)` and `DeferWork` enum using `bit_u8` offsets. - Change `ProcessInner.defer_work` type from `u8` to `DeferWo
rust_binder: Update defer_work bitmaps to use kernel::impl_flags!
- Define `DeferWorks(u8)` and `DeferWork` enum using `bit_u8` offsets. - Change `ProcessInner.defer_work` type from `u8` to `DeferWorks`. - Update `Process::release()` and `Process::flush()` to check for empty states using `DeferWorks::empty()`. - Update the workqueue runner to inspect flags using `.contains()`.
Signed-off-by: Jahnavi MN <jahnavimn@google.com> Reviewed-by: Alice Ryhl <aliceryhl@google.com> Link: https://patch.msgid.link/20260716-b4-rust_binder_impl_flags-v1-1-b4201d3f15b3@google.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
show more ...
|
| dbb17c9e | 07-Jul-2026 |
Alice Ryhl <aliceryhl@google.com> |
rust_binder: move (e)poll wait queue to Process
Most processes do not use Rust Binder with epoll, so avoid paying the synchronize_rcu() cost in drop for those that don't need it. For those that do,
rust_binder: move (e)poll wait queue to Process
Most processes do not use Rust Binder with epoll, so avoid paying the synchronize_rcu() cost in drop for those that don't need it. For those that do, we also manage to replace synchronize_rcu() with kfree_rcu(), though we introduce an extra allocation.
In case the last ref to an Arc<Thread> is dropped outside of deferred_release(), this also ensures that synchronize_rcu() is not called in destructor of Arc<Thread> in other places. Theoretically that could lead to jank by making other syscalls slow, which would be problematic.
Signed-off-by: Alice Ryhl <aliceryhl@google.com> Reviewed-by: Boqun Feng <boqun@kernel.org> Link: https://patch.msgid.link/20260707-upgrade-poll-v6-2-4b8fae7bf1d9@google.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
show more ...
|
| f14e0c81 | 07-Jul-2026 |
Carlos Llamas <cmllamas@google.com> |
rust_binder: report netlink transactions
The Android Binder driver supports a netlink API that reports transaction *failures* to a userspace daemon. This allows devices to monitor processes with man
rust_binder: report netlink transactions
The Android Binder driver supports a netlink API that reports transaction *failures* to a userspace daemon. This allows devices to monitor processes with many failed transactions so that it can e.g. kill misbehaving apps.
One very important thing that this monitors is when many oneway messages are sent to a frozen process, so there is special handling to ensure this scenario is surfaced over netlink.
Signed-off-by: Carlos Llamas <cmllamas@google.com> Acked-by: Carlos Llamas <cmllamas@google.com> Co-developed-by: Alice Ryhl <aliceryhl@google.com> Signed-off-by: Alice Ryhl <aliceryhl@google.com> Link: https://patch.msgid.link/20260707-binder-netlink-v7-3-42b40e4b1ac8@google.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
show more ...
|
| 5757ed4d | 16-Jul-2026 |
Jahnavi MN <jahnavimn@google.com> |
rust_binder: Implement BINDER_DEBUG_DEAD_TRANSACTION
This adds dynamic debug logs for: - Releasing active transactions during thread stack unwinding. - Discarded transaction error codes when a threa
rust_binder: Implement BINDER_DEBUG_DEAD_TRANSACTION
This adds dynamic debug logs for: - Releasing active transactions during thread stack unwinding. - Discarded transaction error codes when a thread exits. - Undelivered transaction acknowledgments (TRANSACTION_COMPLETE) upon thread exit. - Undelivered process death and freeze notifications when processes exit or die. - Undelivered transactions canceled due to target process death.
We now store the process PID in `ThreadError`, `DeliverCode`, and `FreezeMessage` to ensure the correct PID is logged on cancellation. This is necessary because `cancel()` runs from background `kworkers`, which would otherwise print the wrong PID.
Reviewed-by: Alice Ryhl <aliceryhl@google.com> Reviewed-by: Carlos Llamas <cmllamas@google.com> Signed-off-by: Jahnavi MN <jahnavimn@google.com> Link: https://patch.msgid.link/20260716-rust_binder_debug_mask-v4-7-3d7436c2d2f2@google.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
show more ...
|
| 7ddb9f5d | 16-Jul-2026 |
Jahnavi MN <jahnavimn@google.com> |
rust_binder: Implement BINDER_DEBUG_DEATH_NOTIFICATION
This adds dynamic debug logs for: - Memory allocation (OOM) failures when requesting death notifications - Registration and cancellation life
rust_binder: Implement BINDER_DEBUG_DEATH_NOTIFICATION
This adds dynamic debug logs for: - Memory allocation (OOM) failures when requesting death notifications - Registration and cancellation lifecycle events (BC_REQUEST / BC_CLEAR) - Delivery of death notification events to userspace (BR_DEAD_BINDER)
Reviewed-by: Carlos Llamas <cmllamas@google.com> Reviewed-by: Alice Ryhl <aliceryhl@google.com> Signed-off-by: Jahnavi MN <jahnavimn@google.com> Link: https://patch.msgid.link/20260716-rust_binder_debug_mask-v4-6-3d7436c2d2f2@google.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
show more ...
|
| c61f3ad2 | 16-Jul-2026 |
Jahnavi MN <jahnavimn@google.com> |
rust_binder: Implement BINDER_DEBUG_FAILED_TRANSACTION
This adds dynamic debug logs for: - Failed replies, target process deaths, and error code deliveries. - Detailed transaction failure diagnostic
rust_binder: Implement BINDER_DEBUG_FAILED_TRANSACTION
This adds dynamic debug logs for: - Failed replies, target process deaths, and error code deliveries. - Detailed transaction failure diagnostics (including sender/receiver PIDs, TIDs, transaction IDs, buffer sizes, and error codes).
Reviewed-by: Carlos Llamas <cmllamas@google.com> Reviewed-by: Alice Ryhl <aliceryhl@google.com> Signed-off-by: Jahnavi MN <jahnavimn@google.com> Link: https://patch.msgid.link/20260716-rust_binder_debug_mask-v4-5-3d7436c2d2f2@google.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
show more ...
|
| e49c203b | 16-Jul-2026 |
Jahnavi MN <jahnavimn@google.com> |
rust_binder: Implement BINDER_DEBUG_USER_ERROR for transaction parsing failures
This adds dynamic debug logs in `thread.rs` for: - File descriptor array (FDA) parent offset and parent buffer address
rust_binder: Implement BINDER_DEBUG_USER_ERROR for transaction parsing failures
This adds dynamic debug logs in `thread.rs` for: - File descriptor array (FDA) parent offset and parent buffer address alignment misalignments. - Memory copy, write, and translation failures during transaction serialization (including out-of-bounds pointer fixups). - Incoming transactions or replies that do not match the expected thread calling stack (such as out-of-order replies).
Reviewed-by: Carlos Llamas <cmllamas@google.com> Reviewed-by: Alice Ryhl <aliceryhl@google.com> Signed-off-by: Jahnavi MN <jahnavimn@google.com> Link: https://patch.msgid.link/20260716-rust_binder_debug_mask-v4-4-3d7436c2d2f2@google.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
show more ...
|