Skip to content

Commit

Permalink
staging: erofs: fix unexpected out-of-bound data access
Browse files Browse the repository at this point in the history
Unexpected out-of-bound data will be read in erofs_read_raw_page
after commit 07173c3 ("block: enable multipage bvecs") since
one iovec could have multiple pages.

Let's fix as what Ming's pointed out in the previous email [1].

[1] https://lore.kernel.org/lkml/[email protected]/

Suggested-by: Ming Lei <[email protected]>
Reviewed-by: Chao Yu <[email protected]>
Signed-off-by: Gao Xiang <[email protected]>
Fixes: 07173c3 ("block: enable multipage bvecs")
Signed-off-by: Greg Kroah-Hartman <[email protected]>
  • Loading branch information
Gao Xiang authored and gregkh committed Apr 16, 2019
1 parent 663d294 commit f4e97f5
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/staging/erofs/data.c
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ static inline struct bio *erofs_read_raw_page(struct bio *bio,
*last_block = current_block;

/* shift in advance in case of it followed by too many gaps */
if (unlikely(bio->bi_vcnt >= bio->bi_max_vecs)) {
if (bio->bi_iter.bi_size >= bio->bi_max_vecs * PAGE_SIZE) {
/* err should reassign to 0 after submitting */
err = 0;
goto submit_bio_out;
Expand Down

0 comments on commit f4e97f5

Please sign in to comment.