linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] staging: erofs: fix unexpected out-of-bound data access
@ 2019-04-12  9:53 Gao Xiang
  2019-04-12 13:51 ` Dan Carpenter
  0 siblings, 1 reply; 3+ messages in thread
From: Gao Xiang @ 2019-04-12  9:53 UTC (permalink / raw)
  To: Chao Yu, Ming Lei, Greg Kroah-Hartman, devel
  Cc: LKML, linux-erofs, Chao Yu, Miao Xie, weidu.du, Fang Wei, Gao Xiang

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>
---
change log v2:
 - fix commit message to link the discussion thread
   as pointed out by Chao;

* It should be fixed from linux-5.1-rc after enabling
  multi-page bvec feature.

Thanks,
Gao Xiang

 drivers/staging/erofs/data.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/erofs/data.c b/drivers/staging/erofs/data.c
index 0714061ba888..c64ec76643d4 100644
--- a/drivers/staging/erofs/data.c
+++ b/drivers/staging/erofs/data.c
@@ -304,7 +304,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;
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] staging: erofs: fix unexpected out-of-bound data access
  2019-04-12  9:53 [PATCH v2] staging: erofs: fix unexpected out-of-bound data access Gao Xiang
@ 2019-04-12 13:51 ` Dan Carpenter
  2019-04-12 14:38   ` Gao Xiang
  0 siblings, 1 reply; 3+ messages in thread
From: Dan Carpenter @ 2019-04-12 13:51 UTC (permalink / raw)
  To: Gao Xiang
  Cc: Chao Yu, Ming Lei, Greg Kroah-Hartman, devel, linux-erofs,
	Chao Yu, LKML, weidu.du, Fang Wei, Miao Xie

On Fri, Apr 12, 2019 at 05:53:14PM +0800, Gao Xiang wrote:
> 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/
> 

Please also use the Fixes tag.

Fixes: 07173c3ec276 ("block: enable multipage bvecs")

> Suggested-by: Ming Lei <ming.lei@redhat.com>
> Reviewed-by: Chao Yu <yuchao0@huawei.com>
> Signed-off-by: Gao Xiang <gaoxiang25@huawei.com>

regards,
dan carpenter

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] staging: erofs: fix unexpected out-of-bound data access
  2019-04-12 13:51 ` Dan Carpenter
@ 2019-04-12 14:38   ` Gao Xiang
  0 siblings, 0 replies; 3+ messages in thread
From: Gao Xiang @ 2019-04-12 14:38 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Chao Yu, Ming Lei, Greg Kroah-Hartman, devel, linux-erofs,
	Chao Yu, LKML, weidu.du, Fang Wei, Miao Xie



On 2019/4/12 21:51, Dan Carpenter wrote:
> On Fri, Apr 12, 2019 at 05:53:14PM +0800, Gao Xiang wrote:
>> 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/
>>
> 
> Please also use the Fixes tag.
> 
> Fixes: 07173c3ec276 ("block: enable multipage bvecs")

Thanks for reminder. Maybe Greg could add this line...

Thanks,
Gao Xiang

> 
>> Suggested-by: Ming Lei <ming.lei@redhat.com>
>> Reviewed-by: Chao Yu <yuchao0@huawei.com>
>> Signed-off-by: Gao Xiang <gaoxiang25@huawei.com>
> 
> regards,
> dan carpenter
> 

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-04-12 14:38 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-12  9:53 [PATCH v2] staging: erofs: fix unexpected out-of-bound data access Gao Xiang
2019-04-12 13:51 ` Dan Carpenter
2019-04-12 14:38   ` Gao Xiang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).