[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <CACMswuMVERF_+R3Qxb0xGHCBQUCuxtBLA+eDo__Coed3BoVC3A@mail.gmail.com>
Date: Thu, 3 Nov 2022 14:12:43 +0800
From: Dennis Dai <dzy.0424thu@...il.com>
To: Miguel Ojeda <ojeda@...nel.org>,
Alex Gaynor <alex.gaynor@...il.com>,
Wedson Almeida Filho <wedsonaf@...gle.com>,
Boqun Feng <boqun.feng@...il.com>, Gary Guo <gary@...yguo.net>,
Björn Roy Baron <bjorn3_gh@...tonmail.com>,
rust-for-linux@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: rust nvme driver: potential sleep-in-atomic-context
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/
Powered by blists - more mailing lists