mm-commits.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: akpm@linux-foundation.org, desmondcheongzx@gmail.com,
	gregkh@linuxfoundation.org, gustavoars@kernel.org,
	linux-mm@kvack.org, mm-commits@vger.kernel.org,
	skhan@linuxfoundation.org, slava@dubeyko.com,
	torvalds@linux-foundation.org, viro@zeniv.linux.org.uk
Subject: [patch 10/13] hfs: add missing clean-up in hfs_fill_super
Date: Wed, 14 Jul 2021 21:27:01 -0700	[thread overview]
Message-ID: <20210715042701.RIM_Afm8q%akpm@linux-foundation.org> (raw)
In-Reply-To: <20210714212609.fad116e584ba1194981a6294@linux-foundation.org>

From: Desmond Cheong Zhi Xi <desmondcheongzx@gmail.com>
Subject: hfs: add missing clean-up in hfs_fill_super

Patch series "hfs: fix various errors", v2.

This series ultimately aims to address a lockdep warning in hfs_find_init
reported by Syzbot:
https://syzkaller.appspot.com/bug?id=f007ef1d7a31a469e3be7aeb0fde0769b18585db

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://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 <desmondcheongzx@gmail.com>
Reviewed-by: Viacheslav Dubeyko <slava@dubeyko.com>
Cc: Gustavo A. R. Silva <gustavoars@kernel.org>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Cc: Shuah Khan <skhan@linuxfoundation.org>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---

 fs/hfs/super.c |   10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

--- a/fs/hfs/super.c~hfs-add-missing-clean-up-in-hfs_fill_super
+++ a/fs/hfs/super.c
@@ -420,14 +420,12 @@ static int hfs_fill_super(struct super_b
 	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);
@@ -443,6 +441,8 @@ static int hfs_fill_super(struct super_b
 	/* everything's okay */
 	return 0;
 
+bail_hfs_find:
+	hfs_find_exit(&fd);
 bail_no_root:
 	pr_err("get root inode failed\n");
 bail:
_

  parent reply	other threads:[~2021-07-15  4:27 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-15  4:26 incoming Andrew Morton
2021-07-15  4:26 ` [patch 01/13] mm: move helper to check slub_debug_enabled Andrew Morton
2021-07-15  4:26 ` [patch 02/13] kasan: add memzero init for unaligned size at DEBUG Andrew Morton
2021-07-15  4:26 ` [patch 03/13] kasan: fix build by including kernel.h Andrew Morton
2021-07-15  4:26 ` [patch 04/13] Revert "mm/page_alloc: make should_fail_alloc_page() static" Andrew Morton
2021-07-15  4:26 ` [patch 05/13] mm/page_alloc: avoid page allocator recursion with pagesets.lock held Andrew Morton
2021-07-15  4:26 ` [patch 06/13] mm/page_alloc: correct return value when failing at preparing Andrew Morton
2021-07-15  4:26 ` [patch 07/13] mm/page_alloc: further fix __alloc_pages_bulk() return value Andrew Morton
2021-07-15  4:26 ` [patch 08/13] mm: fix the try_to_unmap prototype for !CONFIG_MMU Andrew Morton
2021-07-15  4:26 ` [patch 09/13] lib/test_hmm: remove set but unused page variable Andrew Morton
2021-07-15  4:27 ` Andrew Morton [this message]
2021-07-15  4:27 ` [patch 11/13] hfs: fix high memory mapping in hfs_bnode_read Andrew Morton
2021-07-15  4:27 ` [patch 12/13] hfs: add lock nesting notation to hfs_find_init Andrew Morton
2021-07-15  4:27 ` [patch 13/13] mm/hugetlb: fix refs calculation from unaligned @vaddr Andrew Morton

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210715042701.RIM_Afm8q%akpm@linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --cc=desmondcheongzx@gmail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=gustavoars@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mm-commits@vger.kernel.org \
    --cc=skhan@linuxfoundation.org \
    --cc=slava@dubeyko.com \
    --cc=torvalds@linux-foundation.org \
    --cc=viro@zeniv.linux.org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).