From patchwork Thu Mar 29 01:17:50 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: piaojun X-Patchwork-Id: 10314319 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 25A8260353 for ; Thu, 29 Mar 2018 01:18:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1258F2855A for ; Thu, 29 Mar 2018 01:18:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 06C0829F8F; Thu, 29 Mar 2018 01:18:34 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=2.0 tests=BAYES_00 autolearn=ham version=3.3.1 Received: from userp2120.oracle.com (userp2120.oracle.com [156.151.31.85]) (using TLSv1.2 with cipher AES256-SHA256 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 607A82855A for ; Thu, 29 Mar 2018 01:18:33 +0000 (UTC) Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w2T14xvI118713; Thu, 29 Mar 2018 01:18:20 GMT Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by userp2120.oracle.com with ESMTP id 2h0nvcr2bd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 29 Mar 2018 01:18:20 +0000 Received: from oss.oracle.com (oss-old-reserved.oracle.com [137.254.22.2]) by aserv0022.oracle.com (8.14.4/8.14.4) with ESMTP id w2T1IIge029457 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Thu, 29 Mar 2018 01:18:19 GMT Received: from localhost ([127.0.0.1] helo=lb-oss.oracle.com) by oss.oracle.com with esmtp (Exim 4.63) (envelope-from ) id 1f1MCo-0007C3-Ob; Wed, 28 Mar 2018 18:18:18 -0700 Received: from aserv0022.oracle.com ([141.146.126.234]) by oss.oracle.com with esmtp (Exim 4.63) (envelope-from ) id 1f1MCn-0007Bu-Re for ocfs2-devel@oss.oracle.com; Wed, 28 Mar 2018 18:18:17 -0700 Received: from userp2030.oracle.com (userp2030.oracle.com [156.151.31.89]) by aserv0022.oracle.com (8.14.4/8.14.4) with ESMTP id w2T1IHpO029426 (version=TLSv1/SSLv3 cipher=AES256-SHA256 bits=256 verify=FAIL) for ; Thu, 29 Mar 2018 01:18:17 GMT Received: from pps.filterd (userp2030.oracle.com [127.0.0.1]) by userp2030.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w2T1IHTl016355 for ; Thu, 29 Mar 2018 01:18:17 GMT Received: from huawei.com (szxga07-in.huawei.com [45.249.212.35] (may be forged)) by userp2030.oracle.com with ESMTP id 2h0h59mxt5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO) for ; Thu, 29 Mar 2018 01:18:16 +0000 Received: from DGGEMS403-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id 24CBBD146E4CB; Thu, 29 Mar 2018 09:18:11 +0800 (CST) Received: from [10.177.253.249] (10.177.253.249) by smtp.huawei.com (10.3.19.203) with Microsoft SMTP Server id 14.3.361.1; Thu, 29 Mar 2018 09:18:06 +0800 To: "akpm@linux-foundation.org" , Joseph Qi , Junxiao Bi , Joel Becker From: piaojun Message-ID: <5ABC3EBE.5020807@huawei.com> Date: Thu, 29 Mar 2018 09:17:50 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 X-Originating-IP: [10.177.253.249] X-CFilter-Loop: Reflected X-CLX-Shades: MLX X-CLX-Response: 1TFkXGx0ZEQpMehcbHBIRCllNF2dmchEKWUkXGnEaEBp3BhsfGXEZGRAadwY YGgYaEQpZXhdobnkRCklGF0VYS0lGT3VaWEVOX0leQ0VEGXVPSxEKQ04XWBpBHBtrElNHfW0Tfn tadV1GeB1kemdDekkSQn8eH28RClhcFx8EGgQbGBMHS09JEkkfT04FGxoEGxoaBB4SBBsQGx4aH xoRCl5ZF3gST2RQEQpNXBcZHBIRCkxaF2hpQk17EQpNThdoEQpDWhceHwQYHhMEGBsYBBkfEQpC XhcbEQpEXhcfEQpESRceEQpCRhdgU24eQxlzZ1hGZhEKQlwXGhEKQkUXZlxse3BkYnoSfEMRCkJ OF2xCSFlTGk1leHgdEQpCTBdvSxkSEkRZeVsbXxEKQmwXYwVCUmZAYl5ae1IRCkJAF2ZvZ2xsaF hSAW1jEQpCWBdifW95AU8YGXBwexEKWlgXGBEKcGcXb2EcWWdSH3oSbBgQHhIRCnBoF2xkRk98b XJTT2N9EBoRCnBoF2dic3tHeAUFSBIcEBoRCnBoF2B8BV1Oa3pcWk1sEBoRCnBoF3pFblhncHBO U1tHEBoRCnBoF2d9Hx16HWgFbkBIEBoRCnBsF2FJeUN6c0l4Z2xiEB4SEQptfhcaEQpYTRdLESA = X-PDR: PASS X-Source-IP: 45.249.212.35 X-ServerName: [45.249.212.35] X-Proofpoint-SPF-Result: pass X-Proofpoint-SPF-Record: v=spf1 ip4:45.249.212.32 ip4:45.249.212.35 ip4:119.145.14.93 ip4:58.251.152.93 ip4:194.213.3.17 ip4:206.16.17.72 ip4:45.249.212.255 ip4:45.249.212.187/29 ip4:45.249.212.191 ~all X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=8846 signatures=668695 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=168 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=173 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1711220000 definitions=main-1803290012 X-Spam: Clean Cc: "ocfs2-devel@oss.oracle.com" Subject: [Ocfs2-devel] [PATCH v2] ocfs2/o2hb: check len for bio_add_page() to avoid getting incorrect bio X-BeenThere: ocfs2-devel@oss.oracle.com X-Mailman-Version: 2.1.9 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: ocfs2-devel-bounces@oss.oracle.com Errors-To: ocfs2-devel-bounces@oss.oracle.com X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=8846 signatures=668695 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1711220000 definitions=main-1803290010 X-Virus-Scanned: ClamAV using ClamSMTP We need check len for bio_add_page() to make sure the bio has been set up correctly, otherwise we may submit incorrect data to device. Signed-off-by: Jun Piao Reviewed-by: Yiwen Jiang Reviewed-by: Changwei Ge Acked-by: Joseph Qi --- fs/ocfs2/cluster/heartbeat.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/fs/ocfs2/cluster/heartbeat.c b/fs/ocfs2/cluster/heartbeat.c index ea8c551..91a8889 100644 --- a/fs/ocfs2/cluster/heartbeat.c +++ b/fs/ocfs2/cluster/heartbeat.c @@ -570,7 +570,16 @@ static struct bio *o2hb_setup_one_bio(struct o2hb_region *reg, current_page, vec_len, vec_start); len = bio_add_page(bio, page, vec_len, vec_start); - if (len != vec_len) break; + if (len != vec_len) { + mlog(ML_ERROR, "Adding page[%d] to bio failed, " + "page %p, len %d, vec_len %u, vec_start %u, " + "bi_sector %llu\n", current_page, page, len, + vec_len, vec_start, + (unsigned long long)bio->bi_iter.bi_sector); + bio_put(bio); + bio = ERR_PTR(-EIO); + return bio; + } cs += vec_len / (PAGE_SIZE/spp); vec_start = 0;