Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp2932688ybk; Mon, 18 May 2020 11:25:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwXoElASLE5unMbYn47r5sGpGZKsZZywa3oVGbG+GJOA0vBqLlJRMX2oSq78CJsEnzMIyhQ X-Received: by 2002:a50:f301:: with SMTP id p1mr8186419edm.180.1589826350864; Mon, 18 May 2020 11:25:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589826350; cv=none; d=google.com; s=arc-20160816; b=z8gUZFZ8TRwe8M5Cjphvz04RhkqlaEuF9TdqCJOgSJLVG+DsS1q7q1NhO3vjdY++tZ QBdDfOia+b3Rf2HB7snRtiVVh764JZLZjvDlthJ9WQIz1T548LwniPkjlx8OSoa6Sqem 6GnrOCQcwoRMDTpi1A01DgHYhzy8Z/vWNNvyFE5S4Fb94nk3vgcSwgvgxentvCb7dYXN GNsb7vKyR+wvre62aScJsMBuM43SxKYSEtbuj5Es0TrH4UMJSSm+CZgtDO+hzo5k8kMM tvEeyRZlbMxZncmCo29FX7O0jA34F656U7OHM0BhdZtk08kZelIxxQyU8QbvAS+mBWVI Bf+w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=V3zr+nlFKDHRH3YdSBpB6PmDMmAEVzRiAmg5SdoPUI0=; b=BwF5tCsRIqQvS3/LC6VHW7z7Fxo5Yqg+qo5alYCeo996gVAPn2hWjEnokROUaR5hw2 w9nYPn7p1rkdpC9/TWTzMEm0iV4XNZknAxW1m4oiXBh3NG32bwONnTVjuMP5ZYxiBBQM 1vVbxCjzZ6CMXIFPdYiOR0E4EfeBduWumPWL1SFeRqERylqiaDRDctUeSnUGrX+Gh/lG iKiamPq4FH+K6ZNbtqwN0inWDFpomKjXMIPxpky1hdKMNGStLt19b9aHrh4KD2ZNBokD fIQTbO/SykR85YuYBq4Ms7AjBEsSymU8IEIBL3SijoJMNuit6C8IxjkToKj4H/am0Sr7 3Vsw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=kaqsu5by; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d13si1263388ejj.191.2020.05.18.11.25.27; Mon, 18 May 2020 11:25:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=kaqsu5by; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387846AbgERSVZ (ORCPT + 99 others); Mon, 18 May 2020 14:21:25 -0400 Received: from mail.kernel.org ([198.145.29.99]:56582 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731059AbgERRw4 (ORCPT ); Mon, 18 May 2020 13:52:56 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 93F9020674; Mon, 18 May 2020 17:52:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1589824376; bh=ZxyMZGot4qCsJCnM/6wDEDK6o+19Yya0ofBttyLsprY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kaqsu5bymFJkbSL+qry0BkLhIDEti3zaeOL8gGyfdMuUHmPIx5IgHtG8GpAynApFg ZgDKaaNCXOjL9J1ofg3hIgKM1bCoOSKO8ZAAaBWQb7WO08/HIg8thEifhZiRsfvzJu 9bjomXVi9CIvTu+ybrtwpFbYxml7ODDRYxcylwMk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Andreas Gruenbacher , Bob Peterson , Sasha Levin Subject: [PATCH 4.19 30/80] gfs2: Another gfs2_walk_metadata fix Date: Mon, 18 May 2020 19:36:48 +0200 Message-Id: <20200518173456.501252925@linuxfoundation.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200518173450.097837707@linuxfoundation.org> References: <20200518173450.097837707@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Andreas Gruenbacher [ Upstream commit 566a2ab3c9005f62e784bd39022d58d34ef4365c ] Make sure we don't walk past the end of the metadata in gfs2_walk_metadata: the inode holds fewer pointers than indirect blocks. Slightly clean up gfs2_iomap_get. Fixes: a27a0c9b6a20 ("gfs2: gfs2_walk_metadata fix") Cc: stable@vger.kernel.org # v5.3+ Signed-off-by: Andreas Gruenbacher Signed-off-by: Bob Peterson Signed-off-by: Sasha Levin --- fs/gfs2/bmap.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/fs/gfs2/bmap.c b/fs/gfs2/bmap.c index 096b479721395..43f53020553b5 100644 --- a/fs/gfs2/bmap.c +++ b/fs/gfs2/bmap.c @@ -530,10 +530,12 @@ static int gfs2_walk_metadata(struct inode *inode, struct metapath *mp, /* Advance in metadata tree. */ (mp->mp_list[hgt])++; - if (mp->mp_list[hgt] >= sdp->sd_inptrs) { - if (!hgt) + if (hgt) { + if (mp->mp_list[hgt] >= sdp->sd_inptrs) + goto lower_metapath; + } else { + if (mp->mp_list[hgt] >= sdp->sd_diptrs) break; - goto lower_metapath; } fill_up_metapath: @@ -879,10 +881,9 @@ static int gfs2_iomap_get(struct inode *inode, loff_t pos, loff_t length, ret = -ENOENT; goto unlock; } else { - /* report a hole */ iomap->offset = pos; iomap->length = length; - goto do_alloc; + goto hole_found; } } iomap->length = size; @@ -936,8 +937,6 @@ static int gfs2_iomap_get(struct inode *inode, loff_t pos, loff_t length, return ret; do_alloc: - iomap->addr = IOMAP_NULL_ADDR; - iomap->type = IOMAP_HOLE; if (flags & IOMAP_REPORT) { if (pos >= size) ret = -ENOENT; @@ -959,6 +958,9 @@ static int gfs2_iomap_get(struct inode *inode, loff_t pos, loff_t length, if (pos < size && height == ip->i_height) ret = gfs2_hole_size(inode, lblock, len, mp, iomap); } +hole_found: + iomap->addr = IOMAP_NULL_ADDR; + iomap->type = IOMAP_HOLE; goto out; } -- 2.20.1