Received: by 2002:a05:6a10:c7c6:0:0:0:0 with SMTP id h6csp1639566pxy; Mon, 2 Aug 2021 06:51:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxTk0/S1iMCIN5az4UiI7ntNbfZ8r+PzwNVEBWlanE1SpYe+KNCTmXrdlB4Y43zuNygv7gZ X-Received: by 2002:a92:905:: with SMTP id y5mr1721828ilg.222.1627912307612; Mon, 02 Aug 2021 06:51:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627912307; cv=none; d=google.com; s=arc-20160816; b=gNhnFtmeSuvQIS4xyneuolKCaaYxLFc5rA+R/Kai77LmgVIURirAVAyNpXhBCh8ijy ZwUfC+X9VThDCBDYjYYYSbUiVskLZLCQVtWs2ZjMWu9Hfh2IcgPIn4UktnmcP838bMAX 9bJcxyfBHH2KQy6i8uDDorcg1Za5hqSlNpMrWZwmcAoi/o89kA+RIvTkNNhcwrRLPH2R b5kPSXB8q0FsBBjm+DlBwuveSu030vUbMpWELJFTya6Lxu/yq0xFYHsHRjGgEqBX3crv FUm114kIEM6jTuVYdg3+Zk9u1ppmnRsYh+Q+McmIsGgeuMCuthYgs2DRKPD6bpLJXo6m hkPw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=841OrZMFZjUeMhd1Fr3UX+5WgxHPibLLdBf0rvje3Oo=; b=wLLZBsu0ayi0iJPKcWVe8AOpXpL919T6QVNVLHXAqh3IFalsCpPNZdrX39Q/LH/Dti RJtuujJy+LNnbn3FIrxOJhq7tNbgGH4DFAzMK//3xBvQzcqJ0x+e3nXCW+GRW6kMTGEf CM+9ttUdAW0G8GGqJ2mKIWSrwv9DhlTqrqLf6evc1DwXbzG1pGZ6G32ed6YYe86aLHYb loGDj1jm9cy42K3kOSscKaqk8wbCFikrNuyIrHoLYiJtGlIBGksMWk5smSZVBEJw6wfK ra7YoUb6vsF866eaveQqZyx2D8sST7iq7/aVJ3uOigrITo63NJGb+UGAOay611AczFy0 3ssg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=jdmvde+V; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y7si12155618jae.125.2021.08.02.06.51.36; Mon, 02 Aug 2021 06:51:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=jdmvde+V; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234798AbhHBNvC (ORCPT + 99 others); Mon, 2 Aug 2021 09:51:02 -0400 Received: from mail.kernel.org ([198.145.29.99]:58080 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234330AbhHBNr7 (ORCPT ); Mon, 2 Aug 2021 09:47:59 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 16A3561100; Mon, 2 Aug 2021 13:47:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1627912069; bh=Jak8ZkmCLa0oz8T4zwIaW/iDvItCwLsURakycKZ58Cc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jdmvde+VK8TtCaACCl9o1XAR1PbbnrM0B+dDaNzAsxXelQ+VzvIlUjPMRz1lixmCa 2Nj9NKEfmj+mVCUI2ruhdqqfPiTyKyMjkReuOQStCGrWvaDwQqeYbF+wjThIJYnvHL 1eqMHOUI+DT3gr2H2l4YqMTcMpbfP4TYqFcrOLMU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Desmond Cheong Zhi Xi , Viacheslav Dubeyko , "Gustavo A. R. Silva" , Al Viro , Shuah Khan , Andrew Morton , Linus Torvalds , Sasha Levin Subject: [PATCH 4.9 09/32] hfs: add missing clean-up in hfs_fill_super Date: Mon, 2 Aug 2021 15:44:29 +0200 Message-Id: <20210802134333.217499590@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210802134332.931915241@linuxfoundation.org> References: <20210802134332.931915241@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Desmond Cheong Zhi Xi [ Upstream commit 16ee572eaf0d09daa4c8a755fdb71e40dbf8562d ] Patch series "hfs: fix various errors", v2. This series ultimately aims to address a lockdep warning in hfs_find_init reported by Syzbot [1]. The work done for this led to the discovery of another bug, and the Syzkaller repro test also reveals an invalid memory access error after clearing the lockdep warning. Hence, this series is broken up into three patches: 1. Add a missing call to hfs_find_exit for an error path in hfs_fill_super 2. Fix memory mapping in hfs_bnode_read by fixing calls to kmap 3. Add lock nesting notation to tell lockdep that the observed locking hierarchy is safe This patch (of 3): Before exiting hfs_fill_super, the struct hfs_find_data used in hfs_find_init should be passed to hfs_find_exit to be cleaned up, and to release the lock held on the btree. The call to hfs_find_exit is missing from an error path. We add it back in by consolidating calls to hfs_find_exit for error paths. Link: https://syzkaller.appspot.com/bug?id=f007ef1d7a31a469e3be7aeb0fde0769b18585db [1] Link: https://lkml.kernel.org/r/20210701030756.58760-1-desmondcheongzx@gmail.com Link: https://lkml.kernel.org/r/20210701030756.58760-2-desmondcheongzx@gmail.com Signed-off-by: Desmond Cheong Zhi Xi Reviewed-by: Viacheslav Dubeyko Cc: Gustavo A. R. Silva Cc: Al Viro Cc: Shuah Khan Cc: Greg Kroah-Hartman Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Sasha Levin --- fs/hfs/super.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/fs/hfs/super.c b/fs/hfs/super.c index bf6304a350a6..c2a5a0ca3948 100644 --- a/fs/hfs/super.c +++ b/fs/hfs/super.c @@ -427,14 +427,12 @@ static int hfs_fill_super(struct super_block *sb, void *data, int silent) if (!res) { if (fd.entrylength > sizeof(rec) || fd.entrylength < 0) { res = -EIO; - goto bail; + goto bail_hfs_find; } hfs_bnode_read(fd.bnode, &rec, fd.entryoffset, fd.entrylength); } - if (res) { - hfs_find_exit(&fd); - goto bail_no_root; - } + if (res) + goto bail_hfs_find; res = -EINVAL; root_inode = hfs_iget(sb, &fd.search_key->cat, &rec); hfs_find_exit(&fd); @@ -450,6 +448,8 @@ static int hfs_fill_super(struct super_block *sb, void *data, int silent) /* everything's okay */ return 0; +bail_hfs_find: + hfs_find_exit(&fd); bail_no_root: pr_err("get root inode failed\n"); bail: -- 2.30.2