All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] block: fix "check bi_size overflow before merge"
@ 2019-12-09 19:11 Andreas Gruenbacher
  2019-12-10  2:12 ` Ming Lei
  2019-12-10  5:04 ` Jens Axboe
  0 siblings, 2 replies; 3+ messages in thread
From: Andreas Gruenbacher @ 2019-12-09 19:11 UTC (permalink / raw)
  To: Jens Axboe
  Cc: Linus Torvalds, Junichi Nomura, Christoph Hellwig, Ming Lei,
	Hannes Reinecke, linux-block, linux-kernel, Andreas Gruenbacher,
	stable

This partially reverts commit e3a5d8e386c3fb973fa75f2403622a8f3640ec06.

Commit e3a5d8e386c3 ("check bi_size overflow before merge") adds a bio_full
check to __bio_try_merge_page.  This will cause __bio_try_merge_page to fail
when the last bi_io_vec has been reached.  Instead, what we want here is only
the bi_size overflow check.

Fixes: e3a5d8e386c3 ("block: check bi_size overflow before merge")
Cc: stable@vger.kernel.org # v5.4+
Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
---
 block/bio.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/block/bio.c b/block/bio.c
index 9d54aa37ce6c..a5d75f6bf4c7 100644
--- a/block/bio.c
+++ b/block/bio.c
@@ -754,10 +754,12 @@ bool __bio_try_merge_page(struct bio *bio, struct page *page,
 	if (WARN_ON_ONCE(bio_flagged(bio, BIO_CLONED)))
 		return false;
 
-	if (bio->bi_vcnt > 0 && !bio_full(bio, len)) {
+	if (bio->bi_vcnt > 0) {
 		struct bio_vec *bv = &bio->bi_io_vec[bio->bi_vcnt - 1];
 
 		if (page_is_mergeable(bv, page, len, off, same_page)) {
+			if (bio->bi_iter.bi_size > UINT_MAX - len)
+				return false;
 			bv->bv_len += len;
 			bio->bi_iter.bi_size += len;
 			return true;
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] block: fix "check bi_size overflow before merge"
  2019-12-09 19:11 [PATCH] block: fix "check bi_size overflow before merge" Andreas Gruenbacher
@ 2019-12-10  2:12 ` Ming Lei
  2019-12-10  5:04 ` Jens Axboe
  1 sibling, 0 replies; 3+ messages in thread
From: Ming Lei @ 2019-12-10  2:12 UTC (permalink / raw)
  To: Andreas Gruenbacher
  Cc: Jens Axboe, Linus Torvalds, Junichi Nomura, Christoph Hellwig,
	Hannes Reinecke, linux-block, linux-kernel, stable

On Mon, Dec 09, 2019 at 08:11:14PM +0100, Andreas Gruenbacher wrote:
> This partially reverts commit e3a5d8e386c3fb973fa75f2403622a8f3640ec06.
> 
> Commit e3a5d8e386c3 ("check bi_size overflow before merge") adds a bio_full
> check to __bio_try_merge_page.  This will cause __bio_try_merge_page to fail
> when the last bi_io_vec has been reached.  Instead, what we want here is only
> the bi_size overflow check.
> 
> Fixes: e3a5d8e386c3 ("block: check bi_size overflow before merge")
> Cc: stable@vger.kernel.org # v5.4+
> Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
> ---
>  block/bio.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/block/bio.c b/block/bio.c
> index 9d54aa37ce6c..a5d75f6bf4c7 100644
> --- a/block/bio.c
> +++ b/block/bio.c
> @@ -754,10 +754,12 @@ bool __bio_try_merge_page(struct bio *bio, struct page *page,
>  	if (WARN_ON_ONCE(bio_flagged(bio, BIO_CLONED)))
>  		return false;
>  
> -	if (bio->bi_vcnt > 0 && !bio_full(bio, len)) {
> +	if (bio->bi_vcnt > 0) {
>  		struct bio_vec *bv = &bio->bi_io_vec[bio->bi_vcnt - 1];
>  
>  		if (page_is_mergeable(bv, page, len, off, same_page)) {
> +			if (bio->bi_iter.bi_size > UINT_MAX - len)
> +				return false;
>  			bv->bv_len += len;
>  			bio->bi_iter.bi_size += len;
>  			return true;

page merging doesn't consume new bvec, so this patch is correct:

Reviewed-by: Ming Lei <ming.lei@redhat.com>

Thanks,
Ming


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] block: fix "check bi_size overflow before merge"
  2019-12-09 19:11 [PATCH] block: fix "check bi_size overflow before merge" Andreas Gruenbacher
  2019-12-10  2:12 ` Ming Lei
@ 2019-12-10  5:04 ` Jens Axboe
  1 sibling, 0 replies; 3+ messages in thread
From: Jens Axboe @ 2019-12-10  5:04 UTC (permalink / raw)
  To: Andreas Gruenbacher
  Cc: Linus Torvalds, Junichi Nomura, Christoph Hellwig, Ming Lei,
	Hannes Reinecke, linux-block, linux-kernel, stable

On 12/9/19 12:11 PM, Andreas Gruenbacher wrote:
> This partially reverts commit e3a5d8e386c3fb973fa75f2403622a8f3640ec06.
> 
> Commit e3a5d8e386c3 ("check bi_size overflow before merge") adds a bio_full
> check to __bio_try_merge_page.  This will cause __bio_try_merge_page to fail
> when the last bi_io_vec has been reached.  Instead, what we want here is only
> the bi_size overflow check.

Applied, thanks.

-- 
Jens Axboe


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-12-10  5:04 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-12-09 19:11 [PATCH] block: fix "check bi_size overflow before merge" Andreas Gruenbacher
2019-12-10  2:12 ` Ming Lei
2019-12-10  5:04 ` Jens Axboe

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.