Commit 2eb94dd
nvme: do not let the user delete a ctrl before a complete initialization
If a userspace application performes a "delete_controller" command
early during the ctrl initialization, the delete operation
may race against the init code and the kernel will crash.
nvme nvme5: Connect command failed: host path error
nvme nvme5: failed to connect queue: 0 ret=880
PF: supervisor write access in kernel mode
PF: error_code(0x0002) - not-present page
blk_mq_quiesce_queue+0x18/0x90
nvme_tcp_delete_ctrl+0x24/0x40 [nvme_tcp]
nvme_do_delete_ctrl+0x7f/0x8b [nvme_core]
nvme_sysfs_delete.cold+0x8/0xd [nvme_core]
kernfs_fop_write_iter+0x124/0x1b0
new_sync_write+0xff/0x190
vfs_write+0x1ef/0x280
Fix the crash by checking the NVME_CTRL_STARTED_ONCE bit;
if it's not set it means that the nvme controller is still
in the process of getting initialized and the kernel
will return an -EBUSY error to userspace.
Set the NVME_CTRL_STARTED_ONCE later in the nvme_start_ctrl()
function, after the controller start operation is completed.
Signed-off-by: Maurizio Lombardi <mlombard@redhat.com>
Reviewed-by: Sagi Grimberg <sagi@grimberg.me>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Keith Busch <kbusch@kernel.org>1 parent 1743e5f commit 2eb94dd
1 file changed
Lines changed: 5 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3574 | 3574 | | |
3575 | 3575 | | |
3576 | 3576 | | |
| 3577 | + | |
| 3578 | + | |
| 3579 | + | |
3577 | 3580 | | |
3578 | 3581 | | |
3579 | 3582 | | |
| |||
5034 | 5037 | | |
5035 | 5038 | | |
5036 | 5039 | | |
5037 | | - | |
| 5040 | + | |
5038 | 5041 | | |
5039 | 5042 | | |
5040 | 5043 | | |
| |||
5045 | 5048 | | |
5046 | 5049 | | |
5047 | 5050 | | |
| 5051 | + | |
5048 | 5052 | | |
5049 | 5053 | | |
5050 | 5054 | | |
| |||
0 commit comments