public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] block: fix the bio_vec array index out-of-bounds test
@ 2009-05-08  6:45 Kazuhisa Ichikawa
  2009-05-12 11:27 ` Jens Axboe
  0 siblings, 1 reply; 2+ messages in thread
From: Kazuhisa Ichikawa @ 2009-05-08  6:45 UTC (permalink / raw)
  To: axboe; +Cc: linux-kernel

From: Kazuhisa Ichikawa <ki@epsilou.com>

Current bio_vec array index out-of-bounds test within 
__end_that_request_first() does not seem correct. 
It checks bio->bi_idx against bio->bi_vcnt, but the subsequent code 
uses idx (which is, bio->bi_idx + next_idx) as the array index into 
bio_vec array. This means that the test really make sense only at 
the first iteration of !(nr_bytes >=bio->bi_size) case (when next_idx 
== zero). Fix this by replacing bio->bi_idx with idx.
(This patch applies to 2.6.30-rc4.)

Signed-off-by: Kazuhisa Ichikawa <ki@epsilou.com>
---

--- linux-2.6.30-rc4/block/blk-core.c.ORIG	2009-05-08 00:00:10.000000000 +0900
+++ linux-2.6.30-rc4/block/blk-core.c	2009-05-08 00:00:10.000000000 +0900
@@ -1768,10 +1768,10 @@ static int __end_that_request_first(stru
 		} else {
 			int idx = bio->bi_idx + next_idx;
 
-			if (unlikely(bio->bi_idx >= bio->bi_vcnt)) {
+			if (unlikely(idx >= bio->bi_vcnt)) {
 				blk_dump_rq_flags(req, "__end_that");
 				printk(KERN_ERR "%s: bio idx %d >= vcnt %d\n",
-				       __func__, bio->bi_idx, bio->bi_vcnt);
+				       __func__, idx, bio->bi_vcnt);
 				break;
 			}
 



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

* Re: [PATCH] block: fix the bio_vec array index out-of-bounds test
  2009-05-08  6:45 [PATCH] block: fix the bio_vec array index out-of-bounds test Kazuhisa Ichikawa
@ 2009-05-12 11:27 ` Jens Axboe
  0 siblings, 0 replies; 2+ messages in thread
From: Jens Axboe @ 2009-05-12 11:27 UTC (permalink / raw)
  To: Kazuhisa Ichikawa; +Cc: linux-kernel

On Fri, May 08 2009, Kazuhisa Ichikawa wrote:
> From: Kazuhisa Ichikawa <ki@epsilou.com>
> 
> Current bio_vec array index out-of-bounds test within 
> __end_that_request_first() does not seem correct. 
> It checks bio->bi_idx against bio->bi_vcnt, but the subsequent code 
> uses idx (which is, bio->bi_idx + next_idx) as the array index into 
> bio_vec array. This means that the test really make sense only at 
> the first iteration of !(nr_bytes >=bio->bi_size) case (when next_idx 
> == zero). Fix this by replacing bio->bi_idx with idx.
> (This patch applies to 2.6.30-rc4.)
> 
> Signed-off-by: Kazuhisa Ichikawa <ki@epsilou.com>
> ---
> 
> --- linux-2.6.30-rc4/block/blk-core.c.ORIG	2009-05-08 00:00:10.000000000 +0900
> +++ linux-2.6.30-rc4/block/blk-core.c	2009-05-08 00:00:10.000000000 +0900
> @@ -1768,10 +1768,10 @@ static int __end_that_request_first(stru
>  		} else {
>  			int idx = bio->bi_idx + next_idx;
>  
> -			if (unlikely(bio->bi_idx >= bio->bi_vcnt)) {
> +			if (unlikely(idx >= bio->bi_vcnt)) {
>  				blk_dump_rq_flags(req, "__end_that");
>  				printk(KERN_ERR "%s: bio idx %d >= vcnt %d\n",
> -				       __func__, bio->bi_idx, bio->bi_vcnt);
> +				       __func__, idx, bio->bi_vcnt);
>  				break;
>  			}

Thanks!

-- 
Jens Axboe


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

end of thread, other threads:[~2009-05-12 11:27 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-05-08  6:45 [PATCH] block: fix the bio_vec array index out-of-bounds test Kazuhisa Ichikawa
2009-05-12 11:27 ` Jens Axboe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox