diff options
author | Chris Mason <clm@fb.com> | 2016-03-21 06:59:09 -0700 |
---|---|---|
committer | Chris Mason <clm@fb.com> | 2016-03-21 07:25:44 -0700 |
commit | 389f239c53420802ad5085e51e88c37e2df5e003 (patch) | |
tree | 211ed431e1fa1dc86fc3bee06df56672a9337ece /fs | |
parent | bb7ab3b92e46da06b580c6f83abe7894dc449cca (diff) | |
download | linux-rpi-389f239c53420802ad5085e51e88c37e2df5e003.tar.gz linux-rpi-389f239c53420802ad5085e51e88c37e2df5e003.tar.bz2 linux-rpi-389f239c53420802ad5085e51e88c37e2df5e003.zip |
btrfs: make sure we stay inside the bvec during __btrfs_lookup_bio_sums
Commit c40a3d38aff4e1c (Btrfs: Compute and look up csums based on
sectorsized blocks) changes around how we walk the bios while looking up
crcs. There's an inner loop that is jumping to the next bvec based on
sectors and before it derefs the next bvec, it needs to make sure we're
still in the bio.
In this case, the outer loop would have decided to stop moving forward
too, and the bvec deref is never actually used for anything. But
CONFIG_DEBUG_PAGEALLOC catches it because we're outside our bio.
Signed-off-by: Chris Mason <clm@fb.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/btrfs/file-item.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/fs/btrfs/file-item.c b/fs/btrfs/file-item.c index 763fd170ff16..b5baf5bdc8e1 100644 --- a/fs/btrfs/file-item.c +++ b/fs/btrfs/file-item.c @@ -292,12 +292,22 @@ found: page_bytes_left -= root->sectorsize; if (!page_bytes_left) { bio_index++; + /* + * make sure we're still inside the + * bio before we update page_bytes_left + */ + if (bio_index >= bio->bi_vcnt) { + WARN_ON_ONCE(count); + goto done; + } bvec++; page_bytes_left = bvec->bv_len; } } } + +done: btrfs_free_path(path); return 0; } |