Skip to content

Commit 3ee859e

Browse files
OGAWAHirofumiaxboe
authored andcommitted
block: Fix wrong offset in bio_truncate()
bio_truncate() clears the buffer outside of last block of bdev, however current bio_truncate() is using the wrong offset of page. So it can return the uninitialized data. This happened when both of truncated/corrupted FS and userspace (via bdev) are trying to read the last of bdev. Reported-by: syzbot+ac94ae5f68b84197f41c@syzkaller.appspotmail.com Signed-off-by: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp> Reviewed-by: Ming Lei <ming.lei@redhat.com> Link: https://lore.kernel.org/r/875yqt1c9g.fsf@mail.parknet.co.jp Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent fd9f4e6 commit 3ee859e

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

block/bio.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -569,7 +569,8 @@ static void bio_truncate(struct bio *bio, unsigned new_size)
569569
offset = new_size - done;
570570
else
571571
offset = 0;
572-
zero_user(bv.bv_page, offset, bv.bv_len - offset);
572+
zero_user(bv.bv_page, bv.bv_offset + offset,
573+
bv.bv_len - offset);
573574
truncated = true;
574575
}
575576
done += bv.bv_len;

0 commit comments

Comments
 (0)