Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp3945989ybv; Tue, 25 Feb 2020 10:09:28 -0800 (PST) X-Google-Smtp-Source: APXvYqzS3GOEAj8eyJpZtmB661iRTsmhcc6cs8CqqTJH1Rdqi77k0a4B1QHSAthQJqNVcnbwr8VL X-Received: by 2002:aca:a810:: with SMTP id r16mr163355oie.116.1582654168633; Tue, 25 Feb 2020 10:09:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582654168; cv=none; d=google.com; s=arc-20160816; b=LLPVNjbzyDoZ7PSW4m2dhkvB+vqGfX235mosG+3lJjvhU7Ke+i94hCMvD2xuteQILy nb3a+CuVI8VkuKWgB65N9+cpMeOukgPKmfuBsq5NvIn5IQCtKxNmeJxpYDePwZFrRUVF Z6be32HiDHNMNTEpA6xvc/9KhQXMsyAwL7q5iHcBvioktU42/4aKJ6B1IWEei95HzVTx 55s/mvVjfRLQKsk4fOUPsfIefMtDMJN2diNUCwOMCfe7fu6NYRNRyvDi45m4QC8M4XYC nVtnvnxZJRAF/y1n2kGNYe3teKFVwdRsICs8fJl2lFvjC9x6qKf+PSlKSvEKecGxCKLc jEjQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=aCaDXtbBQPVEc9XwUeRXZXycGtd4URd8os8NhYVB/ZI=; b=xvP/6IFEhU/S9ZRgJz0DYVZcEkgwnlEKzxNpjq50553YNAsETPMMlvrXwMgMcQLzvi Qo6vsWnzrhqWbiWT86QPO7cbfu2RhrXLceduYkNbWneFVZPAn9w0MRq87V8tQ5zCnZb5 NHaRvGI2iFMqiLsY4TxtKywRDbQDJzHs7d98Cp4o3E6UuGqTmaOF04gyP033qUGwMW11 ehmi0I0XaEnG3Qx7hUzg9m3xQkjUhdoFgBgEHxGOxYc+icb5PlhT9aUCMSMHxOhQOCHK V0GZNCswfVsqmqhdAOObLDTvefGDbi1WpOBUBH+EtBvZuBqHcRJYuj+Rddqn2EaqZE5L BAFg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=kjY4KEu9; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i3si8931759otc.272.2020.02.25.10.09.16; Tue, 25 Feb 2020 10:09:28 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=kjY4KEu9; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731092AbgBYSH1 (ORCPT + 99 others); Tue, 25 Feb 2020 13:07:27 -0500 Received: from bombadil.infradead.org ([198.137.202.133]:44184 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728367AbgBYSH1 (ORCPT ); Tue, 25 Feb 2020 13:07:27 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=aCaDXtbBQPVEc9XwUeRXZXycGtd4URd8os8NhYVB/ZI=; b=kjY4KEu9G68waT7PVGTNrC5OTD alIjGbCn1cTJsnpr7OKaq8fT6XfrJox2JDRDqiEwD0GbL+GW8RZHNIrTyijbZv2RTE6IFbZw0GycS px2U5yzIkx4yBHBZNEsQZUIR8AhuJULSbGSX8aD+vTlOllUVyTuBdlnVNybDzC3rjDYLJ+T4/h/NX ughbMwxKWUz3R2frUfteJaPIOkvA/s8M8gUKk0Tf0V2gn//LWFcCOpj0kuikDHj2jwVJnm2DqU/5K qYcrvlBIicxkjoSW0dGlrrSpvqZ6WpURqmoG7qyqr6CeCM5tR4vENw6dl0ArDHKogeKPwm6/xuZrL 6G18/UDg==; Received: from hch by bombadil.infradead.org with local (Exim 4.92.3 #3 (Red Hat Linux)) id 1j6ec9-0007zW-2t; Tue, 25 Feb 2020 18:07:25 +0000 Date: Tue, 25 Feb 2020 10:07:25 -0800 From: Christoph Hellwig To: Qian Cai Cc: darrick.wong@oracle.com, linux-xfs@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] xfs: fix an undefined behaviour in _da3_path_shift Message-ID: <20200225180725.GA29862@infradead.org> References: <1582641477-4011-1-git-send-email-cai@lca.pw> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1582641477-4011-1-git-send-email-cai@lca.pw> X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org I think we code do this a tad more cleaner, something like: diff --git a/fs/xfs/libxfs/xfs_da_btree.c b/fs/xfs/libxfs/xfs_da_btree.c index 875e04f82541..542a4edfcf54 100644 --- a/fs/xfs/libxfs/xfs_da_btree.c +++ b/fs/xfs/libxfs/xfs_da_btree.c @@ -1986,7 +1986,8 @@ xfs_da3_path_shift( ASSERT(path != NULL); ASSERT((path->active > 0) && (path->active < XFS_DA_NODE_MAXDEPTH)); level = (path->active-1) - 1; /* skip bottom layer in path */ - for (blk = &path->blk[level]; level >= 0; blk--, level--) { + for ( ; level >= 0; level--) { + blk = &path->blk[level]; xfs_da3_node_hdr_from_disk(dp->i_mount, &nodehdr, blk->bp->b_addr);