dm crypt: avoid accessing uninitialized tasklet
stable inclusion from stable-v5.10.177 commit 0b9493b504fc15c63ec9c7d5b47e669a287837e6 category: bugfix bugzilla: https://gitee.com/openeuler/kernel/issues/I88YNP Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=0b9493b504fc15c63ec9c7d5b47e669a287837e6 -------------------------------- [ Upstream commit d9a02e01 ] When neither "no_read_workqueue" nor "no_write_workqueue" are enabled, tasklet_trylock() in crypt_dec_pending() may still return false due to an uninitialized state, and dm-crypt will unnecessarily do io completion in io_queue workqueue instead of current context. Fix this by adding an 'in_tasklet' flag to dm_crypt_io struct and initialize it to false in crypt_io_init(). Set this flag to true in kcryptd_queue_crypt() before calling tasklet_schedule(). If set crypt_dec_pending() will punt io completion to a workqueue. This also nicely avoids the tasklet_trylock/unlock hack when tasklets aren't in use. Fixes: 8e14f610 ("dm crypt: do not call bio_endio() from the dm-crypt tasklet") Cc: stable@vger.kernel.org Reported-by:Hou Tao <houtao1@huawei.com> Suggested-by:
Ignat Korchagin <ignat@cloudflare.com> Reviewed-by:
Ignat Korchagin <ignat@cloudflare.com> Signed-off-by:
Mike Snitzer <snitzer@kernel.org> Signed-off-by:
Sasha Levin <sashal@kernel.org> Signed-off-by:
sanglipeng <sanglipeng1@jd.com>
Loading
Please sign in to comment