From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.0 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D56ABC10F0E for ; Fri, 12 Apr 2019 09:28:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A86A62186A for ; Fri, 12 Apr 2019 09:28:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727676AbfDLJ2p (ORCPT ); Fri, 12 Apr 2019 05:28:45 -0400 Received: from szxga03-in.huawei.com ([45.249.212.189]:2109 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726678AbfDLJ2p (ORCPT ); Fri, 12 Apr 2019 05:28:45 -0400 Received: from DGGEMM406-HUB.china.huawei.com (unknown [172.30.72.53]) by Forcepoint Email with ESMTP id A558976D1FCE4BA83249; Fri, 12 Apr 2019 17:28:41 +0800 (CST) Received: from dggeme763-chm.china.huawei.com (10.3.19.109) by DGGEMM406-HUB.china.huawei.com (10.3.20.214) with Microsoft SMTP Server (TLS) id 14.3.408.0; Fri, 12 Apr 2019 17:28:40 +0800 Received: from [10.134.22.195] (10.134.22.195) by dggeme763-chm.china.huawei.com (10.3.19.109) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1591.10; Fri, 12 Apr 2019 17:28:38 +0800 Subject: Re: [PATCH] staging: erofs: fix unexpected out-of-bound data access To: Gao Xiang , Ming Lei , "Greg Kroah-Hartman" , CC: LKML , , "Chao Yu" , Miao Xie , , Fang Wei References: <20190411105555.133551-1-gaoxiang25@huawei.com> From: Chao Yu Message-ID: <0332f6b3-9705-50d2-6e1e-639d3e8e915f@huawei.com> Date: Fri, 12 Apr 2019 17:28:39 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <20190411105555.133551-1-gaoxiang25@huawei.com> Content-Type: text/plain; charset="windows-1252" Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [10.134.22.195] X-ClientProxiedBy: dggeme705-chm.china.huawei.com (10.1.199.101) To dggeme763-chm.china.huawei.com (10.3.19.109) X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2019/4/11 18:55, 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. It will be better to add link address of discussion thread in your commit message, since discussion includes more details about how this issue happens. > > Suggested-by: Ming Lei > Signed-off-by: Gao Xiang Reviewed-by: Chao Yu Thanks, > --- > > It should be fixed from linux-5.1-rc after 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; >