]> git.baikalelectronics.ru Git - kernel.git/commit
Btrfs: fix segmentation fault when doing dio read
authorLiu Bo <bo.li.liu@oracle.com>
Fri, 7 Apr 2017 20:11:10 +0000 (13:11 -0700)
committerDavid Sterba <dsterba@suse.com>
Tue, 11 Apr 2017 16:49:29 +0000 (18:49 +0200)
commit32a3678ebff83f9577e5e0ba6e4119a92102326b
tree1881d08a5d87094eee395288473860f36d2c14c2
parent7dce7cf578c2581dc87fc020cf734fee39f02317
Btrfs: fix segmentation fault when doing dio read

Commit 0d7f6591c400 ("Btrfs: Direct I/O read: Work on sectorsized blocks")
introduced this bug during iterating bio pages in dio read's endio hook,
and it could end up with segment fault of the dio reading task.

So the reason is 'if (nr_sectors--)', and it makes the code assume that
there is one more block in the same page, so page offset is increased and
the bio which is created to repair the bad block then has an incorrect
bvec.bv_offset, and a later access of the page content would throw a
segmentation fault.

This also adds ASSERT to check page offset against page size.

Signed-off-by: Liu Bo <bo.li.liu@oracle.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/inode.c