* [PATCH] block: Fix bad range check in bio_sector_offset
@ 2012-08-28 18:03 Martin K. Petersen
2012-08-29 14:07 ` Jeff Moyer
2012-08-29 17:16 ` Jens Axboe
0 siblings, 2 replies; 5+ messages in thread
From: Martin K. Petersen @ 2012-08-28 18:03 UTC (permalink / raw)
To: linux-kernel; +Cc: Jens Axboe
DM would occasionally end up splitting data integrity-enabled requests
incorrectly. The culprit was a bad range check in bio_sector_offset.
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Cc: <stable@vger.kernel.org>
diff --git a/fs/bio.c b/fs/bio.c
index 9bfade8..b9a6744 100644
--- a/fs/bio.c
+++ b/fs/bio.c
@@ -1552,8 +1552,8 @@ sector_t bio_sector_offset(struct bio *bio, unsigned short index,
sector_sz = queue_logical_block_size(bio->bi_bdev->bd_disk->queue);
sectors = 0;
- if (index >= bio->bi_idx)
- index = bio->bi_vcnt - 1;
+ if (index > bio->bi_vcnt)
+ return 0;
__bio_for_each_segment(bv, bio, i, 0) {
if (i == index) {
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] block: Fix bad range check in bio_sector_offset
2012-08-28 18:03 [PATCH] block: Fix bad range check in bio_sector_offset Martin K. Petersen
@ 2012-08-29 14:07 ` Jeff Moyer
2012-08-29 16:19 ` Martin K. Petersen
2012-08-29 17:16 ` Jens Axboe
1 sibling, 1 reply; 5+ messages in thread
From: Jeff Moyer @ 2012-08-29 14:07 UTC (permalink / raw)
To: Martin K. Petersen; +Cc: linux-kernel, Jens Axboe
"Martin K. Petersen" <martin.petersen@oracle.com> writes:
> DM would occasionally end up splitting data integrity-enabled requests
> incorrectly. The culprit was a bad range check in bio_sector_offset.
The patch looks ok to me, but what is the user visible behavior when
this happens?
Cheers,
Jeff
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] block: Fix bad range check in bio_sector_offset
2012-08-29 14:07 ` Jeff Moyer
@ 2012-08-29 16:19 ` Martin K. Petersen
2012-08-29 17:48 ` Jeff Moyer
0 siblings, 1 reply; 5+ messages in thread
From: Martin K. Petersen @ 2012-08-29 16:19 UTC (permalink / raw)
To: Jeff Moyer; +Cc: Martin K. Petersen, linux-kernel, Jens Axboe
>>>>> "Jeff" == Jeff Moyer <jmoyer@redhat.com> writes:
>> DM would occasionally end up splitting data integrity-enabled
>> requests incorrectly. The culprit was a bad range check in
>> bio_sector_offset.
Jeff> The patch looks ok to me, but what is the user visible behavior
Jeff> when this happens?
We'd occasionally end up mapping a bad integrity scatterlist and the HBA
would abort the I/O with a protection information error.
--
Martin K. Petersen Oracle Linux Engineering
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] block: Fix bad range check in bio_sector_offset
2012-08-28 18:03 [PATCH] block: Fix bad range check in bio_sector_offset Martin K. Petersen
2012-08-29 14:07 ` Jeff Moyer
@ 2012-08-29 17:16 ` Jens Axboe
1 sibling, 0 replies; 5+ messages in thread
From: Jens Axboe @ 2012-08-29 17:16 UTC (permalink / raw)
To: Martin K. Petersen; +Cc: linux-kernel
On 2012-08-28 11:03, Martin K. Petersen wrote:
>
> DM would occasionally end up splitting data integrity-enabled requests
> incorrectly. The culprit was a bad range check in bio_sector_offset.
>
> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
> Cc: <stable@vger.kernel.org>
>
> diff --git a/fs/bio.c b/fs/bio.c
> index 9bfade8..b9a6744 100644
> --- a/fs/bio.c
> +++ b/fs/bio.c
> @@ -1552,8 +1552,8 @@ sector_t bio_sector_offset(struct bio *bio, unsigned short index,
> sector_sz = queue_logical_block_size(bio->bi_bdev->bd_disk->queue);
> sectors = 0;
>
> - if (index >= bio->bi_idx)
> - index = bio->bi_vcnt - 1;
> + if (index > bio->bi_vcnt)
> + return 0;
>
> __bio_for_each_segment(bv, bio, i, 0) {
> if (i == index) {
Good catch, merged.
--
Jens Axboe
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] block: Fix bad range check in bio_sector_offset
2012-08-29 16:19 ` Martin K. Petersen
@ 2012-08-29 17:48 ` Jeff Moyer
0 siblings, 0 replies; 5+ messages in thread
From: Jeff Moyer @ 2012-08-29 17:48 UTC (permalink / raw)
To: Martin K. Petersen; +Cc: linux-kernel, Jens Axboe
"Martin K. Petersen" <martin.petersen@oracle.com> writes:
>>>>>> "Jeff" == Jeff Moyer <jmoyer@redhat.com> writes:
>
>>> DM would occasionally end up splitting data integrity-enabled
>>> requests incorrectly. The culprit was a bad range check in
>>> bio_sector_offset.
>
> Jeff> The patch looks ok to me, but what is the user visible behavior
> Jeff> when this happens?
>
> We'd occasionally end up mapping a bad integrity scatterlist and the HBA
> would abort the I/O with a protection information error.
Thanks for the explanation, Martin!
Acked-by: Jeff Moyer <jmoyer@redhat.com>
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2012-08-29 17:48 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-08-28 18:03 [PATCH] block: Fix bad range check in bio_sector_offset Martin K. Petersen
2012-08-29 14:07 ` Jeff Moyer
2012-08-29 16:19 ` Martin K. Petersen
2012-08-29 17:48 ` Jeff Moyer
2012-08-29 17:16 ` Jens Axboe
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).