Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp5982960ybc; Wed, 27 Nov 2019 12:52:45 -0800 (PST) X-Google-Smtp-Source: APXvYqySnKFdvWGF0sKF92DIzllWhRMfuK+KXb0Y1Vl9U2lG5CcDZJlwN+FfCIScrUfIAlsOaQDq X-Received: by 2002:aa7:c5d3:: with SMTP id h19mr34601091eds.120.1574887965721; Wed, 27 Nov 2019 12:52:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574887965; cv=none; d=google.com; s=arc-20160816; b=wDPpAGXz0Lq4C+QTCvHV9JIgf01L7MvaLHvHuzsP4YadM0u267g5XI7SZmmaLJftAu W0RNEfQE8ShSfANYqb3XX/vgSCQy30x2V4TwpmCPr4VCpj9PsG4Y8B2Kbe0DjUAp40HZ HTAOtf40/U6wRRkIx3FPCs3S6gA3TuACGDMWIUGjVIYhWQaJpTUIGWJ361CZgi6Jy0Hf IlmkuFKp84WLoKzGIYK1iIFeHsfaT2dSgEQfZEpomNNNFyDqwqbtJbl1oCDF7Fam4kCw X2//szBfGquSV3WkEAN8fwURgLz6uvdLB6J7YeyLsCH2IGwmZ7HtVYPk/h3Dg2P2lEMu KbIg== 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=TveEMae9/JbhR1UL0iDH1uJqhk3oxNkj5mKaEiFBRkA=; b=D3X8fcu5nrxRfxct0fw6p/hlmDNbZH8kyDa5ZvzbH4XZSTg1UtNxTSDqIkfe9ULH6h jCMqI1VFuqpwNADaJhMT/kN2liQzIqXnq1RAYZisR0BsdXS7gaGDkaojc5uKJ6PKXzs/ jOnzL44zO9PvBzY73p20huVVLKNRwhbyIEqi5WzUJC72pgGwLH4aEVWsNGWo6o28QVtQ Q5iRaskZjSwPcFt+B09e3HzHybrdF0aWi47YQlIdU/sesgip//b3xoMtx/JRzY1ud7LS ngnljot7sEi7eBExDHcPB50xqNOUQciXxem1Lnwq1L3E+aWRMB662ON5c0XFItS6kYSg hsfQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=U6VMJaGs; 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 k23si10309926ejd.176.2019.11.27.12.52.21; Wed, 27 Nov 2019 12:52:45 -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=pass header.i=@kernel.org header.s=default header.b=U6VMJaGs; 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 S1730357AbfK0Uu2 (ORCPT + 99 others); Wed, 27 Nov 2019 15:50:28 -0500 Received: from mail.kernel.org ([198.145.29.99]:36302 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730347AbfK0UuX (ORCPT ); Wed, 27 Nov 2019 15:50:23 -0500 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 DA6D621847; Wed, 27 Nov 2019 20:50:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1574887823; bh=jVnLETnGPfxAFSTB/kINL/wkeobz7QLCRb02W0EwSyE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=U6VMJaGs7kLw0yDs+UL10oag1fsxwUKhtM1PuWZp90ZLY/hScObGhj/crmGb3JlRA bLBye1twCa+o5WeQ7cz60tKj46k1pxeQYdgVupNXkG+Y56xZqqRweIjqaSgq7i3Fwe PHAh3dswJH4oMUxmn7O07r5UVPcHpW5dZrCf05I4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, "=?UTF-8?q?Ernesto=20A . =20Fern=C3=A1ndez?=" , Christoph Hellwig , Andrew Morton , Linus Torvalds , Sasha Levin Subject: [PATCH 4.14 109/211] hfsplus: fix BUG on bnode parent update Date: Wed, 27 Nov 2019 21:30:42 +0100 Message-Id: <20191127203104.397602489@linuxfoundation.org> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191127203049.431810767@linuxfoundation.org> References: <20191127203049.431810767@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: Ernesto A. Fernández [ Upstream commit 19a9d0f1acf75e8be8cfba19c1a34e941846fa2b ] Creating, renaming or deleting a file may hit BUG_ON() if the first record of both a leaf node and its parent are changed, and if this forces the parent to be split. This bug is triggered by xfstests generic/027, somewhat rarely; here is a more reliable reproducer: truncate -s 50M fs.iso mkfs.hfsplus fs.iso mount fs.iso /mnt i=1000 while [ $i -le 2400 ]; do touch /mnt/$i &>/dev/null ((++i)) done i=2400 while [ $i -ge 1000 ]; do mv /mnt/$i /mnt/$(perl -e "print $i x61") &>/dev/null ((--i)) done The issue is that a newly created bnode is being put twice. Reset new_node to NULL in hfs_brec_update_parent() before reaching goto again. Link: http://lkml.kernel.org/r/5ee1db09b60373a15890f6a7c835d00e76bf601d.1535682461.git.ernesto.mnd.fernandez@gmail.com Signed-off-by: Ernesto A. Fernández Cc: Christoph Hellwig Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Sasha Levin --- fs/hfsplus/brec.c | 1 + 1 file changed, 1 insertion(+) diff --git a/fs/hfsplus/brec.c b/fs/hfsplus/brec.c index d3f36982f6858..0f53a486d2c18 100644 --- a/fs/hfsplus/brec.c +++ b/fs/hfsplus/brec.c @@ -448,6 +448,7 @@ static int hfs_brec_update_parent(struct hfs_find_data *fd) /* restore search_key */ hfs_bnode_read_key(node, fd->search_key, 14); } + new_node = NULL; } if (!rec && node->parent) -- 2.20.1