Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp1054562pxv; Thu, 22 Jul 2021 21:03:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxVNTFav3xvRTBnvYEVugOFW2GDsUPuAsG+0PSyMZWt8ljP5E9dx1kOr17A0fJf62jPE+ho X-Received: by 2002:a05:6402:6cf:: with SMTP id n15mr3299216edy.362.1627013029262; Thu, 22 Jul 2021 21:03:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627013029; cv=none; d=google.com; s=arc-20160816; b=P7d3joBFmheBZPjClRVyRVD8xAPQnyRu+fzb/5S8rRWXEk0y4M5hNktfsIi+3jvgn7 ir6ZQgU2m+raJuobeeZK3tW76J4obG+96Vtc3kT+HSCeBw6oODvRob7NjmuvR5/+XL4V RGjZksIx02mSvOG2f3qcudClA9M1FBXkHJXdbwxrISX567QdRJ4fcJnVaKE18lefvvwl U6mT18i3cBvU5Z4cIUHQu4Mhoes4agvXBXtQu0LFQmHF2JN/sW27BNS8Wl+oFmoMkp2T DrGbCeNe/P2xyDOLuUyb2vPN4qNzDqli4qZMMjnOZls5JIci2GtnS3E/FeU3y1x0zlyq y8fA== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=841OrZMFZjUeMhd1Fr3UX+5WgxHPibLLdBf0rvje3Oo=; b=RD+FziHxyY5R1WlnUjiqll6cUurxbGHdBl4/+RPM9eBA6SMRjl6x2ppIZtTYlzplhD DxKY02lcExr33i6Bmw4puAjnw+StmABgRGin6wOaD/gDYcy5XVrPfTELKovTc7PKEadu 3jph+ZhbUwxizoEx72HaL92Xd+2/2c0/CC9mmHixad85w8aSKCyhKcN6Ks4zQRmV5rVd HD9HuKo+get3PfdDHVs31YdROf9LH3pAyT5LqgO/fRHyDGbBla61UZjJ2dOS5Zk7GSd7 PvpkzjC6xLTCwVtFtxtk/idO/P06TZvfJLEI3NKMCiDSYdKfbj0W5jSd1MA5u3iXi+Zd Ad4A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=A8w8+mOg; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id hx26si4570187ejc.494.2021.07.22.21.03.26; Thu, 22 Jul 2021 21:03:49 -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=@kernel.org header.s=k20201202 header.b=A8w8+mOg; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235004AbhGWDUj (ORCPT + 99 others); Thu, 22 Jul 2021 23:20:39 -0400 Received: from mail.kernel.org ([198.145.29.99]:39900 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234235AbhGWDSi (ORCPT ); Thu, 22 Jul 2021 23:18:38 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 4A55460F26; Fri, 23 Jul 2021 03:59:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1627012752; bh=Jak8ZkmCLa0oz8T4zwIaW/iDvItCwLsURakycKZ58Cc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=A8w8+mOgmRKIa7TYrYGB94fU4sw4N3A/RSCjXN0O8jy8sYrnd/C6h4wzAOCPadR9q 4gN8Ks07TwVlmZHlOCr0C3EkWn4KQTphMI5EyXeA29MMU+wo9UZm03oD6Gih9q1dQO o/OHAT76lyaHjRV40DoKhqbPKn2e+YMFZTNiC/9c2XB3QZlIjsF2Sn7cdFMOmeLYsj 6NTPzjbRFPAn4nlbdg/i4vPcxBXadRtx2rOx2GW2YTc68/Nw/T1Sj1PSpJ+YBww3Yd NUAeVMIwnDW9coM643hAi2sBgg/MDg+ueR1UwXavUvPRMuvu0LrGvIdV96GfJh+m+0 m9ngD/IK3FQng== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Desmond Cheong Zhi Xi , Viacheslav Dubeyko , "Gustavo A . R . Silva" , Al Viro , Shuah Khan , Greg Kroah-Hartman , Andrew Morton , Linus Torvalds , Sasha Levin , linux-fsdevel@vger.kernel.org Subject: [PATCH AUTOSEL 4.9 4/7] hfs: add missing clean-up in hfs_fill_super Date: Thu, 22 Jul 2021 23:59:03 -0400 Message-Id: <20210723035906.532444-4-sashal@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210723035906.532444-1-sashal@kernel.org> References: <20210723035906.532444-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore 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