Re: [PATCH] rust: block: require `Sync` for `Operations::QueueData`
From: Gary Guo
Date: Wed Jun 10 2026 - 06:02:39 EST
On Mon Jun 8, 2026 at 9:24 AM BST, Andreas Hindborg wrote:
> 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")
> Signed-off-by: Andreas Hindborg <a.hindborg@xxxxxxxxxx>
Reviewed-by: Gary Guo <gary@xxxxxxxxxxx>
> ---
> rust/kernel/block/mq/operations.rs | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)