From: Yuan Tan The `Send` implementation for `GenDisk` 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` owns the queue data `T::QueueData` (stored as the `gendisk`'s `queuedata` and dropped when the `GenDisk` is dropped) and an `Arc>`. 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>: Send` instead. Fixes: 3253aba3408a ("rust: block: introduce `kernel::block::mq` module") Reported-by: Priya Bala Govindasamy Reported-by: Dylan Zueck Suggested-by: Andreas Hindborg Signed-off-by: Yuan Tan --- Changes in v3: - Add Priya and Dylan's names to the `Reported-by` tags Link to v2: - https://lore.kernel.org/all/20260609-rnull-v6-19-rc5-send-v2-1-82c7404542e2@kernel.org/ Link to v1: - https://lore.kernel.org/all/cover.1780633578.git.ytan089@ucr.edu/ I am a bit unsure how to handle this v3. The change in this v3 is adding the missing trailers. Andreas' v2 already addresses the TagSet issue from my v1, and his commit message is also more appropriate. Therefore this v3 has no changes other than the trailers. I am not sure whether it is appropriate for me to take Andreas' patch and only adjust the trailers. Please correct me, and my apologies if this is not the right way to handle it. 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 912cb805caf5..b36d24382cc3 100644 --- a/rust/kernel/block/mq/gen_disk.rs +++ b/rust/kernel/block/mq/gen_disk.rs @@ -199,8 +199,14 @@ pub struct GenDisk { } // 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 Send for GenDisk {} +// `TagSet`. It is safe to send this to other threads as long as these two are `Send`. +unsafe impl Send for GenDisk +where + T: Operations, + T::QueueData: Send, + Arc>: Send, +{ +} impl Drop for GenDisk { fn drop(&mut self) { -- 2.43.2