]> 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)
commit71a17d61e855f58a295ab135063156d613bb68ed
tree1881d08a5d87094eee395288473860f36d2c14c2
parentbb5992952388fc5761cc135f3ffa19abb60bca89
Btrfs: fix segmentation fault when doing dio read

Commit a5a065ba5d2e ("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