Commit d9a02e0
Mike Snitzer
dm crypt: avoid accessing uninitialized tasklet
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: 8e14f61 ("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>1 parent fb294b1 commit d9a02e0
1 file changed
Lines changed: 9 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
72 | 72 | | |
73 | 73 | | |
74 | 74 | | |
75 | | - | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
76 | 78 | | |
77 | 79 | | |
78 | 80 | | |
| |||
1731 | 1733 | | |
1732 | 1734 | | |
1733 | 1735 | | |
| 1736 | + | |
1734 | 1737 | | |
1735 | 1738 | | |
1736 | 1739 | | |
| |||
1777 | 1780 | | |
1778 | 1781 | | |
1779 | 1782 | | |
1780 | | - | |
1781 | | - | |
1782 | | - | |
| 1783 | + | |
| 1784 | + | |
| 1785 | + | |
1783 | 1786 | | |
1784 | 1787 | | |
1785 | 1788 | | |
1786 | | - | |
1787 | | - | |
| 1789 | + | |
1788 | 1790 | | |
1789 | 1791 | | |
1790 | 1792 | | |
| |||
2233 | 2235 | | |
2234 | 2236 | | |
2235 | 2237 | | |
| 2238 | + | |
2236 | 2239 | | |
2237 | 2240 | | |
2238 | 2241 | | |
| |||
0 commit comments