Re: [PATCH] bio: merge_bvec_fn() must be called with the old bi_iter.bi_size value

From: Maurizio Lombardi
Date: Mon Aug 11 2014 - 10:14:10 EST


Hi Jens,

On 07/17/2014 10:49 AM, Maurizio Lombardi wrote:
> The patch "bio: modify __bio_add_page() to accept pages that
> don't start a new segment" updates bio->bi_iter.bi_size before
> calling merge_bvec_fn().
>
> This panics the kernel because merge_bvec_fn() expects bi_size to have
> the old value.
>
> This can be reproduced by trying to create a crypto device with cryptsetup.

Can we give to this patch "bio: modify __bio_add_page() to accept pages that don't start a new segment"
another chance to get in?

Should I squash it with the following fix and resubmit as a single patch or it's not necessary?

>
> Reported-by: Valdis Kletnieks <Valdis.Kletnieks@xxxxxx>
> Signed-off-by: Maurizio Lombardi <mlombard@xxxxxxxxxx>
> ---
> block/bio.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/block/bio.c b/block/bio.c
> index fb12df9..40c5b12 100644
> --- a/block/bio.c
> +++ b/block/bio.c
> @@ -795,7 +795,7 @@ static int __bio_add_page(struct request_queue *q, struct bio *bio, struct page
> struct bvec_merge_data bvm = {
> .bi_bdev = bio->bi_bdev,
> .bi_sector = bio->bi_iter.bi_sector,
> - .bi_size = bio->bi_iter.bi_size,
> + .bi_size = bio->bi_iter.bi_size - len,
> .bi_rw = bio->bi_rw,
> };
>
>

Thanks,
Maurizio Lombardi
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/