diff options
author | Lars Ellenberg <lars.ellenberg@linbit.com> | 2012-03-08 10:43:45 -0500 |
---|---|---|
committer | Philipp Reisner <philipp.reisner@linbit.com> | 2012-05-09 09:16:39 -0400 |
commit | 001a88687aff26d62f8b61d55c6973618cf0f72f (patch) | |
tree | 2946d27abb7a055fe051e7f7f66646edd36b50f6 /drivers/block/drbd/drbd_main.c | |
parent | b6a370ba0786b5eb09c479bffeffe7baba484ab0 (diff) |
drbd: fix potential data corruption and protocol error
We assumed only bios with bi_idx == 0 would end up
in drbd_make_request().
That is wrong.
At least device mapper, in __clone_and_map(), may submit
clones only covering a partial bio, but sharing
the original bvec, by adjusting bi_idx and relevant
other bio members of the clone.
We used __bio_for_each_segment() in various places,
even though that is documented as
* drivers should not use the __ version unless they _really_ want to
* run through the entire bio and not just pending pieces
Impact: we would send the full bio bvec, even for the clone
with bi_idx > 0, which will cause data corruption on the
peer (because we submit wrong data at the clone offset),
and will cause a DRBD protocol error, disconnect/reconnect
and resync (thus fixing the corruption),
because the next package header would be expected right
in the middle of the sent data, causing DRBD magic mismatch.
Fix: drop the assert, and use bio_for_each_segment()
instead of the __ version.
Conflicts:
drbd/drbd_tracing.c
Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com>
Signed-off-by: Lars Ellenberg <lars.ellenberg@linbit.com>
Diffstat (limited to 'drivers/block/drbd/drbd_main.c')
-rw-r--r-- | drivers/block/drbd/drbd_main.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/drivers/block/drbd/drbd_main.c b/drivers/block/drbd/drbd_main.c index 8ca8925520ad..f6cfc45b862a 100644 --- a/drivers/block/drbd/drbd_main.c +++ b/drivers/block/drbd/drbd_main.c | |||
@@ -2734,7 +2734,7 @@ static int _drbd_send_bio(struct drbd_conf *mdev, struct bio *bio) | |||
2734 | struct bio_vec *bvec; | 2734 | struct bio_vec *bvec; |
2735 | int i; | 2735 | int i; |
2736 | /* hint all but last page with MSG_MORE */ | 2736 | /* hint all but last page with MSG_MORE */ |
2737 | __bio_for_each_segment(bvec, bio, i, 0) { | 2737 | bio_for_each_segment(bvec, bio, i) { |
2738 | if (!_drbd_no_send_page(mdev, bvec->bv_page, | 2738 | if (!_drbd_no_send_page(mdev, bvec->bv_page, |
2739 | bvec->bv_offset, bvec->bv_len, | 2739 | bvec->bv_offset, bvec->bv_len, |
2740 | i == bio->bi_vcnt -1 ? 0 : MSG_MORE)) | 2740 | i == bio->bi_vcnt -1 ? 0 : MSG_MORE)) |
@@ -2748,7 +2748,7 @@ static int _drbd_send_zc_bio(struct drbd_conf *mdev, struct bio *bio) | |||
2748 | struct bio_vec *bvec; | 2748 | struct bio_vec *bvec; |
2749 | int i; | 2749 | int i; |
2750 | /* hint all but last page with MSG_MORE */ | 2750 | /* hint all but last page with MSG_MORE */ |
2751 | __bio_for_each_segment(bvec, bio, i, 0) { | 2751 | bio_for_each_segment(bvec, bio, i) { |
2752 | if (!_drbd_send_page(mdev, bvec->bv_page, | 2752 | if (!_drbd_send_page(mdev, bvec->bv_page, |
2753 | bvec->bv_offset, bvec->bv_len, | 2753 | bvec->bv_offset, bvec->bv_len, |
2754 | i == bio->bi_vcnt -1 ? 0 : MSG_MORE)) | 2754 | i == bio->bi_vcnt -1 ? 0 : MSG_MORE)) |