public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* rust nvme driver: potential sleep-in-atomic-context
@ 2022-11-03  6:12 Dennis Dai
  2022-11-03  9:37 ` Miguel Ojeda
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Dennis Dai @ 2022-11-03  6:12 UTC (permalink / raw)
  To: Miguel Ojeda, Alex Gaynor, Wedson Almeida Filho, Boqun Feng,
	Gary Guo, Björn Roy Baron, rust-for-linux, linux-kernel

The rust nvme driver [1] (which is still pending to be merged into
mainline [2]) has a potential sleep-in-atomic-context bug.

The potential buggy code is below

    // drivers/block/nvme.rs:192
    dev.queues.lock().io.try_reserve(nr_io_queues as _)?;
    // drivers/block/nvme.rs:227
    dev.queues.lock().io.try_push(io_queue.clone())?;

The queues field is wrapped in SpinLock, which means that we cannot
sleep (or indirectly call any function that may sleep) when the lock
is held.
However try_reserve function may indirectly call krealloc with a
sleepable flag GFP_KERNEL (that's default behaviour of the global rust
allocator).
The the case is similar for try_push.

I wonder if the bug could be confirmed.


[1] https://github.com/metaspace/rust-linux/commit/d88c3744d6cbdf11767e08bad56cbfb67c4c96d0
[2] https://lore.kernel.org/lkml/202210010816.1317F2C@keescook/

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2022-11-03 10:46 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-11-03  6:12 rust nvme driver: potential sleep-in-atomic-context Dennis Dai
2022-11-03  9:37 ` Miguel Ojeda
2022-11-03  9:38 ` Björn Roy Baron
2022-11-03 10:38   ` Andreas Hindborg
2022-11-03  9:57 ` Andreas Hindborg

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox