Skip to content

Commit 16ee572

Browse files
desmondcheongzxtorvalds
authored andcommitted
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 [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/[email protected] Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: Desmond Cheong Zhi Xi <[email protected]> Reviewed-by: Viacheslav Dubeyko <[email protected]> Cc: Gustavo A. R. Silva <[email protected]> Cc: Al Viro <[email protected]> Cc: Shuah Khan <[email protected]> Cc: Greg Kroah-Hartman <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent c52114d commit 16ee572

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

fs/hfs/super.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -420,14 +420,12 @@ static int hfs_fill_super(struct super_block *sb, void *data, int silent)
420420
if (!res) {
421421
if (fd.entrylength > sizeof(rec) || fd.entrylength < 0) {
422422
res = -EIO;
423-
goto bail;
423+
goto bail_hfs_find;
424424
}
425425
hfs_bnode_read(fd.bnode, &rec, fd.entryoffset, fd.entrylength);
426426
}
427-
if (res) {
428-
hfs_find_exit(&fd);
429-
goto bail_no_root;
430-
}
427+
if (res)
428+
goto bail_hfs_find;
431429
res = -EINVAL;
432430
root_inode = hfs_iget(sb, &fd.search_key->cat, &rec);
433431
hfs_find_exit(&fd);
@@ -443,6 +441,8 @@ static int hfs_fill_super(struct super_block *sb, void *data, int silent)
443441
/* everything's okay */
444442
return 0;
445443

444+
bail_hfs_find:
445+
hfs_find_exit(&fd);
446446
bail_no_root:
447447
pr_err("get root inode failed\n");
448448
bail:

0 commit comments

Comments
 (0)