From patchwork Wed Jul 4 09:59:58 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Carpenter X-Patchwork-Id: 10506449 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 4258C603D7 for ; Wed, 4 Jul 2018 10:00:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3301428DF4 for ; Wed, 4 Jul 2018 10:00:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2851928E20; Wed, 4 Jul 2018 10:00:42 +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=-7.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D388628E20 for ; Wed, 4 Jul 2018 10:00:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932572AbeGDKAj (ORCPT ); Wed, 4 Jul 2018 06:00:39 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:56836 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932399AbeGDKAh (ORCPT ); Wed, 4 Jul 2018 06:00:37 -0400 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 w649xPCO059455; Wed, 4 Jul 2018 10:00:18 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=date : from : to : cc : subject : message-id : mime-version : content-type; s=corp-2017-10-26; bh=L24d0VhJXOMjRMz/Q0usQ9gMi/RHDH9E3suzVJ7ptQY=; b=nDmh2jk0f2tb2o6VWyH926GD8oHJocfyNvjZEVg/9b9a1ikm0ljYUY6wPKOEJCuxq0CS bifVNK1c/xL8YmHnZ1/4kPl0SffK7zl9yzsOKVleBDES2NTnBh61cGy+vlU7CGn715i0 8NBJGgTcrI3xirA+3WV1M81t1EzmRXJtARisuXPhMf2W9YI79GmYtruLpAtiiXP2Z8QD hm2+GWg+mTttf+49UEGfyu+t+qgGUa30Rbs1k4TaiTJZB29qh98JJ9mrdJD3HUhIkVez SBylC5ZuT6O7wFi7urW/9kpYvPPZYGDbjkpNYWxy/5jxggE5HH/0H571t/WAau8ShYKn iQ== Received: from userv0021.oracle.com (userv0021.oracle.com [156.151.31.71]) by userp2120.oracle.com with ESMTP id 2k0dnjj6ak-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 04 Jul 2018 10:00:18 +0000 Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by userv0021.oracle.com (8.14.4/8.14.4) with ESMTP id w64A0Ia9017891 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 4 Jul 2018 10:00:18 GMT Received: from abhmp0016.oracle.com (abhmp0016.oracle.com [141.146.116.22]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id w64A0Du8032568; Wed, 4 Jul 2018 10:00:17 GMT Received: from kili.mountain (/197.157.34.168) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 04 Jul 2018 03:00:12 -0700 Date: Wed, 4 Jul 2018 12:59:58 +0300 From: Dan Carpenter To: Trond Myklebust , Christoph Hellwig Cc: Anna Schumaker , Philippe Ombredanne , Benjamin Coddington , linux-nfs@vger.kernel.org Subject: [PATCH] pnfs/blocklayout: off by one in bl_map_stripe() Message-ID: <20180704095957.bujo2izpjlcvjanb@kili.mountain> MIME-Version: 1.0 Content-Disposition: inline X-Mailer: git-send-email haha only kidding User-Agent: NeoMutt/20170113 (1.7.2) X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=8943 signatures=668704 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-1806210000 definitions=main-1807040118 Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP "dev->nr_children" is the number of children which were parsed successfully in bl_parse_stripe(). It could be all of them and then, in that case, it is equal to v->stripe.volumes_count. Either way, the > should be >= so that we don't go beyond the end of what we're supposed to. Fixes: 5c83746a0cf2 ("pnfs/blocklayout: in-kernel GETDEVICEINFO XDR parsing") Signed-off-by: Dan Carpenter Reviewed-by: Christoph Hellwig --- To unsubscribe from this list: send the line "unsubscribe linux-nfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/fs/nfs/blocklayout/dev.c b/fs/nfs/blocklayout/dev.c index a7efd83779d2..dec5880ac6de 100644 --- a/fs/nfs/blocklayout/dev.c +++ b/fs/nfs/blocklayout/dev.c @@ -204,7 +204,7 @@ static bool bl_map_stripe(struct pnfs_block_dev *dev, u64 offset, chunk = div_u64(offset, dev->chunk_size); div_u64_rem(chunk, dev->nr_children, &chunk_idx); - if (chunk_idx > dev->nr_children) { + if (chunk_idx >= dev->nr_children) { dprintk("%s: invalid chunk idx %d (%lld/%lld)\n", __func__, chunk_idx, offset, dev->chunk_size); /* error, should not happen */