Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp735223ybc; Sat, 16 Nov 2019 07:47:37 -0800 (PST) X-Google-Smtp-Source: APXvYqzC0rc4uZPiCBv/gkhGbWelLaBbkgtnRLxyXP2EbnU7h1lvbx3pCn+hsoAFUnBZLTTw/YZu X-Received: by 2002:a17:906:2444:: with SMTP id a4mr8008027ejb.134.1573919257286; Sat, 16 Nov 2019 07:47:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573919257; cv=none; d=google.com; s=arc-20160816; b=DCWe2JNDpobX8jTSIgdM7BG62ifbbvkosI0Y7Dt/IyalkSVIfBKJy93QWBFNDYr289 y2t6L1PAoOPUOEK9UqNV9QNeI/bfEEHcFYdhQONptD3WdSwoiveQw4oZhT1RLoW6KOyY rif6cNMtqKQP6IKwnPMX2a61uBF/bTM3R6XmB/XqpkOIGJCsoSk/WVdOMapSNTZRua7t +Syc0B1GvyTf14KkOEzUS6DY6Aqte5Cva+DusIorhFKTMFqEXJtE+w+j7iuYgrXxbb7c Jc/Mpwnom67JtlvKaLyGNweYLzxMHrn5NmqVgIqTUZerMJmEcaE7F+CBlbzYeb1o5rmD 1qtg== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=qAPMVqg++y1hxaTjeuusSr51UCHydqPEho9H+5CAOuw=; b=QQH9in083E9JAyDTeaQpQIN9HSheOLzCyc9kyS/ogFB7eA+XfWm8VvCHQTDICGWQ4r yQUCwI97vK5SbO7/mXQUloErrHFxBPMzp695ne3gedQ72tSXCWvHFNTYME4IUWxKCvRF KX+/EFh8TLkqhtxvZedLVmbRX/cXi7OCM+vnI/jTlLy0hUbmvTwZXQEg/HswKQX2h0QI a4z1DEzaYY0S3tscGKZmdtklqRKBW4QKf1wn0m7AEps4yr6zqAz7itdfZ2F0juPGyW6j XgCvUch1iKW5N/7ts/iQcTQQEs7RNP+5rFZmZWZxhvfRIGhSHTwCd7uDal2oKQS8boqm BBFw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=kjkatGxX; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a11si7548294ejx.181.2019.11.16.07.47.12; Sat, 16 Nov 2019 07:47:37 -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=kjkatGxX; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729124AbfKPPpF (ORCPT + 99 others); Sat, 16 Nov 2019 10:45:05 -0500 Received: from mail.kernel.org ([198.145.29.99]:50186 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729100AbfKPPo6 (ORCPT ); Sat, 16 Nov 2019 10:44:58 -0500 Received: from sasha-vm.mshome.net (unknown [50.234.116.4]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 7E38820815; Sat, 16 Nov 2019 15:44:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1573919098; bh=pzDYauFJ0kQK/ZeJvv8P41sxlFTiAZXH6gXqzETieCo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kjkatGxXDYscaqKJ6vv2zlj2xtfsEK6TKr1iVdqgfSgYD0TaZm+MH2xUoxVQnkedV skd/yVk1WQl6y9V4Npm64jqT5SAey2mousurP5D2ngFhqaNhS69KHS7zW4oH4Ogns3 yeX8FXPVQD99xFOH3THIkVc1lWWRFgNO81kgYsN4= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: =?UTF-8?q?Ernesto=20A=2E=20Fern=C3=A1ndez?= , Christoph Hellwig , Andrew Morton , Linus Torvalds , Sasha Levin , linux-fsdevel@vger.kernel.org Subject: [PATCH AUTOSEL 4.19 153/237] hfsplus: fix BUG on bnode parent update Date: Sat, 16 Nov 2019 10:39:48 -0500 Message-Id: <20191116154113.7417-153-sashal@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191116154113.7417-1-sashal@kernel.org> References: <20191116154113.7417-1-sashal@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-stable: review X-Patchwork-Hint: Ignore 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 aa17a392b4140..1918544a78716 100644 --- a/fs/hfsplus/brec.c +++ b/fs/hfsplus/brec.c @@ -449,6 +449,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