Commit Graph

1464455 Commits

Author SHA1 Message Date
Alvin Sun
0752a2e96e rust: module: move module types into module.rs
Move `Module`, `InPlaceModule`, `ModuleMetadata` and `ThisModule` from
`lib.rs` into a new `rust/kernel/module.rs`. Re-export them from `lib.rs`
to avoid tree-wide changes.

Switch six bus driver registrations from `module.0` to the public
`ThisModule::as_ptr()` accessor, since the field is no longer visible
outside the new `module` submodule.

No functional change.

Assisted-by: opencode:glm-5.2
Suggested-by: Gary Guo <gary@garyguo.net>
Link: https://lore.kernel.org/all/DJFIQPLOVO4T.1K8T0VZM30LDA@garyguo.net/
Reviewed-by: Gary Guo <gary@garyguo.net>
Acked-by: Danilo Krummrich <dakr@kernel.org>
Reviewed-by: Alice Ryhl <aliceryhl@google.com>
Acked-by: Petr Pavlu <petr.pavlu@suse.com>
Signed-off-by: Alvin Sun <alvin.sun@linux.dev>
Link: https://patch.msgid.link/20260811-fix-fops-owner-v10-1-7e71776f9dbe@linux.dev
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
2026-08-12 09:36:26 +02:00
Eliot Courtney
8fe5e5f62b rust: num: add Bounded::shr_exact
Add `shr_exact` in the vein of `try_shrink` which shifts a bounded right
only if it loses no set bits. This is useful for getting a shifted down
integer while simultaneously checking that it's aligned.

Signed-off-by: Eliot Courtney <ecourtney@nvidia.com>
Acked-by: Alexandre Courbot <acourbot@nvidia.com>
Reviewed-by: Danilo Krummrich <dakr@kernel.org>
Link: https://patch.msgid.link/20260810-pramin-split-v2-3-65a00b3c7309@nvidia.com
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
2026-08-11 11:36:39 +02:00
Eliot Courtney
223aa25aee rust: num: reject Bounded::shr overshifts at build time
Make `shr` reject shifts of at least the type's bit width at build
time, instead of panicking or masking the shift amount at runtime.

[ This implies we can break the type invariant, which in turn means
  we can trigger UB via `Deref`, e.g.:

      rust_kernel: panicked at rust/kernel/num/bounded.rs:528:22:
      unsafe precondition(s) violated: hint::unreachable_unchecked must never be reached

    - Miguel ]

Signed-off-by: Eliot Courtney <ecourtney@nvidia.com>
Acked-by: Alexandre Courbot <acourbot@nvidia.com>
Reviewed-by: Gary Guo <gary@garyguo.net>
Reviewed-by: Danilo Krummrich <dakr@kernel.org>
Cc: stable@vger.kernel.org
Fixes: c59a2d14cd ("rust: num: add `shr` and `shl` methods to `Bounded`")
Link: https://patch.msgid.link/20260810-pramin-split-v2-2-65a00b3c7309@nvidia.com
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
2026-08-11 11:36:39 +02:00
Eliot Courtney
119b598467 rust: num: use const_assert! in Bounded
Convert the const-block asserts in bounded.rs to const_assert!,
matching the rest of the file.

Signed-off-by: Eliot Courtney <ecourtney@nvidia.com>
Reviewed-by: Gary Guo <gary@garyguo.net>
Reviewed-by: Danilo Krummrich <dakr@kernel.org>
Suggested-by: Gary Guo <gary@garyguo.net>
Link: https://lore.kernel.org/rust-for-linux/DKIY9YGIPUUE.SZD2DUQM9NGK@garyguo.net/
Link: https://patch.msgid.link/20260810-pramin-split-v2-1-65a00b3c7309@nvidia.com
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
2026-08-11 11:35:25 +02:00
Mukesh Kumar Chaurasiya (IBM)
cdfcaa36ac rust: uapi: replace direct asm-generic/ioctl.h include with linux/ioctl.h
rust/uapi/uapi_helper.h was directly including <uapi/asm-generic/ioctl.h>
instead of the proper <uapi/linux/ioctl.h>.

On powerpc, <uapi/linux/ioctl.h> pulls in <uapi/asm/ioctl.h> first, which
defines _IOC_SIZEBITS, _IOC_DIRBITS, _IOC_NONE, and _IOC_WRITE with the
arch-specific values, before falling through to <asm-generic/ioctl.h>.
By bypassing that chain and including <asm-generic/ioctl.h> directly,
the arch-specific overrides never ran first, so when other headers in
the compilation later brought in the full arch-aware chain, Clang saw
those four macros being defined a second time and emitted:

clang diag: arch/powerpc/include/uapi/asm/ioctl.h:5:9: warning: '_IOC_SIZEBITS' macro redefined [-Wmacro-redefined]
clang diag: arch/powerpc/include/uapi/asm/ioctl.h:6:9: warning: '_IOC_DIRBITS' macro redefined [-Wmacro-redefined]
clang diag: arch/powerpc/include/uapi/asm/ioctl.h:8:9: warning: '_IOC_NONE' macro redefined [-Wmacro-redefined]
clang diag: arch/powerpc/include/uapi/asm/ioctl.h:10:9: warning: '_IOC_WRITE' macro redefined [-Wmacro-redefined]

Fix this by replacing the direct include of <uapi/asm-generic/ioctl.h>
with <uapi/linux/ioctl.h>, which is the correct arch-aware entry point
and already maintains the intended include order.

Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202608050618.9dekfjtF-lkp@intel.com/
Signed-off-by: Mukesh Kumar Chaurasiya (IBM) <mkchauras@gmail.com>
Fixes: 4e17466568 ("rust: uapi: Add UAPI crate")
Link: https://patch.msgid.link/20260811063345.685884-1-mkchauras@gmail.com
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
2026-08-11 11:34:06 +02:00
FUJITA Tomonori
d481d99996 rust: time: add Delta::as_millis_ceil()
Add a ceiling variant, mirroring the existing as_micros_ceil() since
the existing as_millis() truncates towards zero.

Reviewed-by: Gary Guo <gary@garyguo.net>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@gmail.com>
Reviewed-by: Andreas Hindborg <a.hindborg@kernel.org>
Link: https://patch.msgid.link/20260808062839.1159990-4-tomo@flapping.org
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
2026-08-11 11:34:06 +02:00
FUJITA Tomonori
2e0d41002a rust: time: add jiffies time unit for Delta
Add a Jiffy time unit with isize as its representation and provide
Delta<Jiffy>::from_jiffies() and as_jiffies() as the unit-specific
constructor and accessor, mirroring from_nanos()/as_nanos() on the
nanosecond Delta.

Represent the jiffies span as isize: Delta is a signed span (nanoseconds
use i64) and, as a timeout, the value only needs to reach
MAX_JIFFY_OFFSET ((LONG_MAX >> 1) - 1). isize is signed and matches the
kernel's c_long, so it meets both.

Reviewed-by: Gary Guo <gary@garyguo.net>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@gmail.com>
Reviewed-by: Andreas Hindborg <a.hindborg@kernel.org>
Link: https://patch.msgid.link/20260808062839.1159990-3-tomo@flapping.org
[ Added intra-doc links. - Miguel ]
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
2026-08-11 11:34:06 +02:00
FUJITA Tomonori
2e2203d885 rust: time: make Delta generic over its time unit
Delta hardcodes its value as i64 nanoseconds. A later patch adds a
jiffies span, whose natural representation is isize jiffies rather than
i64 nanoseconds, and a separate type per unit would duplicate the
arithmetic and comparison machinery.

Make Delta generic over its time unit so the jiffies span can reuse that
machinery. The nanosecond Delta keeps its current representation and API
via the default unit parameter, so no functional change.

Reviewed-by: Gary Guo <gary@garyguo.net>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@gmail.com>
Reviewed-by: Andreas Hindborg <a.hindborg@kernel.org>
Link: https://patch.msgid.link/20260808062839.1159990-2-tomo@flapping.org
[ Reworded to remove stray word. Added intra-doc links. - Miguel ]
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
2026-08-11 11:34:06 +02:00
FUJITA Tomonori
ec90dfcf05 rust: time: fix as_micros_ceil() rounding near i64::MAX
The ceiling adjustment used saturating_add(NSEC_PER_USEC - 1) before
dividing. Once the nanosecond value gets within NSEC_PER_USEC - 1 of
i64::MAX the addition saturates to i64::MAX, which drops the ceiling
bias and can yield a result one microsecond too small.

Fixes: fae0cdc123 ("rust: time: Introduce Delta type")
Reported-by: Miguel Ojeda <miguel.ojeda.sandonis@gmail.com>
Closes: https://lore.kernel.org/rust-for-linux/CANiq72mtS0ABA2JnT5tpz6J9c_mnxY+vyPvghV_ukngWvN8F2w@mail.gmail.com/
Signed-off-by: FUJITA Tomonori <fujita.tomonori@gmail.com>
Acked-by: Andreas Hindborg <a.hindborg@kernel.org>
Cc: stable@vger.kernel.org
Link: https://patch.msgid.link/20260807130531.1056209-1-tomo@flapping.org
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
2026-08-11 11:34:06 +02:00
Alvin Sun
409d09194c rust: doctest: use vertical import style
Convert `use` imports to vertical layout for better readability and
maintainability.

Signed-off-by: Alvin Sun <alvin.sun@linux.dev>
Acked-by: David Gow <david@davidgow.net>
Link: https://patch.msgid.link/20260521-miscdev-use-format-v3-7-56240ca70d0c@linux.dev
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
2026-08-11 11:34:06 +02:00
Philipp Stanner
d8973c4754 rust: sync: Add abstraction for rcu_barrier()
rcu_barrier() is a frequently used C function which is always safe to be
called.

Add a safe abstraction for rcu_barrier().

Tested-by: Daniel Almeida <daniel.almeida@collabora.com>
Signed-off-by: Philipp Stanner <phasta@kernel.org>
Acked-by: Gary Guo <gary@garyguo.net>
Reviewed-by: Onur Özkan <work@onurozkan.dev>
Acked-by: Danilo Krummrich <dakr@kernel.org>
Link: https://patch.msgid.link/20260805145949.938505-5-phasta@kernel.org
[ Formatted documentation. Sorted tags. - Miguel ]
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
2026-08-10 07:58:37 +02:00
Danilo Krummrich
445ac1c805 rust: types: implement ForeignOwnable for ARef<T>
Implement ForeignOwnable for ARef<T>, making it possible for C code to
own an ARef<T>.

Since ARef represents shared ownership, BorrowedMut is &T rather than
&mut T, matching the semantics of the underlying reference-counted type.

Signed-off-by: Danilo Krummrich <dakr@kernel.org>
Reviewed-by: Alice Ryhl <aliceryhl@google.com>
Tested-by: Daniel Almeida <daniel.almeida@collabora.com>
Signed-off-by: Philipp Stanner <phasta@kernel.org>
Acked-by: Danilo Krummrich <dakr@kernel.org>
Link: https://patch.msgid.link/20260805145949.938505-4-phasta@kernel.org
[ Relaxed `'static` bound and added `#[inline]` as discussed. Added
  the submitter's Signed-off-by tag. - Miguel ]
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
2026-08-10 07:58:27 +02:00
Timur Tabi
b93fb6e76e rust: error: add remaining error codes
Add all of the remaining error codes from include/uapi/asm-generic/errno.h.

Previous updates to error.rs have been piecemeal -- adding single error
codes as needed.  Instead, we can avoid future problems by adding all
the remaining error code in one swoop.

EDEADLOCK and EWOULDBLOCK are intentionally left out: they are just
deprecated compatibility aliases of EDEADLK and EAGAIN, kept around for
non-Linux/POSIX code, and have no use in new kernel code.

Signed-off-by: Timur Tabi <ttabi@nvidia.com>
Reviewed-by: Fiona Behrens <me@kloenk.dev>
Acked-by: Danilo Krummrich <dakr@kernel.org>
Reviewed-by: Gary Guo <gary@garyguo.net>
Reviewed-by: Alexandre Courbot <acourbot@nvidia.com>
Signed-off-by: Philipp Stanner <phasta@kernel.org>
Link: https://patch.msgid.link/20260805145949.938505-3-phasta@kernel.org
[ Formatted comments. Added the submitter's Signed-off-by tag. - Miguel ]
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
2026-08-10 07:57:34 +02:00
FUJITA Tomonori
30a449e04a rust: bug: fix warn_on macro build error on UML
Callers that go through `kernel::prelude` have `CStrExt` in scope, but
code inside the `kernel` crate imports explicitly and may not. Using
`warn_on!` from such a module fails to build on UML, which is the only
configuration where `warn_flags!` needs a C string pointer rather than an
inline asm bug entry:

error[E0599]: no method named `as_char_ptr` found for reference `&ffi::CStr` in the current scope
   --> linux/rust/kernel/bug.rs:83:49
    |
 83 |                 $crate::c_str!(::core::file!()).as_char_ptr(),
    |                                                 ^^^^^^^^^^^
    |
   ::: linux/rust/kernel/time.rs:427:9
    |
427 |         warn_on!(self.nanos < 0);
    |         ------------------------ in this macro invocation
    |
    = help: items from traits can only be used if the trait is in scope
    = note: this error originates in the macro `$crate::warn_flags` which comes from the expansion of the macro `warn_on` (in Nightly builds, run with -Z mac)
help: trait `CStrExt` which provides `as_char_ptr` is implemented but not in scope; perhaps you want to import it
   --> linux/rust/kernel/time.rs:27:1
    |
 27 + use crate::str::CStrExt;

Call the method through its fully qualified path, which resolves
without any import at the expansion site.

Cc: stable@vger.kernel.org
Fixes: dff64b0727 ("rust: Add warn_on macro")
Signed-off-by: FUJITA Tomonori <fujita.tomonori@gmail.com>
Link: https://patch.msgid.link/20260807112427.1039056-1-tomo@flapping.org
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
2026-08-10 07:14:24 +02:00
FUJITA Tomonori
5d9668f393 rust: bug: skip arch-specific asm in testlib builds
Running `make rusttest` with `ARCH=` set to an architecture other than
the host's fails, e.g. `ARCH=arm64` on an x86_64 host:

error: invalid instruction mnemonic 'brk'
  --> rust/kernel/bug.rs:63:17
   |
63 | /                 concat!(
64 | |                     "/* {size} */",
65 | |                     include!(concat!(env!("OBJTREE"), "/rust/kernel/generated_arch_warn_asm.rs")),
66 | |                     include!(concat!(env!("OBJTREE"), "/rust/kernel/generated_arch_reachable_asm.rs")));
   | |_______________________________________________________________________________________________________^
   |
note: instantiated into assembly here
  --> <inline asm>:1:115
   |
 1 |     /* 8 */.pushsection __bug_table,"aw"; .align 2; 14470: .long 14471f - .;.short 2305;.align 2; .popsection; 14471:brk 0x800
   |                                                                                                                      ^^^

The reason is that `rusttest` builds the `kernel` crate as a host
library: it passes the `CONFIG_*` cfgs of the configured architecture,
but not `--target`, so code generation happens for the
host. `warn_flags!` then selects the arch-specific inline asm arm
based on `CONFIG_*`, and the host assembler rejects it.

This does not happen with the current `master` because `warn_on!` has
no user inside the `kernel` crate itself yet, but it will as soon as
one is added.

Reported-by: Miguel Ojeda <ojeda@kernel.org>
Closes: https://lore.kernel.org/all/CANiq72n4=fz=JNKY0Jdm8BnLa=RmHB2B7s0bO47YTJ7hygqBZg@mail.gmail.com/
Signed-off-by: FUJITA Tomonori <fujita.tomonori@gmail.com>
Cc: stable@vger.kernel.org
Fixes: dff64b0727 ("rust: Add warn_on macro")
Link: https://patch.msgid.link/20260808022608.1125174-1-tomo@flapping.org
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
2026-08-10 07:14:24 +02:00
FUJITA Tomonori
e66cfc29e0 rust: bug: prevent dead_code warning from warn_on!'s flags constant
Fix the following dead_code warning on some configurations in an
atomic development branch:

warning: constant `WARN_ON_FLAGS` is never used
   --> linux/rust/kernel/bug.rs:126:19
    |
126 |               const WARN_ON_FLAGS: u32 = $crate:🐛:bugflag_taint($crate::bindings::TAINT_WARN);
    |                     ^^^^^^^^^^^^^
    |
   ::: linux/rust/kernel/sync/srcu.rs:106:12
    |
106 |           if crate::warn_on!(
    |  ____________-
107 | |             // SAFETY: By the type invariants, `self` contains a valid and pinned `struct srcu_struct`
108 | |             // and `srcu_readers_active()` only checks the active reader count.
109 | |             unsafe { bindings::srcu_readers_active(ptr) }
110 | |         ) {
    | |_________- in this macro invocation
    |
    = note: `#[warn(dead_code)]` (part of `#[warn(unused)]`) on by default
    = note: this warning originates in the macro `crate::warn_on` (in Nightly builds, run with -Z macro-backtrace for more info)

The warn_on! macro always defines a WARN_ON_FLAGS constant and hands it
to warn_flags!. On configurations where warn_flags! does not reference
its flags argument (the LOONGARCH/ARM variant, which only calls
WARN_ON(), and the !CONFIG_BUG no-op variant), the constant is left
unused and triggers a dead_code warning.

warn_flags! is the macro that accepts (and here discards) the flags
argument, so make it responsible for the argument it drops.

Also rename `_COND_STR` to `COND_STR` and consume `$file` for consistency.

Fixes: dff64b0727 ("rust: Add warn_on macro")
Signed-off-by: FUJITA Tomonori <fujita.tomonori@gmail.com>
Cc: stable@vger.kernel.org
Link: https://patch.msgid.link/20260801024841.786664-1-tomo@flapping.org
[ Added newlines. - Miguel ]
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
2026-08-10 07:14:03 +02:00
Antoni Boucher
359af52575 rust: bitfield: always inline test conversions
When using the Rust GCC backend (i.e. `rustc_codegen_gcc`), GCC does not
inline enough these `Bounded::from_expr` calls:

    /usr/bin/x86_64-linux-gnu-ld.bfd: rust/kernel.o: in function `<kernel::num::bounded::Bounded<u16, 2> as core::convert::From<kernel::bitfield::tests::Priority>>::from':
    fake.c:(.text.unlikely+0x7be): undefined reference to `rust_build_error'

    /usr/bin/x86_64-linux-gnu-ld.bfd: rust/kernel.o: in function `<kernel::num::bounded::Bounded<u64, 4> as core::convert::From<kernel::bitfield::tests::MemoryType>>::from':
    fake.c:(.text.unlikely+0x90d): undefined reference to `rust_build_error'

Thus, similar to commit bc197e24a3 ("rust: num: bounded: Always inline
fits_within and from_expr"), mark them as `#[inline(always)]`.

[ Reworded to add the error and to follow our usual style and sent on
  behalf of Antoni, who found this during his work to support Rust for
  Linux with the GCC backend, i.e. with `rustc_codegen_gcc`. - Miguel ]

Assisted-by: Claude:claude-opus-4-8
Signed-off-by: Antoni Boucher <bouanto@zoho.com>
Acked-by: Alexandre Courbot <acourbot@nvidia.com>
Reviewed-by: Gary Guo <gary@garyguo.net>
Reviewed-by: Danilo Krummrich <dakr@kernel.org>
Link: https://patch.msgid.link/20260807175012.142083-1-ojeda@kernel.org
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
2026-08-10 06:58:31 +02:00
Kosumi Chan
39a309f432 rust: impl_flags: use bit helper in example
Use bit_u32() instead of open-coding shifts in the impl_flags! example.
This demonstrates the checked bit helper and ensures that bit positions
remain within the underlying u32 type.

Suggested-by: Miguel Ojeda <ojeda@kernel.org>
Link: https://github.com/Rust-for-Linux/linux/issues/1244
Assisted-by: OpenCode:openai/gpt-5.6-sol
Signed-off-by: Kosumi Chan <chankocyo@gmail.com>
Suggested-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Link: https://lore.kernel.org/rust-for-linux/2026071054-hazing-antirust-8e40@gregkh/
Reviewed-by: Alexandre Courbot <acourbot@nvidia.com>
Link: https://patch.msgid.link/20260711082327.3062227-1-chankocyo@gmail.com
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
2026-08-10 06:44:10 +02:00
Harish C S
168b4f9aa5 rust: sync: improve Arc documentation links
The `Arc` documentation has a few mentions that do not follow the
surrounding style: a plain `Arc` without an intra-doc link and a
lower-case "arc".

Use intra-doc links for rustdoc references to `Arc` and spell internal
comments consistently as `Arc`, matching nearby docs.

Suggested-by: Miguel Ojeda <ojeda@kernel.org>
Link: https://github.com/Rust-for-Linux/linux/issues/1240
Signed-off-by: Harish C S <harish.cs.ss24@gmail.com>
Acked-by: Boqun Feng <boqun@kernel.org>
Link: https://patch.msgid.link/20260711145033.39649-1-harish.cs.ss24@gmail.com
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
2026-08-10 06:44:10 +02:00
Miguel Ojeda
ec520816b5 docs: rust: quick-start: remove Ubuntu 25.10
Ubuntu 25.10 is not supported anymore [1].

Thus remove it.

Link: https://ubuntu.com/about/release-cycle [1]
Reviewed-by: Gary Guo <gary@garyguo.net>
Link: https://patch.msgid.link/20260709204926.139252-1-ojeda@kernel.org
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
2026-08-10 06:44:10 +02:00
Miguel Ojeda
5086dffd4b Merge tag 'pin-init-v7.3' of https://github.com/Rust-for-Linux/linux into rust-next
Pull pin-init updates from Gary Guo:
 "User-visible changes:

   - Merge the '__pinned_init' and '__init' methods and make 'Init'
     a marker trait.

   - Introduce public APIs 'raw_init' and 'raw_try_init' to prevent users
     from needing to invoke the internal '__pinned_init'/'__init' methods.

   - Emit errors for duplicate '#[pin]' attributes.

   - Link 'Zeroable::zeroed' and 'pin_init::zeroed' in documentation.

  Other changes:

   - Fix unwind safety issues.

   - Clean up lint 'allow' and 'expect's.

   - Overhaul '#[cfg]' handling to pave the way for tuple structs and
     self-referential structs.

   - Mark many functions as '#[inline]' for better codegen with '-C
     opt-level=s' ('CC_OPTIMIZE_FOR_SIZE')."

* tag 'pin-init-v7.3' of https://github.com/Rust-for-Linux/linux:
  rust: pin-init: add `#[inline]` to small functions
  rust: pin-init: remove `__pinned_init` method for `cfg(kernel)`
  rust: treewide: replace `__pinned_init` with `raw_[try_]init`
  rust: pin-init: add `raw_init` and `raw_try_init` and recommend over `__init`
  rust: pin-init: merge `__pinned_init` and `__init`
  rust: pin-init: examples: use `Wrapper::pin_init` instead of manual reimplementation
  rust: pin-init: mark `pin_init::zeroed` and `Zeroable::zeroed` as `#[inline]`
  rust: pin-init: docs: link `Zeroable::zeroed` and `pin_init::zeroed` in documentation
  rust: pin-init: internal: rework how `#[pin_data]` handles cfg
  rust: pin-init: make `[pin_]chain` unwind safe
  rust: pin-init: make `[pin_]init_array_from_fn` unwind safe
  rust: pin-init: internal: generate brace in macro for init code blocks
  rust: pin-init: internal: remove `allow` and `expect`s that don't fire
  rust: pin-init: remove redundant clippy expects in doc tests
  rust: pin-init: examples: fix incorrect drop
  rust: pin-init: internal: error on duplicate `#[pin]` attribute
2026-08-10 06:43:48 +02:00
Gary Guo
1e26aea035 rust: pin-init: add #[inline] to small functions
Currently `pin-init` crate is missing many inline annotations. They are all
generic so still get inlined in normal builds, but are not inlined in
`-C opt-level=s` build. Mark these functions as `#[inline]` so they are
considered for inlining regardless.

Signed-off-by: Gary Guo <gary@garyguo.net>
2026-08-05 11:36:18 +01:00
Gary Guo
1f7fa1374d rust: pin-init: remove __pinned_init method for cfg(kernel)
Remove `__pinned_init` for kernel configuration, with all users gone.
Still perserve it temporarily as deprecated so other users have time to
move off it.

Link: https://patch.msgid.link/20260729-merge-init-v2-5-26adf47109e7@garyguo.net
Signed-off-by: Gary Guo <gary@garyguo.net>
2026-08-05 11:36:18 +01:00
Gary Guo
ea7da31160 rust: treewide: replace __pinned_init with raw_[try_]init
The `__init` method is not designed to be a public API (existence of "__"
is a hint for this); replace users with `pin_init::raw_[try_]init` which
does the same thing.

There are a few users of `__init` which are replaced as well.

Acked-by: Miguel Ojeda <ojeda@kernel.org>
Acked-by: Danilo Krummrich <dakr@kernel.org>
Link: https://patch.msgid.link/20260729-merge-init-v2-4-26adf47109e7@garyguo.net
Signed-off-by: Gary Guo <gary@garyguo.net>
2026-08-05 11:36:18 +01:00
Gary Guo
d5492db2bf rust: pin-init: add raw_init and raw_try_init and recommend over __init
The `__init` method is not designed to be a public API (existence of "__"
is a hint for this); but currently there is no other API that allows raw
initialization on pointers. Add `raw_init` and `raw_try_init` and recommend
people to use this instead if raw pointer initialization is needed.

Link: https://patch.msgid.link/20260729-merge-init-v2-3-26adf47109e7@garyguo.net
[ Renamed from `ptr_[try_]init` to `raw_[try_]init`. - Gary ]
Reviewed-by: Benno Lossin <lossin@kernel.org>
Signed-off-by: Gary Guo <gary@garyguo.net>
2026-08-05 11:36:16 +01:00
Gary Guo
91665820d9 rust: pin-init: merge __pinned_init and __init
These functions have the same requirements and are also required to execute
the same code. Prevent duplication by merging them to the single function
and document the additional relaxation of `Init::__init` on both the merged
function and the safety requirement of `Init`.

The existing `__pinned_init` function is deprecated and kept for
compatibility for existing users. For `cfg(kernel)`, it is soft-deprecated
for now and will be removed when all users are migrated.

Link: https://patch.msgid.link/20260729-merge-init-v2-2-26adf47109e7@garyguo.net
Signed-off-by: Gary Guo <gary@garyguo.net>
2026-08-03 13:36:42 +01:00
Gary Guo
c998b661b7 rust: pin-init: examples: use Wrapper::pin_init instead of manual reimplementation
`UnsafeCell` gains the method via the extension trait `Wrapper`.

Link: https://patch.msgid.link/20260729-merge-init-v2-1-26adf47109e7@garyguo.net
Signed-off-by: Gary Guo <gary@garyguo.net>
2026-08-03 13:36:34 +01:00
Miguel Ojeda
dc01dfb37b rust: rust_is_available: warn for bindgen < 0.72.1 && libclang >= 22
Starting with LLVM 22, `clang_getTypeDeclaration()` may return a forward
declaration instead of the type definition. This made `bindgen` generate
opaque types [1][2], which in turn made us fail with e.g.

    error[E0609]: no field `__bindgen_anon_1` on type `bindings::kernel_param`
      --> rust/kernel/module_param.rs:78:46
       |
    78 |         let container = unsafe { &*((*param).__bindgen_anon_1.arg.cast::<SetOnce<T>>()) };
       |                                              ^^^^^^^^^^^^^^^^ unknown field
       |
       = note: available field is: `_address`

This was fixed in `bindgen` 0.72.1 [3].

In order to clarify what is going on and avoid confusion [4][5], add
a warning to `rust_is_available.sh` about it when the versions match,
similar to past warnings like the one removed in:

  commit ae64324ad5 ("rust: rust_is_available: remove warning for `bindgen` < 0.69.5 && libclang >= 19.1")

In addition, even if the versions match, check if the issue appears to
not reproduce with the given binaries, to avoid a warning in such a case.

Finally, include tests.

[ Nathan, in parallel, updated the instructions of the LLVM+Rust
  kernel.org toolchains [6] so that `--version` is not passed to
  `cargo` for `bindgen`, and thus the latest `bindgen` is installed
  by default, which should help to avoid some of these situations.

  Thanks!

    - Miguel ]

Cc: stable@vger.kernel.org # Needed in 6.12.y and later (Rust is pinned in older LTSs).
Link: https://github.com/rust-lang/rust-bindgen/issues/3264 [1]
Link: https://github.com/Rust-for-Linux/linux/issues/353 [2] # "Missing fields in nested class with LLVM 22."
Link: https://github.com/rust-lang/rust-bindgen/pull/3278 [3]
Reported-by: Burak Emir <burak.emir@gmail.com>
Link: https://github.com/Rust-for-Linux/linux/issues/1247 [4]
Link: https://lore.kernel.org/rust-for-linux/CABwQupNfMAJOGqRM9ke6tj4f53dCCsBDKU7Vp+zf8mwk7bqt8Q@mail.gmail.com/ [5]
Link: https://mirrors.edge.kernel.org/pub/tools/llvm/rust/ [6]
Tested-by: Burak Emir <burak.emir@gmail.com>
Link: https://patch.msgid.link/20260719120514.159914-1-ojeda@kernel.org
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
2026-08-03 14:08:42 +02:00
Antoni Boucher
fe39a233ea rust: kbuild: disambiguate zerocopy for rusttest
Starting with Rust 1.76.0, `zerocopy` was added as an (indirect)
compiler dependency [1]. In turn, this meant that the `rustc-dev`
component started including a precompiled `zerocopy` crate in the sysroot.

This makes `rusttest` fail because the compiler finds several candidates:

    error[E0464]: multiple candidates for `rmeta` dependency `zerocopy` found
      --> rust/kernel/prelude.rs:64:9
       |
    64 | pub use zerocopy::{
       |         ^^^^^^^^
       |
       = note: candidate #1: .../lib/rustlib/x86_64-unknown-linux-gnu/lib/libzerocopy-dfef4cb07ca752aa.rmeta
       = note: candidate #2: ./rust/test/libzerocopy.rlib

We cannot use `--sysroot=/dev/null` for these, thus point to the dependency
explicitly.

Assisted-by: Claude:claude-opus-4-8
Signed-off-by: Antoni Boucher <bouanto@zoho.com>
Cc: stable@vger.kernel.org
Fixes: 567621523a ("rust: zerocopy: enable support in kbuild")
Link: https://github.com/rust-lang/rust/pull/118546 [1]
Link: https://patch.msgid.link/20260729173803.13459-1-ojeda@kernel.org
[ Investigated when it started happening, reworded to add that and to
  follow our usual style and sent on behalf of Antoni, who found this
  during his work to support Rust for Linux with the GCC backend, i.e.
  with `rustc_codegen_gcc`. - Miguel ]
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
2026-08-03 08:17:16 +02:00
Younes Akhouayri
ec72b466db rust: print: fix broken _printk Rustdoc link
The Rustdoc link for `_printk` points to `include/linux/_printk.h`,
which does not exist. Point it to `include/linux/printk.h`, where
`_printk` is declared.

Fixes: 247b365dc8 ("rust: add `kernel` crate")
Signed-off-by: Younes Akhouayri <git@younes.io>
Link: https://github.com/Rust-for-Linux/linux/issues/1246
Reviewed-by: Onur Özkan <work@onurozkan.dev>
Link: https://patch.msgid.link/20260717-docs-printk-rustdoc-link-v1-1-892074948f75@younes.io
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
2026-08-03 08:03:24 +02:00
Miguel Ojeda
fd045c81ed rust: rust_is_available: support testing with bash as /bin/sh
`command -v` behaves differently on `dash` vs. `bash` when faced with
a file without the execute bit.

Thus, for the non-executable `rustc` and `bindgen` tests, support both
possible outputs that the script currently gives.

This makes the test script clean on distributions like Fedora.

Reviewed-by: Onur Özkan <work@onurozkan.dev>
Link: https://patch.msgid.link/20260719130723.162899-1-ojeda@kernel.org
[ Added custom assertion message as suggested. - Miguel ]
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
2026-08-03 08:03:24 +02:00
Miguel Ojeda
16861ca350 objtool/rust: add one more noreturn Rust function for Rust 1.99.0
Starting with Rust 1.99.0 (expected 2026-10-01), `objtool` may report:

    rust/kernel.o: warning: objtool: _R..._6kernel3str9parse_intaNtNtB2_7private12FromStrRadix14from_str_radix()
    falls through to next function _R..._6kernel3str9parse_intaNtNtB2_7private12FromStrRadix16from_u64_negated()

due to calls to the `noreturn` symbol:

    core::num::from_ascii_bytes_radix_panic

The function was renamed from `from_ascii_radix_panic` [1], which is
already in the list.

Thus add the new one to the list so that `objtool` knows it is actually
`noreturn`.

See commit 56d680dd23 ("objtool/rust: list `noreturn` Rust functions")
for more details.

Cc: stable@vger.kernel.org # Needed in 6.12.y and later (Rust is pinned in older LTSs).
Cc: Josh Poimboeuf <jpoimboe@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: https://github.com/rust-lang/rust/pull/159554 [1]
Tested-by: Alice Ryhl <aliceryhl@google.com>
Link: https://patch.msgid.link/20260728191448.349241-1-ojeda@kernel.org
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
2026-08-03 08:03:23 +02:00
Linus Torvalds
075b74841b Linux 7.2-rc6 v7.2-rc6 2026-08-02 16:24:24 -07:00
Linus Torvalds
f5a7e2ae5f Merge tag 'riscv-for-linus-7.2-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/riscv/linux
Pull RISC-V fixes from Paul Walmsley:

 - Fix swiotlb initialization on systems where DRAM is located above
   4GiB (such as the Tenstorrent Blackhole cards)

 - Fix an out-of-bounds access in the memory hot-remove code that can
   occur on Sv39 and Sv48 systems

 - Avoid oopsing during boot if the SBI component of the unaligned
   access performance checking code loses a race against __init function
   freeing

 - Avoid attempting to install the debug-enabled vDSO when it shouldn't
   be built due to !CONFIG_MMU

 - Avoid some sparse warnings by adding missing __iomem notations in
   get_cycles{,_hi}()

 - Drop an unnecessary runtime warning in the SiFive errata handler

* tag 'riscv-for-linus-7.2-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/riscv/linux:
  riscv: vdso: Only try to install vDSO when present
  riscv: mm: Fix out-of-bounds page-table walk during memory hot-remove
  riscv: drop __init from vec_check_unaligned_access_speed_all_cpus
  riscv: mm: fix SWIOTLB initialization for systems with DRAM above 4GB
  riscv/sifive: remove warning in errata
  riscv: time: Add missing __iomem in get_cycles() and get_cycles_hi()
2026-08-02 12:12:21 -07:00
Linus Torvalds
0e672789d4 Merge tag 's390-7.2-6' of git://git.kernel.org/pub/scm/linux/kernel/git/s390/linux
Pull s390 updates from Vasily Gorbik:

 - Fix PCI MMIO write syscall falsely reporting success for mappings not
   valid for MMIO when MIO is unavailable by returning -EFAULT

 - Fix CPRB parameter buffer overflows in zcrypt CCA AES cipher and ECC
   private key conversion by rejecting oversized key tokens

 - Fix buffer overreads and length underflow in pkey and zcrypt CCA
   token validation by checking length fields against actual buffer
   sizes

 - Fix out of bounds permission bitmap access in zcrypt EP11 admin CPRB
   filtering on custom device nodes by using AP_DOMAINS as the limit

 - Fix speculative permission bitmap reads in zcrypt CCA and EP11 admin
   CPRB handling by sanitizing user controlled domain indexes

 - Fix sensitive key material left in zcrypt CCA clear key import
   buffers by scrubbing CPRB and temporary buffers after use

* tag 's390-7.2-6' of git://git.kernel.org/pub/scm/linux/kernel/git/s390/linux:
  s390/zcrypt: Fix missing mem scrub at clear key import in cca_clr2cipherkey()
  s390/zcrypt: Close speculative mem read possibility
  s390/zcrypt: Fix wrong domain value verification with EP11 CPRBs
  s390/zcrypt: Fix buffer over-read in cca_cipher2protkey
  s390/zcrypt: Validate length for CCA ECC private key requests
  s390/zcrypt: Validate length for CCA AES cipher key requests
  s390/pci: Fix s390_pci_mmio_write syscall error return without MIO
2026-08-02 11:55:49 -07:00
Linus Torvalds
8eae6c90b7 Merge tag 'x86-urgent-2026-08-02' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull misc x86 fixes from Ingo Molnar:

 - Fix the boot-time memcmp() asm implementation's constraints
   and optimization properties (Mauricio Faria de Oliveira)

 - Move the 0xd0...0xd7 AMD Zen5 model range from the Zen6
   range where it mistakenly ended up (Pratik Vishwakarma)

* tag 'x86-urgent-2026-08-02' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
  x86/CPU/AMD: Carve out a Zen5 models range
  x86/boot: Add volatile, clobbers and zero-length test in memcmp()
2026-08-02 11:44:12 -07:00
Linus Torvalds
65bfd707fd Merge tag 'sched-urgent-2026-08-02' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull scheduler fix from Ingo Molnar:

 - Fix wakeups of deferred DL servers to be actually deferred (Gabriele
   Monaco)

* tag 'sched-urgent-2026-08-02' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
  sched/deadline: Use revised wakeup rule only for running dl_server
2026-08-02 11:39:10 -07:00
Linus Torvalds
e1f05cd3fc Merge tag 'perf-urgent-2026-08-02' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull uprobes fix from Ingo Molnar:

 - Fix uretprobes race that can crash the kernel (Breno Leitao)

* tag 'perf-urgent-2026-08-02' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
  uprobes: Fix NULL pointer dereference in hprobe_expire()
2026-08-02 11:32:42 -07:00
Linus Torvalds
bd1dde8775 Merge tag 'vfs-7.2-rc6.fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs
Pull vfs fixes from Christian Brauner:
 "binfmt_misc:

   - Don't let an 'F' entry pin its own instance.

     An entry registered with 'F' opens its interpreter at registration
     time and holds that file until the entry is freed, so an entry
     nobody removes by hand is only closed once the binfmt_misc
     superblock is shut down.

     If the interpreter lives on a mount that keeps that superblock
     alive the two pin each other and the file is never closed. That's
     reachable by pointing the interpreter at the instance itself or by
     using the instance as an overlayfs lower layer, and once the mount
     namespace is gone there's nothing left to unregister through
     either.

   - Restore write access when removing an entry.

     Registering with the MISC_FMT_OPEN_FILE flag opens the interpreter
     via open_exec() which denies write access for as long as the entry
     exists, but removal only did filp_close() and never restored it.
     The inode's i_writecount stayed permanently negative and opening
     the interpreter for writing kept failing with ETXTBSY long after
     the entry was gone.

   - Use exe_file_deny_write_access() for the interpreter clone so both
     sides base their decision on the same mode.

   - Reject a flag character as the field delimiter. create_entry() pads
     the buffer with the delimiter so the field parsers terminate even
     on a truncated string, but check_special_flags() consumes flag
     characters instead of scanning for the delimiter.

     If the delimiter is itself a flag character the padding stops
     acting as a terminator and the scan keeps reading past the end of
     the allocation. Such a registration was always rejected, just only
     after the out of bounds read has already happened.

   - Don't leak the user namespace when the mount fails.

     bm_get_tree() hands its reference to get_tree_keyed() and sget_fc()
     moves it into sb->s_fs_info, but generic_shutdown_super() only
     calls ->put_super() from inside the if (sb->s_root) branch and
     bm_fill_super() can fail before either s_root or s_op is in place.

     Drop the reference in ->kill_sb() instead, which runs
     unconditionally.

  netfs:

   - Clear PG_private_2 on a copy-to-cache append failure.

   - Handle a rolling buffer allocation failure in single-object
     writeback and drop the extra folio reference
     netfs_write_folio_single() took before the append.

   - Release the previously batched readahead folios when
     rolling_buffer_load_from_ra() fails in
     netfs_prepare_read_iterator()

   - Fix the folio_queue ENOMEM in writeback by adding a mempool and
     passing gfp flags into the rolling buffer helpers.

  iomap:

   - Add a separate bio_set for iomap_split_ioend(). It can split bios
     that already come from iomap_ioend_bioset and deadlock once that
     bioset is exhausted.

  afs:

   - Set call->async for an asynchronous afs_fs_fetch_data() the way
     afs_fs_fetch_data64() already does.

   - Subtract subreq->transferred from subreq->len in
     afs_fs_fetch_data() rather than adding it.

   - Fix a UAF when sending a message"

* tag 'vfs-7.2-rc6.fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs:
  iomap: add a separate bio_set for iomap_split_ioend
  binfmt_misc: don't leak the user namespace when the mount fails
  binfmt_misc: reject a flag character as the field delimiter
  binfmt_misc: use exe_file_deny_write_access() for the interpreter clone
  binfmt_misc: restore write access when removing an entry
  binfmt_misc: don't let an 'F' entry pin its own instance
  netfs: Fix folio_queue ENOMEM in writeback by adding a mempool
  netfs: release readahead folios on iterator preparation failure
  netfs: handle single writeback rolling buffer allocation failure
  netfs: clear PG_private_2 on copy-to-cache append failure
  afs: Fix UAF when sending a message
  afs: Fix afs_fs_fetch_data() to subtract transferred from len
  afs: Fix afs_fs_fetch_data() to set call->async
2026-08-02 10:12:21 -07:00
Linus Torvalds
a84c804215 Merge tag 'scsi-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi
Pull SCSI fixes from James Bottomley"
 "No core changes. The largest driver fix is the reversion of threaded
  interrupt handlers in UFS and the next is the resume deadlock fix in
  hisi_sas which extends into libsas"

* tag 'scsi-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi:
  scsi: ufs: core: Initialize hba->rpmbs list in ufshcd
  scsi: mpi3mr: Fix potential deadlock in mpi3mr_fault_uevent_emit
  scsi: target: Clear cmd_cnt when initial counter enrollment fails
  scsi: zfcp: Fix memory leak during adapter release by destroying gid_pn_req
  scsi: ufs: core: Revert "Delegate the interrupt service routine to a threaded IRQ handler"
  scsi: ufs: core: Cancel RTC work in active-active suspend
  scsi: scsi_debug: Fix REPORT ZONES alloc_len underflow OOB write
  scsi: target: iblock: Fix wrong PR ops NULL check for PREEMPT/RELEASE
  scsi: ufs: dt-bindings: Add missing mcq reg for qcom,sa8255p-ufshc
  scsi: libsas: Fix HA resume deadlock and hisi_sas disk-wake race
  scsi: libiscsi_tcp: Bound SCSI Response data segment to the connection buffer
  scsi: libiscsi: Fix stale-data leak into the SCSI sense buffer
2026-08-02 09:32:07 -07:00
Linus Torvalds
49c9f4657b Merge tag 'dmaengine-fix-7.2' of git://git.kernel.org/pub/scm/linux/kernel/git/vkoul/dmaengine
Pull dmaengine fixes from Vinod Koul:

 - switchtec fix for register programming

 - sun6i descriptor reclaim fix

 - Intel idxd fixes for double free in error and setup failure

 - Qualcomm bam dma command element fix

* tag 'dmaengine-fix-7.2' of git://git.kernel.org/pub/scm/linux/kernel/git/vkoul/dmaengine:
  dmaengine: qcom: bam_dma: Fix command element mask field for BAM v1.6.0+
  dmaengine: idxd: fix fdev setup failure cleanup in idxd_cdev_open()
  dmaengine: idxd: fix double free of wq, engine, and group structs
  dmaengine: sun6i-dma: Fix reclaim descriptors while terminating DMA
  dmaengine: switchtec-dma: fix FIELD_GET misuse when programming SE threshold
2026-08-02 09:19:40 -07:00
Linus Torvalds
40814468ee Merge tag 'phy-fixes-7.2' of git://git.kernel.org/pub/scm/linux/kernel/git/phy/linux-phy
Pull phy fixes from Vinod Koul:

 - fixes for zynqmp clock and pm error handling and SERDES scrambler
   register handling

 - Rockchip SSC spread fix

 - Qualcomm musb return call fix

* tag 'phy-fixes-7.2' of git://git.kernel.org/pub/scm/linux/kernel/git/phy/linux-phy:
  phy: zynqmp: keep SERDES scrambler and 8b/10b enabled for USB
  phy: zynqmp: use read-modify-write for SERDES scrambler bypass
  phy: zynqmp: fix L0_TM_DISABLE_SCRAMBLE_ENCODER mask
  phy: zynqmp: fix runtime PM leak on probe allocation failure
  phy: zynqmp: fix clock error handling in xpsgtr_phy_init()
  phy: rockchip: naneng-combphy: Always configure SSC spread direction
  phy: qcom: m31-eusb2: Fix return value of init call
2026-08-02 09:16:32 -07:00
Linus Torvalds
2d2338c93d Merge tag 'i2c-fixes-7.2-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/andi.shyti/linux
Pull i2c fixes from Andi Shyti:
 "A set of fixes across several host controller drivers. The largest
  part addresses three issues in the i.MX driver, while the remaining
  changes fix probe ordering, power management, timeout recovery and
  error handling.

  amd-mp2:
   - unregister callback if adapter registration fails

  designware:
   - defer probe until child GPIO controllers are bound

  imx:
   - mark adapter suspended while hardware is powered down
   - fix stale slave pointer and shared IRQ registration race
   - stop slave timer before clearing slave pointer

  iproc:
   - reset controller if START_BUSY remains set after timeout

  jz4780:
   - cache clock rate to avoid clk_get_rate() deadlock

  qcom-cci:
   - rely on runtime PM helpers for system sleep

  spacemit:
   - request interrupt after clock initialization"

* tag 'i2c-fixes-7.2-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/andi.shyti/linux:
  i2c: qcom-cci: drop custom suspend/resume and rely on runtime PM helpers
  i2c: imx: Cancel hrtimer before clearing slave pointer
  i2c: imx: Fix slave registration race and error handling
  i2c: iproc: reset bus after timeout if START_BUSY is stuck
  i2c: imx: mark I2C adapter when hardware is powered down
  i2c: designware: defer probe if child GpioInt controllers are not bound
  i2c: jz4780: Cache host clock rate at probe to prevent CCF prepare_lock deadlock
  i2c: amd-mp2: Unregister callback on adapter add failure
  i2c: spacemit: request IRQ after controller initialization
2026-08-01 09:02:45 -07:00
Linus Torvalds
02dc699f83 Merge tag 'kbuild-fixes-7.2-1' of git://git.kernel.org/pub/scm/linux/kernel/git/kbuild/linux
Pull Kbuild fixes from Nathan Chancellor:

 - Fix regression with MO= when building out of tree kernel modules due
   to incorrectly overwriting build tree's Makefile

 - Avoid stripping .BTF sections from modules when building debug .rpm
   packages

* tag 'kbuild-fixes-7.2-1' of git://git.kernel.org/pub/scm/linux/kernel/git/kbuild/linux:
  kbuild: rpm-pkg: Preserve BTF sections in kernel modules during debuginfo stripping
  kbuild: Stop modifying $(objtree)/Makefile when building oot-kmods oos
2026-07-31 20:45:28 -07:00
Linus Torvalds
2aa6a5e889 Merge tag 'trace-v7.2-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace
Pull tracing fixes from Steven Rostedt:

 - Reset dropped_count in mmio_reset_data()

   When mmio_reset_data() is called, it does not reset the dropped_count
   so that subsequent runs will have incorrect reporting.

 - Add NULL check for mmio_trace_array in logging functions

   The functions __trace_mmiotrace_rw() and __trace_mmiotrace_map() may
   have the 'tr' variable passed to it as NULL. But they both
   dereference it without checking if it is NULL first.

 - Check return value of __register_event() in trace_module_add_events()

   If __register_event() fails, the __add_event_to_tracers() call after
   it will create a file for it. If the module fails to load and its
   memory is freed, the file will still point to it and it will not be
   removed as the registering of the event did not complete.

   Only call __add_event_to_tracers() if the __register_event() was
   successful.

 - Fix false positive match in regex_match_full()

   The regex full matching uses a strncmp() to test against the match
   string and the value. It should not match if value is a prefix of the
   string to match. Check to make sure the length of the strings match
   before comparing.

 - Fix reader page read offset for remote buffers

   A page swapped in by __rb_get_reader_page_from_remote() retains its
   stale read offset, causing subsequent reads to skip events or read
   past valid data.

 - Fix memory leak of subbuf_ids in rb_allocate_cpu_buffer()

   Remote buffers allocate a subbuf_ids array. If the allocator function
   fails after it is allocated, it does not free it, resulting in a
   memory leak.

* tag 'trace-v7.2-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace:
  ring-buffer: Fix subbuf_ids memory leak in rb_allocate_cpu_buffer() error path
  ring-buffer: Fix reader page read offset for remote buffers
  tracing/filters: Fix false positive match in regex_match_full()
  tracing: Check return value of __register_event() in trace_module_add_events()
  tracing/mmiotrace: Add NULL check for mmio_trace_array in logging functions
  tracing/mmiotrace: Reset dropped_count in mmio_reset_data()
2026-07-31 20:24:11 -07:00
Linus Torvalds
0131b508c0 Merge tag 'ntfs-for-7.2-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/linkinjeon/ntfs
Pull ntfs fixes from Namjae Jeon:

 - Keep RECALL_ON_OPEN in inode flags when reloading them from
   $FILE_NAME

 - Check runlist reallocation sizes for negative values and overflow

 - Drop stale page cache after shrinking non-resident attributes to
   prevent writeback failures and data loss

* tag 'ntfs-for-7.2-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/linkinjeon/ntfs:
  ntfs: drop stale page-cache when shrinking a non-resident attr
  ntfs: harden runlist realloc size calculations
  ntfs: preserve RECALL_ON_OPEN on WSL special-file reparse points
2026-07-31 17:47:48 -07:00
Linus Torvalds
bc29fe1c61 Merge tag 'v7.2-rc5-smb3-server-fixes' of git://git.samba.org/ksmbd
Pull smb server fixes from Steve French:

 - Use memcmp() when comparing fixed-size binary ClientGUIDs, so
   embedded NUL bytes are handled correctly

 - Reject repeated SMB2 NEGOTIATE requests after dialect selection

   This prevents preauth_info leaks, enforces the SMB2 protocol
   requirements, and serializes negotiation state updates.

 - Fix a use-after-free in __close_file_table_ids() by removing the
   volatile file ID from the owning IDR before dropping the IDR
   reference

* tag 'v7.2-rc5-smb3-server-fixes' of git://git.samba.org/ksmbd:
  ksmbd: use memcmp() to compare ClientGUIDs
  ksmbd: reject repeated SMB2 NEGOTIATE requests
  ksmbd: fix use-after-free in __close_file_table_ids()
2026-07-31 17:35:17 -07:00
Linus Torvalds
f30ca2ce7d Merge tag 'ata-7.2-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/libata/linux
Pull ata fixes from Damien Le Moal:

 - Fix PCI resource initialization in the sata_mv driver to keep legacy
   Marvell boards functional (Rosen)

 - Fix ahci_ceva driver initialization error path (Radhey)

 - Fix libata header file to remove a kernel doc compilation warning
   (Randy)

 - Increase the timeout for the STANDBY IMMEDIATE command to avoid
   suspend failures with drives that are slow to respond to this command
   (Matt)

 - Fixes for the handling of timed out commands in the presence of
   deferred non-NCQ commands, to avoid excessive delays in executing the
   error handler (me)

 - Disable link power management for a couple of WD drives that have
   been identified as not functioning properly when power management is
   used (Niklas)

 - Fix the device iteration loop when checking for link power management
   support to correctly handle port multiplier setups (Niklas)

* tag 'ata-7.2-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/libata/linux:
  ata: libata-sata: fix ata_scsi_lpm_supported() iteration
  ata: libata-core: Disable LPM on WD Green 2.5 480GB
  ata: libata-core: Disable LPM on some WD drives
  scsi: libsas: terminate deferred commands on time out
  ata: libata-scsi: schedule deferred atapi command
  ata: libata-scsi: terminate deferred commands on time out
  ata: libata-eh: Increase STANDBY IMMEDIATE timeout
  ata: libata: avoid kernel-doc warnings
  ata: ahci_ceva: fix error paths in ceva_ahci_platform_enable_resources()
  ata: sata_mv: accept 1 or 2 resources in platform probe
2026-07-31 17:05:13 -07:00
Masami Hiramatsu (Google)
260b20d9b7 ring-buffer: Fix subbuf_ids memory leak in rb_allocate_cpu_buffer() error path
In rb_allocate_cpu_buffer(), cpu_buffer->subbuf_ids is allocated using
kcalloc() when buffer->remote is non-NULL. If a subsequent page allocation
fails (e.g., ring_buffer_desc_page() returns NULL or rb_allocate_pages()
fails), execution jumps to fail_free_reader.

While __free(kfree) automatically frees the outer cpu_buffer structure
at scope exit, kfree(cpu_buffer) does not recursively free nested heap
pointers such as cpu_buffer->subbuf_ids, resulting in a memory leak.

Fix this by explicitly freeing cpu_buffer->subbuf_ids in the
fail_free_reader error unwinding path when cpu_buffer->remote is set.

Link: https://patch.msgid.link/178550740672.380917.6067449683620196150.stgit@devnote2
Fixes: 2e67fabd8b ("ring-buffer: Introduce ring-buffer remotes")
Assisted-by: Antigravity:gemini-3.6-flash
Signed-off-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
Reviewed-by: Vincent Donnefort <vdonnefort@google.com>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
2026-07-31 19:48:27 -04:00
Linus Torvalds
f01618fd79 Merge tag 'block-7.2-20260731' of git://git.kernel.org/pub/scm/linux/kernel/git/axboe/linux
Pull block fixes from Jens Axboe:

 - A set of fixes for s390/dasd, via Stefan

 - Fix for a missing stop of the timeout timer, if a disk has never been
   added

 - Clear kernel owned fields on ublk setup by default

* tag 'block-7.2-20260731' of git://git.kernel.org/pub/scm/linux/kernel/git/axboe/linux:
  s390/dasd: Fix undersized format-check buffer
  s390/dasd: Fix potential NULL pointer dereference
  s390/dasd: Fix path verification interrupted by concurrent dasd_sleep_on_immediatly
  block: stop the timeout timer when releasing a never added disk
  ublk: reset kernel-owned dev_info fields in ublk_ctrl_add_dev()
2026-07-31 16:42:34 -07:00