提交 d144ac3c 编写于 作者: D Desmond Cheong Zhi Xi 提交者: Yang Yingliang

hfs: add missing clean-up in hfs_fill_super

stable inclusion
from linux-4.19.200
commit 04c6a7861ab5ff620eec60a6d08f4c73cef7653e

--------------------------------

[ Upstream commit 16ee572e ]

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.comSigned-off-by: NDesmond Cheong Zhi Xi <desmondcheongzx@gmail.com>
Reviewed-by: NViacheslav 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: NAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: NSasha Levin <sashal@kernel.org>
Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
上级 b1e93aab
...@@ -427,14 +427,12 @@ static int hfs_fill_super(struct super_block *sb, void *data, int silent) ...@@ -427,14 +427,12 @@ static int hfs_fill_super(struct super_block *sb, void *data, int silent)
if (!res) { if (!res) {
if (fd.entrylength > sizeof(rec) || fd.entrylength < 0) { if (fd.entrylength > sizeof(rec) || fd.entrylength < 0) {
res = -EIO; res = -EIO;
goto bail; goto bail_hfs_find;
} }
hfs_bnode_read(fd.bnode, &rec, fd.entryoffset, fd.entrylength); hfs_bnode_read(fd.bnode, &rec, fd.entryoffset, fd.entrylength);
} }
if (res) { if (res)
hfs_find_exit(&fd); goto bail_hfs_find;
goto bail_no_root;
}
res = -EINVAL; res = -EINVAL;
root_inode = hfs_iget(sb, &fd.search_key->cat, &rec); root_inode = hfs_iget(sb, &fd.search_key->cat, &rec);
hfs_find_exit(&fd); hfs_find_exit(&fd);
...@@ -450,6 +448,8 @@ static int hfs_fill_super(struct super_block *sb, void *data, int silent) ...@@ -450,6 +448,8 @@ static int hfs_fill_super(struct super_block *sb, void *data, int silent)
/* everything's okay */ /* everything's okay */
return 0; return 0;
bail_hfs_find:
hfs_find_exit(&fd);
bail_no_root: bail_no_root:
pr_err("get root inode failed\n"); pr_err("get root inode failed\n");
bail: bail:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册