]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/commitdiff
5.10-stable patches
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 27 Jul 2022 14:59:26 +0000 (16:59 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 27 Jul 2022 14:59:26 +0000 (16:59 +0200)
added patches:
block-crypto-fallback-use-a-bio_set-for-splitting-bios.patch
block-fix-memory-leak-of-bvec.patch

queue-5.10/block-crypto-fallback-use-a-bio_set-for-splitting-bios.patch [new file with mode: 0644]
queue-5.10/block-fix-memory-leak-of-bvec.patch [new file with mode: 0644]
queue-5.10/series

diff --git a/queue-5.10/block-crypto-fallback-use-a-bio_set-for-splitting-bios.patch b/queue-5.10/block-crypto-fallback-use-a-bio_set-for-splitting-bios.patch
new file mode 100644 (file)
index 0000000..667ba0f
--- /dev/null
@@ -0,0 +1,69 @@
+From 5407334c53e9922c1c3fb28801e489d0b74f2c8d Mon Sep 17 00:00:00 2001
+From: Christoph Hellwig <hch@lst.de>
+Date: Wed, 24 Feb 2021 08:24:04 +0100
+Subject: block-crypto-fallback: use a bio_set for splitting bios
+
+From: Christoph Hellwig <hch@lst.de>
+
+commit 5407334c53e9922c1c3fb28801e489d0b74f2c8d upstream.
+
+bio_split with a NULL bs argumen used to fall back to kmalloc the
+bio, which does not guarantee forward progress and could to deadlocks.
+Now that the overloading of the NULL bs argument to bio_alloc_bioset
+has been removed it crashes instead.  Fix all that by using a special
+crafted bioset.
+
+Fixes: 3175199ab0ac ("block: split bio_kmalloc from bio_alloc_bioset")
+Reported-by: John Stultz <john.stultz@linaro.org>
+Signed-off-by: Christoph Hellwig <hch@lst.de>
+Tested-by: John Stultz <john.stultz@linaro.org>
+Signed-off-by: Jens Axboe <axboe@kernel.dk>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ block/blk-crypto-fallback.c |   12 ++++++++++--
+ 1 file changed, 10 insertions(+), 2 deletions(-)
+
+--- a/block/blk-crypto-fallback.c
++++ b/block/blk-crypto-fallback.c
+@@ -80,6 +80,7 @@ static struct blk_crypto_keyslot {
+ static struct blk_keyslot_manager blk_crypto_ksm;
+ static struct workqueue_struct *blk_crypto_wq;
+ static mempool_t *blk_crypto_bounce_page_pool;
++static struct bio_set crypto_bio_split;
+ /*
+  * This is the key we set when evicting a keyslot. This *should* be the all 0's
+@@ -222,7 +223,8 @@ static bool blk_crypto_split_bio_if_need
+       if (num_sectors < bio_sectors(bio)) {
+               struct bio *split_bio;
+-              split_bio = bio_split(bio, num_sectors, GFP_NOIO, NULL);
++              split_bio = bio_split(bio, num_sectors, GFP_NOIO,
++                                    &crypto_bio_split);
+               if (!split_bio) {
+                       bio->bi_status = BLK_STS_RESOURCE;
+                       return false;
+@@ -536,9 +538,13 @@ static int blk_crypto_fallback_init(void
+       prandom_bytes(blank_key, BLK_CRYPTO_MAX_KEY_SIZE);
+-      err = blk_ksm_init(&blk_crypto_ksm, blk_crypto_num_keyslots);
++      err = bioset_init(&crypto_bio_split, 64, 0, 0);
+       if (err)
+               goto out;
++
++      err = blk_ksm_init(&blk_crypto_ksm, blk_crypto_num_keyslots);
++      if (err)
++              goto fail_free_bioset;
+       err = -ENOMEM;
+       blk_crypto_ksm.ksm_ll_ops = blk_crypto_ksm_ll_ops;
+@@ -589,6 +595,8 @@ fail_free_wq:
+       destroy_workqueue(blk_crypto_wq);
+ fail_free_ksm:
+       blk_ksm_destroy(&blk_crypto_ksm);
++fail_free_bioset:
++      bioset_exit(&crypto_bio_split);
+ out:
+       return err;
+ }
diff --git a/queue-5.10/block-fix-memory-leak-of-bvec.patch b/queue-5.10/block-fix-memory-leak-of-bvec.patch
new file mode 100644 (file)
index 0000000..90c0b02
--- /dev/null
@@ -0,0 +1,36 @@
+From 8358c28a5d44bf0223a55a2334086c3707bb4185 Mon Sep 17 00:00:00 2001
+From: Ming Lei <ming.lei@redhat.com>
+Date: Tue, 2 Feb 2021 23:54:10 +0800
+Subject: block: fix memory leak of bvec
+
+From: Ming Lei <ming.lei@redhat.com>
+
+commit 8358c28a5d44bf0223a55a2334086c3707bb4185 upstream.
+
+bio_init() clears bio instance, so the bvec index has to be set after
+bio_init(), otherwise bio->bi_io_vec may be leaked.
+
+Fixes: 3175199ab0ac ("block: split bio_kmalloc from bio_alloc_bioset")
+Cc: Johannes Thumshirn <johannes.thumshirn@wdc.com>
+Cc: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
+Cc: Damien Le Moal <damien.lemoal@wdc.com>
+Reviewed-by: Christoph Hellwig <hch@lst.de>
+Signed-off-by: Ming Lei <ming.lei@redhat.com>
+Signed-off-by: Jens Axboe <axboe@kernel.dk>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ block/bio.c |    2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+--- a/block/bio.c
++++ b/block/bio.c
+@@ -491,8 +491,8 @@ struct bio *bio_alloc_bioset(gfp_t gfp_m
+               if (unlikely(!bvl))
+                       goto err_free;
+-              bio->bi_flags |= idx << BVEC_POOL_OFFSET;
+               bio_init(bio, bvl, bvec_nr_vecs(idx));
++              bio->bi_flags |= idx << BVEC_POOL_OFFSET;
+       } else if (nr_iovecs) {
+               bio_init(bio, bio->bi_inline_vecs, BIO_INLINE_VECS);
+       } else {
index 808dc5906f0b3454c7c0dda79a7ed3618a4e856f..87e898cf1bbe727cc7dab9e2d5395b1f24cfe273 100644 (file)
@@ -101,3 +101,5 @@ tty-extract-tty_flip_buffer_commit-from-tty_flip_buffer_push.patch
 tty-use-new-tty_insert_flip_string_and_push_buffer-in-pty_write.patch
 net-usb-ax88179_178a-needs-flag_send_zlp.patch
 watch-queue-remove-spurious-double-semicolon.patch
+block-fix-memory-leak-of-bvec.patch
+block-crypto-fallback-use-a-bio_set-for-splitting-bios.patch