From: Greg Kroah-Hartman Date: Thu, 10 Jan 2019 19:29:10 +0000 (+0100) Subject: 4.4-stable patches X-Git-Tag: v4.20.2~41 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=8c1745bbe98dd756afa4934b41b7378b8300286e;p=thirdparty%2Fkernel%2Fstable-queue.git 4.4-stable patches added patches: block-break-discard-submissions-into-the-user-defined-size.patch block-don-t-deal-with-discard-limit-in-blkdev_issue_discard.patch crypto-x86-chacha20-avoid-sleeping-with-preemption-disabled.patch vhost-vsock-fix-uninitialized-vhost_vsock-guest_cid.patch --- diff --git a/queue-4.4/block-break-discard-submissions-into-the-user-defined-size.patch b/queue-4.4/block-break-discard-submissions-into-the-user-defined-size.patch new file mode 100644 index 00000000000..71df55bbb3e --- /dev/null +++ b/queue-4.4/block-break-discard-submissions-into-the-user-defined-size.patch @@ -0,0 +1,40 @@ +From af097f5d199e2aa3ab3ef777f0716e487b8f7b08 Mon Sep 17 00:00:00 2001 +From: Jens Axboe +Date: Tue, 8 May 2018 15:09:41 -0600 +Subject: block: break discard submissions into the user defined size + +From: Jens Axboe + +commit af097f5d199e2aa3ab3ef777f0716e487b8f7b08 upstream. + +Don't build discards bigger than what the user asked for, if the +user decided to limit the size by writing to 'discard_max_bytes'. + +Reviewed-by: Darrick J. Wong +Reviewed-by: Omar Sandoval +Signed-off-by: Jens Axboe +Signed-off-by: Sudip Mukherjee +Signed-off-by: Greg Kroah-Hartman +--- + block/blk-lib.c | 10 ++++++++-- + 1 file changed, 8 insertions(+), 2 deletions(-) + +--- a/block/blk-lib.c ++++ b/block/blk-lib.c +@@ -81,8 +81,14 @@ int blkdev_issue_discard(struct block_de + break; + } + +- /* Make sure bi_size doesn't overflow */ +- req_sects = min_t(sector_t, nr_sects, UINT_MAX >> 9); ++ /* ++ * Issue in chunks of the user defined max discard setting, ++ * ensuring that bi_size doesn't overflow ++ */ ++ req_sects = min_t(sector_t, nr_sects, ++ q->limits.max_discard_sectors); ++ if (req_sects > UINT_MAX >> 9) ++ req_sects = UINT_MAX >> 9; + + /* + * If splitting a request, and the next starting sector would be diff --git a/queue-4.4/block-don-t-deal-with-discard-limit-in-blkdev_issue_discard.patch b/queue-4.4/block-don-t-deal-with-discard-limit-in-blkdev_issue_discard.patch new file mode 100644 index 00000000000..d6c90100a32 --- /dev/null +++ b/queue-4.4/block-don-t-deal-with-discard-limit-in-blkdev_issue_discard.patch @@ -0,0 +1,94 @@ +From 744889b7cbb56a64f957e65ade7cb65fe3f35714 Mon Sep 17 00:00:00 2001 +From: Ming Lei +Date: Fri, 12 Oct 2018 15:53:10 +0800 +Subject: block: don't deal with discard limit in blkdev_issue_discard() + +From: Ming Lei + +commit 744889b7cbb56a64f957e65ade7cb65fe3f35714 upstream. + +blk_queue_split() does respect this limit via bio splitting, so no +need to do that in blkdev_issue_discard(), then we can align to +normal bio submit(bio_add_page() & submit_bio()). + +More importantly, this patch fixes one issue introduced in a22c4d7e34402cc +("block: re-add discard_granularity and alignment checks"), in which +zero discard bio may be generated in case of zero alignment. + +Fixes: a22c4d7e34402ccdf3 ("block: re-add discard_granularity and alignment checks") +Cc: stable@vger.kernel.org +Cc: Ming Lin +Cc: Mike Snitzer +Cc: Christoph Hellwig +Cc: Xiao Ni +Tested-by: Mariusz Dabrowski +Signed-off-by: Ming Lei +Signed-off-by: Jens Axboe +Signed-off-by: Sudip Mukherjee +Signed-off-by: Greg Kroah-Hartman +--- + block/blk-lib.c | 28 ++-------------------------- + 1 file changed, 2 insertions(+), 26 deletions(-) + +--- a/block/blk-lib.c ++++ b/block/blk-lib.c +@@ -43,8 +43,6 @@ int blkdev_issue_discard(struct block_de + DECLARE_COMPLETION_ONSTACK(wait); + struct request_queue *q = bdev_get_queue(bdev); + int type = REQ_WRITE | REQ_DISCARD; +- unsigned int granularity; +- int alignment; + struct bio_batch bb; + struct bio *bio; + int ret = 0; +@@ -56,10 +54,6 @@ int blkdev_issue_discard(struct block_de + if (!blk_queue_discard(q)) + return -EOPNOTSUPP; + +- /* Zero-sector (unknown) and one-sector granularities are the same. */ +- granularity = max(q->limits.discard_granularity >> 9, 1U); +- alignment = (bdev_discard_alignment(bdev) >> 9) % granularity; +- + if (flags & BLKDEV_DISCARD_SECURE) { + if (!blk_queue_secdiscard(q)) + return -EOPNOTSUPP; +@@ -72,8 +66,8 @@ int blkdev_issue_discard(struct block_de + + blk_start_plug(&plug); + while (nr_sects) { +- unsigned int req_sects; +- sector_t end_sect, tmp; ++ unsigned int req_sects = nr_sects; ++ sector_t end_sect; + + bio = bio_alloc(gfp_mask, 1); + if (!bio) { +@@ -81,28 +75,10 @@ int blkdev_issue_discard(struct block_de + break; + } + +- /* +- * Issue in chunks of the user defined max discard setting, +- * ensuring that bi_size doesn't overflow +- */ +- req_sects = min_t(sector_t, nr_sects, +- q->limits.max_discard_sectors); + if (req_sects > UINT_MAX >> 9) + req_sects = UINT_MAX >> 9; + +- /* +- * If splitting a request, and the next starting sector would be +- * misaligned, stop the discard at the previous aligned sector. +- */ + end_sect = sector + req_sects; +- tmp = end_sect; +- if (req_sects < nr_sects && +- sector_div(tmp, granularity) != alignment) { +- end_sect = end_sect - alignment; +- sector_div(end_sect, granularity); +- end_sect = end_sect * granularity + alignment; +- req_sects = end_sect - sector; +- } + + bio->bi_iter.bi_sector = sector; + bio->bi_end_io = bio_batch_end_io; diff --git a/queue-4.4/crypto-x86-chacha20-avoid-sleeping-with-preemption-disabled.patch b/queue-4.4/crypto-x86-chacha20-avoid-sleeping-with-preemption-disabled.patch new file mode 100644 index 00000000000..edc3eb74e8b --- /dev/null +++ b/queue-4.4/crypto-x86-chacha20-avoid-sleeping-with-preemption-disabled.patch @@ -0,0 +1,40 @@ +From ebiggers@kernel.org Thu Jan 10 20:09:51 2019 +From: Eric Biggers +Date: Mon, 7 Jan 2019 15:15:59 -0800 +Subject: crypto: x86/chacha20 - avoid sleeping with preemption disabled +To: stable@vger.kernel.org, Greg Kroah-Hartman +Cc: linux-crypto@vger.kernel.org, Martin Willi , Ard Biesheuvel +Message-ID: <20190107231559.13357-1-ebiggers@kernel.org> + + +From: Eric Biggers + +In chacha20-simd, clear the MAY_SLEEP flag in the blkcipher_desc to +prevent sleeping with preemption disabled, under kernel_fpu_begin(). + +This was fixed upstream incidentally by a large refactoring, +commit 9ae433bc79f9 ("crypto: chacha20 - convert generic and x86 +versions to skcipher"). But syzkaller easily trips over this when +running on older kernels, as it's easily reachable via AF_ALG. +Therefore, this patch makes the minimal fix for older kernels. + +Fixes: c9320b6dcb89 ("crypto: chacha20 - Add a SSSE3 SIMD variant for x86_64") +Cc: linux-crypto@vger.kernel.org +Cc: Martin Willi +Signed-off-by: Eric Biggers +Acked-by: Ard Biesheuvel +Signed-off-by: Greg Kroah-Hartman +--- + arch/x86/crypto/chacha20_glue.c | 1 + + 1 file changed, 1 insertion(+) + +--- a/arch/x86/crypto/chacha20_glue.c ++++ b/arch/x86/crypto/chacha20_glue.c +@@ -77,6 +77,7 @@ static int chacha20_simd(struct blkciphe + + blkcipher_walk_init(&walk, dst, src, nbytes); + err = blkcipher_walk_virt_block(desc, &walk, CHACHA20_BLOCK_SIZE); ++ desc->flags &= ~CRYPTO_TFM_REQ_MAY_SLEEP; + + crypto_chacha20_init(state, crypto_blkcipher_ctx(desc->tfm), walk.iv); + diff --git a/queue-4.4/series b/queue-4.4/series index 550b6da0374..77d5a4c371e 100644 --- a/queue-4.4/series +++ b/queue-4.4/series @@ -67,3 +67,7 @@ mm-devm_memremap_pages-mark-devm_memremap_pages-export_symbol_gpl.patch mm-devm_memremap_pages-kill-mapping-system-ram-support.patch sunrpc-fix-cache_head-leak-due-to-queued-request.patch sunrpc-use-svc_net-in-svcauth_gss_-functions.patch +crypto-x86-chacha20-avoid-sleeping-with-preemption-disabled.patch +block-break-discard-submissions-into-the-user-defined-size.patch +block-don-t-deal-with-discard-limit-in-blkdev_issue_discard.patch +vhost-vsock-fix-uninitialized-vhost_vsock-guest_cid.patch diff --git a/queue-4.4/vhost-vsock-fix-uninitialized-vhost_vsock-guest_cid.patch b/queue-4.4/vhost-vsock-fix-uninitialized-vhost_vsock-guest_cid.patch new file mode 100644 index 00000000000..db5444cf59d --- /dev/null +++ b/queue-4.4/vhost-vsock-fix-uninitialized-vhost_vsock-guest_cid.patch @@ -0,0 +1,34 @@ +From a72b69dc083a931422cc8a5e33841aff7d5312f2 Mon Sep 17 00:00:00 2001 +From: Stefan Hajnoczi +Date: Thu, 9 Nov 2017 13:29:10 +0000 +Subject: vhost/vsock: fix uninitialized vhost_vsock->guest_cid + +From: Stefan Hajnoczi + +commit a72b69dc083a931422cc8a5e33841aff7d5312f2 upstream. + +The vhost_vsock->guest_cid field is uninitialized when /dev/vhost-vsock +is opened until the VHOST_VSOCK_SET_GUEST_CID ioctl is called. + +kvmalloc(..., GFP_KERNEL | __GFP_RETRY_MAYFAIL) does not zero memory. +All other vhost_vsock fields are initialized explicitly so just +initialize this field too. + +Signed-off-by: Stefan Hajnoczi +Signed-off-by: Michael S. Tsirkin +Cc: Daniel Verkamp +Signed-off-by: Greg Kroah-Hartman + +diff --git a/drivers/vhost/vsock.c b/drivers/vhost/vsock.c +index c9de9c41aa97..5a5e981bd8e4 100644 +--- a/drivers/vhost/vsock.c ++++ b/drivers/vhost/vsock.c +@@ -518,6 +518,8 @@ static int vhost_vsock_dev_open(struct inode *inode, struct file *file) + goto out; + } + ++ vsock->guest_cid = 0; /* no CID assigned yet */ ++ + atomic_set(&vsock->queued_replies, 0); + + vqs[VSOCK_VQ_TX] = &vsock->vqs[VSOCK_VQ_TX];