summaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorGao Xiang <gaoxiang25@huawei.com>2019-04-12 17:53:14 +0800
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2019-04-16 13:56:20 +0200
commitf4e97f5d4c9ece362b9379d3158cf5e4c02404dc (patch)
tree1db2a14a70ab972819be7a2ddaf2d48067a7e552 /drivers
parent663d294b4768bfd89e529e069bffa544a830b5bf (diff)
downloadlinux-f4e97f5d4c9ece362b9379d3158cf5e4c02404dc.tar.bz2
staging: erofs: fix unexpected out-of-bound data access
Unexpected out-of-bound data will be read in erofs_read_raw_page after commit 07173c3ec276 ("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/20190411080953.GE421@ming.t460p/ Suggested-by: Ming Lei <ming.lei@redhat.com> Reviewed-by: Chao Yu <yuchao0@huawei.com> Signed-off-by: Gao Xiang <gaoxiang25@huawei.com> Fixes: 07173c3ec276 ("block: enable multipage bvecs") Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/staging/erofs/data.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/staging/erofs/data.c b/drivers/staging/erofs/data.c
index 526e0dbea5b5..81af768e7248 100644
--- a/drivers/staging/erofs/data.c
+++ b/drivers/staging/erofs/data.c
@@ -298,7 +298,7 @@ submit_bio_retry:
*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;