Skip to content

Commit

Permalink
Merge tag 'block-6.12-20241026' of git://git.kernel.dk/linux
Browse files Browse the repository at this point in the history
Pull block fixes from Jens Axboe:

 - Pull request for MD via Song fixing a few issues

 - Fix a wrong check in blk_rq_map_user_bvec(), causing IO errors on
   passthrough IO (Xinyu)

* tag 'block-6.12-20241026' of git://git.kernel.dk/linux:
  block: fix sanity checks in blk_rq_map_user_bvec
  md/raid10: fix null ptr dereference in raid10_size()
  md: ensure child flush IO does not affect origin bio->bi_status
  • Loading branch information
torvalds committed Oct 27, 2024
2 parents a8b3be2 + 2ff9494 commit 75f8b2f
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 6 deletions.
4 changes: 1 addition & 3 deletions block/blk-map.c
Original file line number Diff line number Diff line change
Expand Up @@ -600,9 +600,7 @@ static int blk_rq_map_user_bvec(struct request *rq, const struct iov_iter *iter)
if (nsegs >= nr_segs || bytes > UINT_MAX - bv->bv_len)
goto put_bio;
if (bytes + bv->bv_len > nr_iter)
goto put_bio;
if (bv->bv_offset + bv->bv_len > PAGE_SIZE)
goto put_bio;
break;

nsegs++;
bytes += bv->bv_len;
Expand Down
24 changes: 23 additions & 1 deletion drivers/md/md.c
Original file line number Diff line number Diff line change
Expand Up @@ -546,6 +546,26 @@ static int mddev_set_closing_and_sync_blockdev(struct mddev *mddev, int opener_n
return 0;
}

/*
* The only difference from bio_chain_endio() is that the current
* bi_status of bio does not affect the bi_status of parent.
*/
static void md_end_flush(struct bio *bio)
{
struct bio *parent = bio->bi_private;

/*
* If any flush io error before the power failure,
* disk data may be lost.
*/
if (bio->bi_status)
pr_err("md: %pg flush io error %d\n", bio->bi_bdev,
blk_status_to_errno(bio->bi_status));

bio_put(bio);
bio_endio(parent);
}

bool md_flush_request(struct mddev *mddev, struct bio *bio)
{
struct md_rdev *rdev;
Expand All @@ -565,7 +585,9 @@ bool md_flush_request(struct mddev *mddev, struct bio *bio)
new = bio_alloc_bioset(rdev->bdev, 0,
REQ_OP_WRITE | REQ_PREFLUSH, GFP_NOIO,
&mddev->bio_set);
bio_chain(new, bio);
new->bi_private = bio;
new->bi_end_io = md_end_flush;
bio_inc_remaining(bio);
submit_bio(new);
}

Expand Down
7 changes: 5 additions & 2 deletions drivers/md/raid10.c
Original file line number Diff line number Diff line change
Expand Up @@ -4061,9 +4061,12 @@ static int raid10_run(struct mddev *mddev)
}

if (!mddev_is_dm(conf->mddev)) {
ret = raid10_set_queue_limits(mddev);
if (ret)
int err = raid10_set_queue_limits(mddev);

if (err) {
ret = err;
goto out_free_conf;
}
}

/* need to check that every block has at least one working mirror */
Expand Down

0 comments on commit 75f8b2f

Please sign in to comment.