Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp5637102imu; Mon, 26 Nov 2018 03:20:23 -0800 (PST) X-Google-Smtp-Source: AJdET5cpyh/Z+96TxQsA+U9EBz9L2uLY2DQ//HkF3vYf5gH3TG0JDHeKkF9omxKKYyi16voqEFpD X-Received: by 2002:a62:6408:: with SMTP id y8mr27344917pfb.202.1543231223242; Mon, 26 Nov 2018 03:20:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543231223; cv=none; d=google.com; s=arc-20160816; b=Hzh+gYyaus7LY7iqiDcPAmkhkpUS/7OyEKBMPEvVzW7qpAltc63B0pIuLMqFt/7fnB Hr9n0IaUDQkVoRIYfms9mn9nnqwN+KWKOg2wK5mXKx+FkxNDg9tGz0S0YWRKYOgfKf88 0orpk383KiDznnakRmHDTGRnXn9Yt9yFBiQ1dff69zNVOgV9bkd7TB7RNIcdCVKJVUNl W/RoMuV1/M0CZW8sedDCHUM5ncg6e2seELxn/q59pDy3ODiBrYoY93OCKqZ+IOuvLyjJ g6rvT9rn+ifAM+QMXa9k4gabxUodpGuIyNhJgTsj4Z47Len4v2HwkNnvFOHT6y1beCmC zw+Q== 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=Ba7RlfSQF0VArKaM654RX3/GoHzKglexQdMFNtAFTaM=; b=W6UxQefinjriCbxuBaJUon6WFCc9NahuLcl6dZND3HQC8gRFM/4qgJ9QSuNI/Fp+lT W0Fg3ko9jlSx10K69eggPll4RRWyjGIvCmAvBiyaEKXD4GGGp77HqFjDo9P03YuZsoIm asQhGpRLWm8qARlV7FKDnBsghhhW6w+/WYXSGMAomns3EPRiTX4mVmjtmwuc9tLvxZVB 66u5SGnXF8dDlPxHbATP5bk/ziF6WRV5JTsqlZsioU3nr1gzyyF/lBR1vMHi24G4C6sG 6J8/zbBzEKxmSthpZo+3v4IbjD98ByG0i3/D2PPsjQGbcY3U7D/k6qV7Aq+u6Cm3+2CM NQNQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=GRaURG0f; 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 d23si36373078pgm.559.2018.11.26.03.19.56; Mon, 26 Nov 2018 03:20:23 -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=GRaURG0f; 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 S1729763AbeKZVxz (ORCPT + 99 others); Mon, 26 Nov 2018 16:53:55 -0500 Received: from mail.kernel.org ([198.145.29.99]:35754 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728553AbeKZVxy (ORCPT ); Mon, 26 Nov 2018 16:53:54 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.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 5E3AC21104; Mon, 26 Nov 2018 11:00:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1543230008; bh=C39sKKvURYYfVAyqBEgEVHmaRvsbXJa+l94/m9cUYCE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GRaURG0f/9QeySl26hsJ2ocLFEeF+vhUqVclAMG2imH3LEv8+T004yze41GiBBrFO lhFQBlGzNByR/7iGkP/t8t6cg17X2ClXBNRUsVwvVNIcUsDYiq4MAiDwzHMtQ2C53J UFFVuFSlUvjYgYoWLko7+zoHtItf5VACygPoDeog= 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 07/62] hfs: prevent btree data loss on root split Date: Mon, 26 Nov 2018 11:50:48 +0100 Message-Id: <20181126105051.578811267@linuxfoundation.org> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20181126105050.592727680@linuxfoundation.org> References: <20181126105050.592727680@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review 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 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ [ Upstream commit d057c036672f33d43a5f7344acbb08cf3a8a0c09 ] This bug is triggered whenever hfs_brec_update_parent() needs to split the root node. The height of the btree is not increased, which leaves the new node orphaned and its records lost. It is not possible for this to happen on a valid hfs filesystem because the index nodes have fixed length keys. For reasons I ignore, the hfs module does have support for a number of hfsplus features. A corrupt btree header may report variable length keys and trigger this bug, so it's better to fix it. Link: http://lkml.kernel.org/r/9750b1415685c4adca10766895f6d5ef12babdb0.1535682463.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/hfs/brec.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/fs/hfs/brec.c b/fs/hfs/brec.c index 9a8772465a90..da25c49203cc 100644 --- a/fs/hfs/brec.c +++ b/fs/hfs/brec.c @@ -425,6 +425,10 @@ skip: if (new_node) { __be32 cnid; + if (!new_node->parent) { + hfs_btree_inc_height(tree); + new_node->parent = tree->root; + } fd->bnode = hfs_bnode_find(tree, new_node->parent); /* create index key and entry */ hfs_bnode_read_key(new_node, fd->search_key, 14); -- 2.17.1