Ignat Korchagin
d68b29584c
dm crypt: use GFP_ATOMIC when allocating crypto requests from softirq
...
Commit 39d42fa96ba1 ("dm crypt: add flags to optionally bypass kcryptd
workqueues") made it possible for some code paths in dm-crypt to be
executed in softirq context, when the underlying driver processes IO
requests in interrupt/softirq context.
In this case sometimes when allocating a new crypto request we may get
a stacktrace like below:
[ 210.103008][ C0] BUG: sleeping function called from invalid context at mm/mempool.c:381
[ 210.104746][ C0] in_atomic(): 1, irqs_disabled(): 0, non_block: 0, pid: 2602, name: fio
[ 210.106599][ C0] CPU: 0 PID: 2602 Comm: fio Tainted: G W 5.10.0+ #50
[ 210.108331][ C0] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 0.0.0 02/06/2015
[ 210.110212][ C0] Call Trace:
[ 210.110921][ C0] <IRQ>
[ 210.111527][ C0] dump_stack+0x7d/0xa3
[ 210.112411][ C0] ___might_sleep.cold+0x122/0x151
[ 210.113527][ C0] mempool_alloc+0x16b/0x2f0
[ 210.114524][ C0] ? __queue_work+0x515/0xde0
[ 210.115553][ C0] ? mempool_resize+0x700/0x700
[ 210.116586][ C0] ? crypt_endio+0x91/0x180
[ 210.117479][ C0] ? blk_update_request+0x757/0x1150
[ 210.118513][ C0] ? blk_mq_end_request+0x4b/0x480
[ 210.119572][ C0] ? blk_done_softirq+0x21d/0x340
[ 210.120628][ C0] ? __do_softirq+0x190/0x611
[ 210.121626][ C0] crypt_convert+0x29f9/0x4c00
[ 210.122668][ C0] ? _raw_spin_lock_irqsave+0x87/0xe0
[ 210.123824][ C0] ? kasan_set_track+0x1c/0x30
[ 210.124858][ C0] ? crypt_iv_tcw_ctr+0x4a0/0x4a0
[ 210.125930][ C0] ? kmem_cache_free+0x104/0x470
[ 210.126973][ C0] ? crypt_endio+0x91/0x180
[ 210.127947][ C0] kcryptd_crypt_read_convert+0x30e/0x420
[ 210.129165][ C0] blk_update_request+0x757/0x1150
[ 210.130231][ C0] blk_mq_end_request+0x4b/0x480
[ 210.131294][ C0] blk_done_softirq+0x21d/0x340
[ 210.132332][ C0] ? _raw_spin_lock+0x81/0xd0
[ 210.133289][ C0] ? blk_mq_stop_hw_queue+0x30/0x30
[ 210.134399][ C0] ? _raw_read_lock_irq+0x40/0x40
[ 210.135458][ C0] __do_softirq+0x190/0x611
[ 210.136409][ C0] ? handle_edge_irq+0x221/0xb60
[ 210.137447][ C0] asm_call_irq_on_stack+0x12/0x20
[ 210.138507][ C0] </IRQ>
[ 210.139118][ C0] do_softirq_own_stack+0x37/0x40
[ 210.140191][ C0] irq_exit_rcu+0x110/0x1b0
[ 210.141151][ C0] common_interrupt+0x74/0x120
[ 210.142171][ C0] asm_common_interrupt+0x1e/0x40
Fix this by allocating crypto requests with GFP_ATOMIC mask in
interrupt context.
Fixes: 39d42fa96ba1 ("dm crypt: add flags to optionally bypass kcryptd workqueues")
Cc: stable@vger.kernel.org # v5.9+
Reported-by: Maciej S. Szmigiero <mail@maciej.szmigiero.name>
Signed-off-by: Ignat Korchagin <ignat@cloudflare.com>
Acked-by: Mikulas Patocka <mpatocka@redhat.com>
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
2021-01-04 15:02:33 -05:00
..
2020-12-23 09:25:15 -07:00
2020-09-29 16:33:11 -04:00
2019-11-05 14:53:03 -05:00
2020-01-07 12:07:08 -05:00
2020-03-03 10:02:46 -05:00
2020-07-20 11:17:43 -04:00
2020-09-02 13:38:24 -04:00
2020-12-22 09:54:48 -05:00
2020-03-27 14:42:51 -04:00
2020-03-27 14:42:51 -04:00
2020-07-08 17:20:46 -06:00
2020-12-01 14:53:39 -07:00
2021-01-04 15:02:33 -05:00
2020-07-01 07:27:24 -06:00
2020-07-20 11:17:41 -04:00
2020-12-21 13:59:37 -05:00
2020-07-08 17:20:46 -06:00
2019-05-16 15:55:48 -07:00
2019-11-12 19:12:07 -07:00
2020-08-04 15:51:28 -04:00
2020-11-17 10:45:06 -05:00
2020-07-16 12:35:15 -07:00
2020-12-04 18:04:36 -05:00
2019-08-15 15:57:39 -04:00
2020-09-25 08:20:03 -06:00
2020-05-20 17:09:44 -04:00
2020-09-29 16:33:08 -04:00
2020-05-15 10:29:36 -04:00
2020-12-04 18:04:35 -05:00
2020-12-04 18:04:35 -05:00
2020-12-04 18:04:35 -05:00
2020-12-04 18:04:35 -05:00
2020-12-04 18:04:35 -05:00
2020-07-01 07:27:24 -06:00
2021-01-04 15:02:30 -05:00
2020-12-04 09:42:00 -07:00
2020-09-29 16:33:12 -04:00
2020-07-01 07:27:24 -06:00
2020-05-20 17:09:44 -04:00
2020-12-04 18:04:35 -05:00
2020-12-04 18:04:35 -05:00
2020-12-16 12:57:51 -08:00
2019-04-25 15:38:52 -04:00
2020-09-29 16:33:11 -04:00
2019-12-05 17:05:24 -05:00
2020-07-08 17:20:46 -06:00
2019-05-30 11:26:35 -07:00
2019-05-30 11:26:35 -07:00
2020-12-04 18:04:35 -05:00
2020-04-16 16:16:38 -04:00
2019-05-30 11:26:32 -07:00
2020-12-21 13:57:25 -05:00
2020-12-04 18:04:35 -05:00
2020-08-04 15:48:13 -04:00
2020-07-13 11:47:33 -04:00
2020-12-01 15:43:39 -05:00
2020-12-04 18:04:35 -05:00
2020-07-08 12:21:53 -04:00
2020-07-08 12:21:53 -04:00
2020-08-03 11:57:03 -07:00
2020-06-05 14:59:53 -04:00
2020-12-22 13:27:21 -08:00
2020-09-29 16:33:07 -04:00
2021-01-04 15:02:32 -05:00
2020-12-04 18:04:35 -05:00
2020-08-23 17:36:59 -05:00
2020-10-08 22:37:39 -07:00
2020-12-16 13:09:32 -08:00
2020-07-01 07:27:24 -06:00
2020-12-04 09:42:00 -07:00
2020-05-13 12:02:23 -07:00
2020-07-08 17:20:46 -06:00
2020-12-16 13:09:32 -08:00
2020-12-16 13:09:32 -08:00
2020-12-16 12:57:51 -08:00
2019-09-13 13:10:05 -07:00
2019-06-15 01:37:35 -06:00
2020-12-04 09:42:00 -07:00
2020-05-13 12:02:23 -07:00
2020-08-02 23:03:52 -07:00
2019-03-12 10:15:18 -07:00
2020-07-21 17:18:12 -07:00
2020-12-04 09:42:00 -07:00
2020-09-24 16:44:44 -07:00
2020-12-16 13:09:32 -08:00
2020-12-09 20:46:00 -08:00