* [PATCH GIT PULL 4/9] rust: block: fix `Send` bound for `GenDisk`
2026-09-29 9:33 [GIT PULL PATCH 0/9] Rust changes for v7.4-rc1 Andreas Hindborg
@ 2026-09-29 9:34 ` Andreas Hindborg
2026-09-29 9:34 ` [PATCH GIT PULL 9/9] rust: block: require `Sync` for `Operations::QueueData` Andreas Hindborg
2026-09-29 11:47 ` [GIT PULL PATCH 0/9] Rust changes for v7.4-rc1 Jens Axboe
2 siblings, 0 replies; 8+ messages in thread
From: Andreas Hindborg @ 2026-09-29 9:34 UTC (permalink / raw)
To: Jens Axboe
Cc: Andreas Hindborg, Boqun Feng, Miguel Ojeda, Gary Guo,
Björn Roy Baron, Benno Lossin, Alice Ryhl, Trevor Gross,
Danilo Krummrich, Daniel Almeida, Tamir Duberstein,
Alexandre Courbot, Onur Özkan, linux-block, rust-for-linux,
linux-kernel, stable,
Priya Bala Govindasamy <pgovind2@uci.edu>, Dylan Zueck <dzueck@uci.edu>, Yuan Tan,
Yuan Tan
The `Send` implementation for `GenDisk<T>` was conditioned on `T: Send`.
This constrains the wrong type. `T` is the `Operations` implementation,
which is typically a zero-sized marker type that carries no data, so `T:
Send` says nothing about whether the data a `GenDisk` actually owns can be
moved to another thread.
A `GenDisk<T>` owns the queue data `T::QueueData` (stored as the
`gendisk`'s `queuedata` and dropped when the `GenDisk` is dropped) and an
`Arc<TagSet<T>>`. These are the values transferred when a `GenDisk` is sent
across a thread boundary, so the `Send` bound must constrain exactly them.
Bound `T::QueueData: Send` and `Arc<TagSet<T>>: Send` instead.
Fixes: 3253aba3408a ("rust: block: introduce `kernel::block::mq` module")
Cc: stable@vger.kernel.org
Reported-by: Priya Bala Govindasamy <pgovind2@uci.edu>, Dylan Zueck <dzueck@uci.edu>, Yuan Tan <ytan089@ucr.edu>
Closes: https://lore.kernel.org/all/cover.1780633578.git.ytan089@ucr.edu
Signed-off-by: Yuan Tan <ytan089@ucr.edu>
Link: https://msgid.link/20260709100100.604252-1-yuantan098@gmail.com
[ Andreas: Fix tags to make checkpatch happy. Change summary line. ]
Signed-off-by: Andreas Hindborg <a.hindborg@kernel.org>
---
rust/kernel/block/mq/gen_disk.rs | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/rust/kernel/block/mq/gen_disk.rs b/rust/kernel/block/mq/gen_disk.rs
index 8ec38a7b9815..080dedb5d5d9 100644
--- a/rust/kernel/block/mq/gen_disk.rs
+++ b/rust/kernel/block/mq/gen_disk.rs
@@ -224,8 +224,14 @@ pub struct GenDisk<T: Operations> {
}
// SAFETY: `GenDisk` is an owned pointer to a `struct gendisk` and an `Arc` to a
-// `TagSet` It is safe to send this to other threads as long as T is Send.
-unsafe impl<T: Operations + Send> Send for GenDisk<T> {}
+// `TagSet`. It is safe to send this to other threads as long as these two are `Send`.
+unsafe impl<T> Send for GenDisk<T>
+where
+ T: Operations,
+ T::QueueData: Send,
+ Arc<TagSet<T>>: Send,
+{
+}
impl<T: Operations> Drop for GenDisk<T> {
fn drop(&mut self) {
--
2.54.0
^ permalink raw reply related [flat|nested] 8+ messages in thread* [PATCH GIT PULL 9/9] rust: block: require `Sync` for `Operations::QueueData`
2026-09-29 9:33 [GIT PULL PATCH 0/9] Rust changes for v7.4-rc1 Andreas Hindborg
2026-09-29 9:34 ` [PATCH GIT PULL 4/9] rust: block: fix `Send` bound for `GenDisk` Andreas Hindborg
@ 2026-09-29 9:34 ` Andreas Hindborg
2026-09-29 11:47 ` [GIT PULL PATCH 0/9] Rust changes for v7.4-rc1 Jens Axboe
2 siblings, 0 replies; 8+ messages in thread
From: Andreas Hindborg @ 2026-09-29 9:34 UTC (permalink / raw)
To: Jens Axboe
Cc: Andreas Hindborg, Boqun Feng, Miguel Ojeda, Gary Guo,
Björn Roy Baron, Benno Lossin, Alice Ryhl, Trevor Gross,
Danilo Krummrich, Daniel Almeida, Tamir Duberstein,
Alexandre Courbot, Onur Özkan, linux-block, rust-for-linux,
linux-kernel, stable
The queue data installed in a `GenDisk` is stored in the request queue and
handed back to the driver as a shared borrow through the `queue_rq` and
`commit_rqs` callbacks. Both callbacks obtain that borrow via
`ForeignOwnable::borrow` and may execute concurrently on several CPUs,
since the block layer runs one hardware queue per CPU. That means a shared
reference to the same queue data can be live on multiple threads at once,
which is only sound when the referent is `Sync`.
The initial `GenDisk` private data support omitted this bound, so a
driver could install a non-`Sync` type as queue data and then access
it concurrently from multiple CPUs without synchronization. Add a
`Sync` bound to the `QueueData` associated type to rule that out.
Fixes: 90d952fac8ac ("rust: block: add `GenDisk` private data support")
Cc: stable@vger.kernel.org
Reviewed-by: Alice Ryhl <aliceryhl@google.com>
Reviewed-by: Gary Guo <gary@garyguo.net>
Link: https://msgid.link/20260608-queue-data-sync-v1-1-0efff051aaf3@kernel.org
Signed-off-by: Andreas Hindborg <a.hindborg@kernel.org>
---
rust/kernel/block/mq/operations.rs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/rust/kernel/block/mq/operations.rs b/rust/kernel/block/mq/operations.rs
index b9ab0e6102a4..08111d8368eb 100644
--- a/rust/kernel/block/mq/operations.rs
+++ b/rust/kernel/block/mq/operations.rs
@@ -36,7 +36,7 @@
pub trait Operations: Sized {
/// Data associated with the `struct request_queue` that is allocated for
/// the `GenDisk` associated with this `Operations` implementation.
- type QueueData: ForeignOwnable;
+ type QueueData: ForeignOwnable + Sync;
/// Called by the kernel to queue a request with the driver. If `is_last` is
/// `false`, the driver is allowed to defer committing the request.
--
2.54.0
^ permalink raw reply related [flat|nested] 8+ messages in thread* Re: [GIT PULL PATCH 0/9] Rust changes for v7.4-rc1
2026-09-29 9:33 [GIT PULL PATCH 0/9] Rust changes for v7.4-rc1 Andreas Hindborg
2026-09-29 9:34 ` [PATCH GIT PULL 4/9] rust: block: fix `Send` bound for `GenDisk` Andreas Hindborg
2026-09-29 9:34 ` [PATCH GIT PULL 9/9] rust: block: require `Sync` for `Operations::QueueData` Andreas Hindborg
@ 2026-09-29 11:47 ` Jens Axboe
2026-09-30 15:06 ` Thorsten Leemhuis
2 siblings, 1 reply; 8+ messages in thread
From: Jens Axboe @ 2026-09-29 11:47 UTC (permalink / raw)
To: Andreas Hindborg
Cc: Boqun Feng, Miguel Ojeda, Gary Guo, Björn Roy Baron,
Benno Lossin, Alice Ryhl, Trevor Gross, Danilo Krummrich,
Daniel Almeida, Tamir Duberstein, Alexandre Courbot,
Onur Özkan, linux-block, rust-for-linux, linux-kernel,
Alvin Sun, stable,
Priya Bala Govindasamy <pgovind2@uci.edu>, Dylan Zueck <dzueck@uci.edu>, Yuan Tan,
Sophon Z, Qingxiao Xu, Malte Wechter
On Tue, 29 Sep 2026 11:33:58 +0200, Andreas Hindborg wrote:
> I have a number of Rust block layer patches I would ask you to pick for
> v7.4. I have collected them into a patch series as well as a pull request
> so you can use whatever is easier.
>
> The changes cover
>
> - Style and formatting changes.
> - Documentation fixes.
> - Fixes for missing trait bounds that can cause API unsoundness.
> - A change to set the owner of the file operations vtable in `GenDisk`.
> - Two bug fixes for the rnull driver.
>
> [...]
Applied, thanks!
[1/9] rust: block: mq: use vertical import style
commit: 020185c5f4a5590267b825dffda05eb5d45dfa5f
[2/9] rust: block: mq: remove redundant imports and format
commit: 06e75dbe894f260651627c35e0f36536c4894536
[3/9] rust: block: rnull: use vertical import style
commit: a463f71c492336f9650bae7d7166b66ee87461e9
[4/9] rust: block: fix `Send` bound for `GenDisk`
commit: e502b667ee70a7fa2a578e7722672ecd4fe0eb81
[5/9] rust: block: gen_disk: set fops.owner from driver module pointer
commit: 67a11f2e076016f054dc4a4a637d9b37530b7908
[6/9] rust: block: Fix GenDiskBuilder block size documentation
commit: c595572d0e49c79fcefe8db8e3e4f4e6e1fab734
[7/9] rnull: fix geometry store check-then-act across lock scopes
commit: 7ac697d4a08f01e7aefdeb1f3e1d6f71b2cdac0d
[8/9] rnull: configfs: add power to configfs features
commit: 0cd698e89375d0dfc257f9ae978420aa7fe5359d
[9/9] rust: block: require `Sync` for `Operations::QueueData`
commit: 67b7a2728e4873e64405c5564fe50f7123012b71
Best regards,
--
Jens Axboe
^ permalink raw reply [flat|nested] 8+ messages in thread* Re: [GIT PULL PATCH 0/9] Rust changes for v7.4-rc1
2026-09-29 11:47 ` [GIT PULL PATCH 0/9] Rust changes for v7.4-rc1 Jens Axboe
@ 2026-09-30 15:06 ` Thorsten Leemhuis
2026-09-30 15:25 ` Miguel Ojeda
2026-09-30 15:31 ` Gary Guo
0 siblings, 2 replies; 8+ messages in thread
From: Thorsten Leemhuis @ 2026-09-30 15:06 UTC (permalink / raw)
To: Jens Axboe, Andreas Hindborg
Cc: Boqun Feng, Miguel Ojeda, Gary Guo, Björn Roy Baron,
Benno Lossin, Alice Ryhl, Trevor Gross, Danilo Krummrich,
Daniel Almeida, Tamir Duberstein, Alexandre Courbot,
Onur Özkan, linux-block, rust-for-linux, linux-kernel,
Alvin Sun, stable, Priya Bala Govindasamy, Dylan Zueck, Yuan Tan,
Sophon Z, Qingxiao Xu, Malte Wechter, Mark Brown,
Linux kernel regressions list, Linux Next Mailing List
On 9/29/26 13:47, Jens Axboe wrote:
> On Tue, 29 Sep 2026 11:33:58 +0200, Andreas Hindborg wrote:
>> I have a number of Rust block layer patches I would ask you to pick for
>> v7.4. I have collected them into a patch series as well as a pull request
>> so you can use whatever is easier.
>>
>> The changes cover
>>
>> - Style and formatting changes.
>> - Documentation fixes.
>> - Fixes for missing trait bounds that can cause API unsoundness.
>> - A change to set the owner of the file operations vtable in `GenDisk`.
>> - Two bug fixes for the rnull driver.
>>
>> [...]
>
> Applied, thanks!
> [...]
This series showed up in next today and broke the build for me on
various Fedora releases for aarch64 and x86_64; reverting this series
fixed that from a quick build test limited to drivers/block/rnull/
The full error msg is quote long, find the top of it below. Full log:
https://download.copr.fedorainfracloud.org/results/@kernel-vanilla/next/fedora-rawhide-aarch64/11055137-next-next-all/builder-live.log.gz
Ciao, Thorsten
"""
> error[E0277]: `UnsafeCell<MaybeUninit<blk_mq_tag_set>>` cannot be shared between threads safely
> --> drivers/block/rnull/configfs.rs:57:18
> |
> 57 | type Child = DeviceConfig;
> | ^^^^^^^^^^^^ `UnsafeCell<MaybeUninit<blk_mq_tag_set>>` cannot be shared between threads safely
> |
> = help: within `TagSet<NullBlkDevice>`, the trait `Sync` is not implemented for `UnsafeCell<MaybeUninit<blk_mq_tag_set>>`
> note: required because it appears within the type `Opaque<blk_mq_tag_set>`
> --> rust/kernel/types.rs:332:12
> |
> 332 | pub struct Opaque<T> {
> | ^^^^^^
> note: required because it appears within the type `TagSet<NullBlkDevice>`
> --> rust/kernel/block/mq/tag_set.rs:32:12
> |
> 32 | pub struct TagSet<T: Operations> {
> | ^^^^^^
> = note: required for `Arc<TagSet<NullBlkDevice>>` to implement `Send`
> = note: 1 redundant requirement hidden
> = note: required for `GenDisk<NullBlkDevice>` to implement `Send`
> note: required because it appears within the type `Option<GenDisk<NullBlkDevice>>`
> --> /usr/lib/rustlib/src/rust/library/core/src/option.rs:598:10
> |
> 598 | pub enum Option<T> {
> | ^^^^^^
> note: required because it appears within the type `DeviceConfigInner`
> --> drivers/block/rnull/configfs.rs:130:8
> |
> 130 | struct DeviceConfigInner {
> | ^^^^^^^^^^^^^^^^^
> = note: required for `Lock<DeviceConfigInner, MutexBackend>` to implement `Send`
> note: required because it appears within the type `DeviceConfig`
> --> drivers/block/rnull/configfs.rs:124:19
> |
> 124 | pub(crate) struct DeviceConfig {
> | ^^^^^^^^^^^^
> note: required by a bound in `kernel::configfs::GroupOperations::Child`
> --> rust/kernel/configfs.rs:518:27
> |
> 518 | type Child: 'static + Send;
> | ^^^^ required by this bound in `GroupOperations::Child`
>
> error[E0277]: `*const blk_mq_ops` cannot be sent between threads safely
> --> drivers/block/rnull/configfs.rs:57:18
> |
> 57 | type Child = DeviceConfig;
> | ^^^^^^^^^^^^ `*const blk_mq_ops` cannot be sent between threads safely
> |
> = help: within `TagSet<NullBlkDevice>`, the trait `Send` is not implemented for `*const blk_mq_ops`
> note: required because it appears within the type `blk_mq_tag_set`
> --> /builddir/build/BUILD/kernel-7.3.0-build/kernel-next-20260930/linux-7.3.0-0.0.next.20260930.545.vanilla.fc46.aarch64/rust/bindings/bindings_generated.rs:105198:12
> |
> 105198 | pub struct blk_mq_tag_set {
> | ^^^^^^^^^^^^^^
> note: required because it appears within the type `MaybeDangling<blk_mq_tag_set>`
> --> /usr/lib/rustlib/src/rust/library/core/src/mem/maybe_dangling.rs:73:12
> |
> 73 | pub struct MaybeDangling<P: ?Sized>(P);
> [...]"""
^ permalink raw reply [flat|nested] 8+ messages in thread* Re: [GIT PULL PATCH 0/9] Rust changes for v7.4-rc1
2026-09-30 15:06 ` Thorsten Leemhuis
@ 2026-09-30 15:25 ` Miguel Ojeda
2026-09-30 15:31 ` Gary Guo
1 sibling, 0 replies; 8+ messages in thread
From: Miguel Ojeda @ 2026-09-30 15:25 UTC (permalink / raw)
To: Thorsten Leemhuis
Cc: Jens Axboe, Andreas Hindborg, Boqun Feng, Miguel Ojeda, Gary Guo,
Björn Roy Baron, Benno Lossin, Alice Ryhl, Trevor Gross,
Danilo Krummrich, Daniel Almeida, Tamir Duberstein,
Alexandre Courbot, Onur Özkan, linux-block, rust-for-linux,
linux-kernel, Alvin Sun, stable, Priya Bala Govindasamy,
Dylan Zueck, Yuan Tan, Sophon Z, Qingxiao Xu, Malte Wechter,
Mark Brown, Linux kernel regressions list,
Linux Next Mailing List
On Wed, Sep 30, 2026 at 5:07 PM Thorsten Leemhuis <linux@leemhuis.info> wrote:
>
> This series showed up in next today and broke the build for me on
> various Fedora releases for aarch64 and x86_64; reverting this series
> fixed that from a quick build test limited to drivers/block/rnull/
>
> The full error msg is quote long, find the top of it below. Full log:
> https://download.copr.fedorainfracloud.org/results/@kernel-vanilla/next/fedora-rawhide-aarch64/11055137-next-next-all/builder-live.log.gz
Confirmed, I see it e.g. in my arm32 build.
Cheers,
Miguel
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [GIT PULL PATCH 0/9] Rust changes for v7.4-rc1
2026-09-30 15:06 ` Thorsten Leemhuis
2026-09-30 15:25 ` Miguel Ojeda
@ 2026-09-30 15:31 ` Gary Guo
2026-09-30 19:49 ` Andreas Hindborg
1 sibling, 1 reply; 8+ messages in thread
From: Gary Guo @ 2026-09-30 15:31 UTC (permalink / raw)
To: Thorsten Leemhuis, Jens Axboe, Andreas Hindborg
Cc: Boqun Feng, Miguel Ojeda, Gary Guo, Björn Roy Baron,
Benno Lossin, Alice Ryhl, Trevor Gross, Danilo Krummrich,
Daniel Almeida, Tamir Duberstein, Alexandre Courbot,
Onur Özkan, linux-block, rust-for-linux, linux-kernel,
Alvin Sun, stable, Priya Bala Govindasamy, Dylan Zueck, Yuan Tan,
Sophon Z, Qingxiao Xu, Malte Wechter, Mark Brown,
Linux kernel regressions list, Linux Next Mailing List
On Wed Sep 30, 2026 at 4:06 PM BST, Thorsten Leemhuis wrote:
> On 9/29/26 13:47, Jens Axboe wrote:
>> On Tue, 29 Sep 2026 11:33:58 +0200, Andreas Hindborg wrote:
>>> I have a number of Rust block layer patches I would ask you to pick for
>>> v7.4. I have collected them into a patch series as well as a pull request
>>> so you can use whatever is easier.
>>>
>>> The changes cover
>>>
>>> - Style and formatting changes.
>>> - Documentation fixes.
>>> - Fixes for missing trait bounds that can cause API unsoundness.
>>> - A change to set the owner of the file operations vtable in `GenDisk`.
>>> - Two bug fixes for the rnull driver.
>>>
>>> [...]
>>
>> Applied, thanks!
>> [...]
>
> This series showed up in next today and broke the build for me on
> various Fedora releases for aarch64 and x86_64; reverting this series
> fixed that from a quick build test limited to drivers/block/rnull/
>
> The full error msg is quote long, find the top of it below. Full log:
> https://download.copr.fedorainfracloud.org/results/@kernel-vanilla/next/fedora-rawhide-aarch64/11055137-next-next-all/builder-live.log.gz
The `Child: Send` bound is introduced in configfs:
https://lore.kernel.org/all/tencent_05937A22D2DA2BAE808EF19E491AA109BC09@qq.com/.
So this is more or less a semantic conflict.
However, the fundamental issue is that TagSet never implements Send/Sync, which
means that "rust: block: fix `Send` bound for `GenDisk`" will unconditionally
strip away the Send implementation, which is problematic.
Something like this should fix the issue:
unsafe impl<T: Operations<QueueData: Send>> Send for TagSet<T> {}
unsafe impl<T: Operations<QueueData: Send>> Sync for TagSet<T> {}
That said, I am not sure why the GenDisk need to carry `Arc<TagSet<T>>: Send`
bound in the first place. Removing it should also fix the issue.
Also, the `QueueData: Send` bound should be part of the `Operations` trait and
not carried around everywhere.
Best,
Gary
^ permalink raw reply [flat|nested] 8+ messages in thread* Re: [GIT PULL PATCH 0/9] Rust changes for v7.4-rc1
2026-09-30 15:31 ` Gary Guo
@ 2026-09-30 19:49 ` Andreas Hindborg
0 siblings, 0 replies; 8+ messages in thread
From: Andreas Hindborg @ 2026-09-30 19:49 UTC (permalink / raw)
To: Gary Guo, Thorsten Leemhuis, Jens Axboe
Cc: Boqun Feng, Miguel Ojeda, Gary Guo, Björn Roy Baron,
Benno Lossin, Alice Ryhl, Trevor Gross, Danilo Krummrich,
Daniel Almeida, Tamir Duberstein, Alexandre Courbot,
Onur Özkan, linux-block, rust-for-linux, linux-kernel,
Alvin Sun, stable, Priya Bala Govindasamy, Dylan Zueck, Yuan Tan,
Sophon Z, Qingxiao Xu, Malte Wechter, Mark Brown,
Linux kernel regressions list, Linux Next Mailing List
"Gary Guo" <gary@garyguo.net> writes:
> On Wed Sep 30, 2026 at 4:06 PM BST, Thorsten Leemhuis wrote:
>> On 9/29/26 13:47, Jens Axboe wrote:
>>> On Tue, 29 Sep 2026 11:33:58 +0200, Andreas Hindborg wrote:
>>>> I have a number of Rust block layer patches I would ask you to pick for
>>>> v7.4. I have collected them into a patch series as well as a pull request
>>>> so you can use whatever is easier.
>>>>
>>>> The changes cover
>>>>
>>>> - Style and formatting changes.
>>>> - Documentation fixes.
>>>> - Fixes for missing trait bounds that can cause API unsoundness.
>>>> - A change to set the owner of the file operations vtable in `GenDisk`.
>>>> - Two bug fixes for the rnull driver.
>>>>
>>>> [...]
>>>
>>> Applied, thanks!
>>> [...]
>>
>> This series showed up in next today and broke the build for me on
>> various Fedora releases for aarch64 and x86_64; reverting this series
>> fixed that from a quick build test limited to drivers/block/rnull/
>>
>> The full error msg is quote long, find the top of it below. Full log:
>> https://download.copr.fedorainfracloud.org/results/@kernel-vanilla/next/fedora-rawhide-aarch64/11055137-next-next-all/builder-live.log.gz
>
> The `Child: Send` bound is introduced in configfs:
> https://lore.kernel.org/all/tencent_05937A22D2DA2BAE808EF19E491AA109BC09@qq.com/.
> So this is more or less a semantic conflict.
I did not consider the interactions of the two trees together. Good
thing we have linux-next.
> However, the fundamental issue is that TagSet never implements Send/Sync, which
> means that "rust: block: fix `Send` bound for `GenDisk`" will unconditionally
> strip away the Send implementation, which is problematic.
>
> Something like this should fix the issue:
>
> unsafe impl<T: Operations<QueueData: Send>> Send for TagSet<T> {}
> unsafe impl<T: Operations<QueueData: Send>> Sync for TagSet<T> {}
>
> That said, I am not sure why the GenDisk need to carry `Arc<TagSet<T>>: Send`
> bound in the first place. Removing it should also fix the issue.
`GenDisk<T>` has a field of type `Arc<TagSet<T>>`, so for `GenDisk` to be
send, so must `Arc<TagSet<T>>`. That `Arc` may be dropped with the
`GenDisk` if it is the last reference.
> Also, the `QueueData: Send` bound should be part of the `Operations` trait and
> not carried around everywhere.
`QueueData` is not involved here. An unconditional implementation is
fine. I submitted a patch here [1], hopefully Jens can pick it soon so
next can be unbroken tomorrow.
Best regards,
Andreas Hindborg
[1] https://lore.kernel.org/r/20260930-tag-set-send-sync-v1-1-51acdb36f4bb@kernel.org
^ permalink raw reply [flat|nested] 8+ messages in thread