[PATCH 2/4] nvme: fix reset uninitialized controller

Sagi Grimberg sagi at grimberg.me
Tue Jan 3 02:32:44 PST 2023



On 1/3/23 12:03, Taehee Yoo wrote:
> nvme-fabric controllers can be reset by
> /sys/class/nvme/nvme#/reset_controller
> echo 1 > /sys/class/nvme/nvme#/reset_controller
> The above command will call nvme_sysfs_reset().
> 
> This function internally calls ctrl->reset_work synchronously or
> asynchronously.
> At this point, it doesn't sure if the controller will be reset after
> initialization.
> 
> So kernel panic would occur because ctrl->reset_work dereferences
> uninitialized values.

This is strange, the reset_work func is assigned earlier than sysfs...

> 
> In order to avoid this, nvme_sysfs_reset checks
> the NVME_CTRL_STARTED_ONCE flag. This flag indicates the controller is
> initialized fully. So, reset logic can be executed safely.

Same comment, the reset should fully fence the controller
initialization.



More information about the Linux-nvme mailing list