Commit 7620e9fe authored by Daniel Wagner's avatar Daniel Wagner Committed by Li Lingfeng
Browse files

nvme-fc: do not wait in vain when unloading module

mainline inclusion
from mainline-v6.8-rc3
commit 70fbfc47a392b98e5f8dba70c6efc6839205c982
category: bugfix
bugzilla: https://gitee.com/src-openeuler/kernel/issues/I9HJSI
CVE: CVE-2024-26846

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=70fbfc47a392b98e5f8dba70c6efc6839205c982



--------------------------------

The module exit path has race between deleting all controllers and
freeing 'left over IDs'. To prevent double free a synchronization
between nvme_delete_ctrl and ida_destroy has been added by the initial
commit.

There is some logic around trying to prevent from hanging forever in
wait_for_completion, though it does not handling all cases. E.g.
blktests is able to reproduce the situation where the module unload
hangs forever.

If we completely rely on the cleanup code executed from the
nvme_delete_ctrl path, all IDs will be freed eventually. This makes
calling ida_destroy unnecessary. We only have to ensure that all
nvme_delete_ctrl code has been executed before we leave
nvme_fc_exit_module. This is done by flushing the nvme_delete_wq
workqueue.

While at it, remove the unused nvme_fc_wq workqueue too.

Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
Reviewed-by: default avatarHannes Reinecke <hare@suse.de>
Signed-off-by: default avatarDaniel Wagner <dwagner@suse.de>
Signed-off-by: default avatarKeith Busch <kbusch@kernel.org>

Conflict:
  drivers/nvme/host/fc.c
[Commit 97faec53("nvme_fc: add 'nvme_discovery' sysfs attribute to fc
transport device") define static fc_class and replace class_destroy with
class_unregister to release fc_class; Commit 3dd83f40("nvme-fc:
replace ida_simple[get|remove] with the simler ida_[alloc|free]") replace
ida_simple_remove with the simler ida_free;]
Signed-off-by: default avatarLi Lingfeng <lilingfeng3@huawei.com>
parent a7cbc15a
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment