]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commit
kernel/module.c: wakeup processes in module_wq on module unload
authorKonstantin Khorenko <khorenko@virtuozzo.com>
Wed, 13 Nov 2019 09:29:50 +0000 (12:29 +0300)
committerMarcelo Henrique Cerri <marcelo.cerri@canonical.com>
Fri, 17 Jan 2020 17:22:54 +0000 (14:22 -0300)
commit2dd64624fbfe0a8d1d84f02bd2b37d7d2ab0527a
tree356cf0625589585c23657e2b7c8931dbe913d65b
parent7c1c06d993021aecfcfccdc2f1620650106a373c
kernel/module.c: wakeup processes in module_wq on module unload

BugLink: https://bugs.launchpad.net/bugs/1857158
[ Upstream commit 5d603311615f612320bb77bd2a82553ef1ced5b7 ]

Fix the race between load and unload a kernel module.

sys_delete_module()
 try_stop_module()
  mod->state = _GOING
add_unformed_module()
 old = find_module_all()
 (old->state == _GOING =>
  wait_event_interruptible())

 During pre-condition
 finished_loading() rets 0
 schedule()
 (never gets waken up later)
 free_module()
  mod->state = _UNFORMED
   list_del_rcu(&mod->list)
   (dels mod from "modules" list)

return

The race above leads to modprobe hanging forever on loading
a module.

Error paths on loading module call wake_up_all(&module_wq) after
freeing module, so let's do the same on straight module unload.

Fixes: 6e6de3dee51a ("kernel/module.c: Only return -EEXIST for modules that have finished loading")
Reviewed-by: Prarit Bhargava <prarit@redhat.com>
Signed-off-by: Konstantin Khorenko <khorenko@virtuozzo.com>
Signed-off-by: Jessica Yu <jeyu@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>
kernel/module.c