Commit 4b6af87d authored by Khazhismel Kumykov's avatar Khazhismel Kumykov Committed by Treehugger Robot
Browse files

BACKPORT: writeback avoid use-after-free after removing device

When a disk is removed, bdi_unregister gets called to stop further
writeback and wait for associated delayed work to complete. However,
wb_inode_writeback_end() may schedule bandwidth estimation dwork after
this has completed, which can result in the timer attempting to access
the just freed bdi_writeback.

Fix this by checking if the bdi_writeback is alive, similar to when
scheduling writeback work.

Since this requires wb-work_lock, and wb_inode_writeback_end() may get
called from interrupt, switch wb-work_lock to an irqsafe lock.

Link: https://lkml.kernel.org/r/20220801155034.3772543-1-khazhy@google.com


Fixes: 45a2966f ("writeback: fix bandwidth estimate for spiky workload")
Signed-off-by: default avatarKhazhismel Kumykov <khazhy@chromium.org>
Reviewed-by: default avatarJan Kara <jack@suse.cz>
Cc: Michael Stapelberg <stapelberg+linux@google.com>
Cc: Wu Fengguang <fengguang.wu@intel.com>
Cc: Alexander Viro <viro@zeniv.linux.org.uk>
Cc: <stable@vger.kernel.org>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Bug: 250784408
Bug: 250441015
(cherry picked from commit f87904c0)
Change-Id: If06401e2dc6c33f267340be2ae699a6c57d3ca0a
Signed-off-by: default avatarChun-Hung Wu <chun-hung.wu@mediatek.com>
parent 75b1bf99
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment