Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp27023imm; Fri, 21 Sep 2018 17:21:38 -0700 (PDT) X-Google-Smtp-Source: ANB0VdZHtZFOljGLDtf4MveaTmAyEaLDASW5wcwhSCKAbyclsXSWH04ABKL7iRmNMVMf+eCVKb/8 X-Received: by 2002:a62:1c0a:: with SMTP id c10-v6mr137090pfc.41.1537575698332; Fri, 21 Sep 2018 17:21:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537575698; cv=none; d=google.com; s=arc-20160816; b=YLmoiuJFhXEGUXBeFRikuZ3dKShjckariuWvfNo+6Ub2sHjErFD1HlZy6hu5NLxdup lI0Zqaw+ExeS9PP45wbgmjYpUc4obbDOl/ngcufs/HgeAdRzjR+RwoI+yL3J5fZIGzZ9 gIRGudK/wQpv6pk88t/63BEGSuRRc8GVzeI1T8WM+74xkgb5DXCAdQ6y/qGcUUeLWRHq K02ByWm06p1uC7YbTdtXx9Yn1hSAPpxJheGIeK1UH7y9RyhEMtvbWZMvsFsUxtYELi7z SqH0rGssITTerpz6+b4e46OIxNV7AU0W7nChlifAig2ebdqrgUJSIFCI6Osyqiu85GOQ 0s4A== 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:subject:message-id:date:cc:to :from:mime-version:content-transfer-encoding:content-disposition; bh=H7tpy7kjlo0DpPcdsVa83VuxALyMKrCMdMqar2tz+Rw=; b=TwVoF1moSFiIjY90QSGSMzAz07pL7WMF/rNuD27aQnz31agMk/cPkOwCj6dSnC+8x4 VItlek2CSqw2djBkt8U+cEK1NMJ7pa2Mh46nJp5apQq0bfPf277e9LDzywHHekh31ZaX UVw/QyWItXN3y0nG1+aDNx2L79tASDmmSCA0ataKJeE5GZ94TVCTO6ZPeQdUC3wQuZGc GZs3uiu3WNCN3womJuaf2SL/eQmNToRbPl7X1w+xjN6ZrH6VykyXySG2IkfZNqmsDe1K jdc+NkeKLpkg4umyk+b8SYpMYxG8pCecJvwLgqX4azerCPkofbHtoc+BlD9KfmqMTu1M aEYg== ARC-Authentication-Results: i=1; mx.google.com; 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 h187-v6si31810394pfb.62.2018.09.21.17.21.22; Fri, 21 Sep 2018 17:21:38 -0700 (PDT) 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; 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 S2392279AbeIVGMB (ORCPT + 99 others); Sat, 22 Sep 2018 02:12:01 -0400 Received: from shadbolt.e.decadent.org.uk ([88.96.1.126]:44320 "EHLO shadbolt.e.decadent.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2392009AbeIVGKu (ORCPT ); Sat, 22 Sep 2018 02:10:50 -0400 Received: from [2a02:8011:400e:2:cbab:f00:c93f:614] (helo=deadeye) by shadbolt.decadent.org.uk with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1g3Ve1-0008BQ-2G; Sat, 22 Sep 2018 01:19:33 +0100 Received: from ben by deadeye with local (Exim 4.91) (envelope-from ) id 1g3Vdn-0000rX-R8; Sat, 22 Sep 2018 01:19:19 +0100 Content-Type: text/plain; charset="UTF-8" Content-Disposition: inline Content-Transfer-Encoding: 8bit MIME-Version: 1.0 From: Ben Hutchings To: linux-kernel@vger.kernel.org, stable@vger.kernel.org CC: akpm@linux-foundation.org, "Eric Sandeen" , "Darrick J. Wong" , "Christoph Hellwig" Date: Sat, 22 Sep 2018 01:15:42 +0100 Message-ID: X-Mailer: LinuxStableQueue (scripts by bwh) Subject: [PATCH 3.16 23/63] xfs: set format back to extents if xfs_bmap_extents_to_btree In-Reply-To: X-SA-Exim-Connect-IP: 2a02:8011:400e:2:cbab:f00:c93f:614 X-SA-Exim-Mail-From: ben@decadent.org.uk X-SA-Exim-Scanned: No (on shadbolt.decadent.org.uk); SAEximRunCond expanded to false Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 3.16.58-rc1 review patch. If anyone has any objections, please let me know. ------------------ From: Eric Sandeen commit 2c4306f719b083d17df2963bc761777576b8ad1b upstream. If xfs_bmap_extents_to_btree fails in a mode where we call xfs_iroot_realloc(-1) to de-allocate the root, set the format back to extents. Otherwise we can assume we can dereference ifp->if_broot based on the XFS_DINODE_FMT_BTREE format, and crash. Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=199423 Signed-off-by: Eric Sandeen Reviewed-by: Christoph Hellwig Reviewed-by: Darrick J. Wong Signed-off-by: Darrick J. Wong [bwh: Backported to 3.16: - Only one failure path needs to be patched - Adjust filename] Signed-off-by: Ben Hutchings --- fs/xfs/xfs_bmap.c | 4 ++++ 1 file changed, 4 insertions(+) --- a/fs/xfs/xfs_bmap.c +++ b/fs/xfs/xfs_bmap.c @@ -822,6 +822,8 @@ xfs_bmap_extents_to_btree( *logflagsp = 0; if ((error = xfs_alloc_vextent(&args))) { xfs_iroot_realloc(ip, -1, whichfork); + ASSERT(ifp->if_broot == NULL); + XFS_IFORK_FMT_SET(ip, whichfork, XFS_DINODE_FMT_EXTENTS); xfs_btree_del_cursor(cur, XFS_BTREE_ERROR); return error; }