hfs, hfsplus: remove WARN_ON when new bnode already hashed
Subsystems (3)
PATCH 1/1 hfs, hfsplus: remove WARN_ON when new bnode already hashed
From: Aditya Prakash Srivastava <[email protected]>
Syzbot reported a warning in hfsplus_bnode_create() when mounting and traversing a fuzzed/corrupted disk image.
The warning is triggered because the node index is found to be already active and hashed in the btree hash table, which indicates on-disk metadata corruption.
Filesystem corruption should be handled gracefully by returning an error and logging a message, rather than triggering kernel-level warnings (which can panic the system under panic_on_warn=1 configurations). The code already prints a critical message and returns -EEXIST (or the node in hfs), so the WARN_ON() is completely redundant and dangerous.
Remove the WARN_ON(1) from both hfs_bnode_create() and hfsplus_bnode_create().
--- fs/hfs/bnode.c | 1 - fs/hfsplus/bnode.c | 1 - 2 files changed, 2 deletions(-)
fs/hfs/bnode.c +0 -1
@@ -517,7 +517,6 @@ struct hfs_bnode *hfs_bnode_create(struct hfs_btree *tree, u32 num)spin_unlock (&tree->hash_lock);if (node) {pr_crit ("new node %u already hashed?\n" , num); -WARN_ON (1 );return node; } node =__hfs_bnode_create (tree, num);
fs/hfsplus/bnode.c +0 -1
@@ -631,7 +631,6 @@ struct hfs_bnode *hfs_bnode_create(struct hfs_btree *tree, u32 num)spin_unlock (&tree->hash_lock);if (node) {pr_crit ("new node %u already hashed?\n" , num); -WARN_ON (1 );return ERR_PTR (-EEXIST ); } node =__hfs_bnode_create (tree, num);
Signature · 1 line
2.47.3
Viacheslav Dubeyko
maintainerQuoted 55 lines · Aditya Srivastava
From: Aditya Prakash Srivastava <[email protected]>
Syzbot reported a warning in
hfsplus_bnode_create()when mounting and traversing a fuzzed/corrupted disk image.The warning is triggered because the node index is found to be already
active and hashed in the btree hash table, which indicates on-disk metadata corruption.Filesystem corruption should be handled gracefully by returning an error
and logging a message, rather than triggering kernel-level warnings (which can panic the system under panic_on_warn=1 configurations). The code already prints a critical message and returns-EEXIST(or the
node in hfs), so theWARN_ON()is completely redundant and dangerous.Remove the
WARN_ON(1)from bothhfs_bnode_create()andhfsplus_bnode_create().Reported-by [email protected]Fixes 1da177e4c3f4 ("Linux-2.6.12-rc2")Signed-off-by Aditya Prakash Srivastava <[email protected]>---
fs/hfs/bnode.c | 1 -
fs/hfsplus/bnode.c | 1 -2 files changed, 2 deletions(-)fs/hfs/bnode.c +0
-1@@ -517,7 +517,6 @@ struct hfs_bnode *hfs_bnode_create(struct hfs_btree *tree, u32 num) spin_unlock(&tree->hash_lock); if (node) { pr_crit("new node %u already hashed?\n", num); -WARN_ON (1 ); return node; }node =
__hfs_bnode_create(tree, num);fs/hfsplus/bnode.c +0
-1@@ -631,7 +631,6 @@ struct hfs_bnode *hfs_bnode_create(struct hfs_btree *tree, u32 num) spin_unlock(&tree->hash_lock); if (node) { pr_crit("new node %u already hashed?\n", num); -WARN_ON (1 ); return ERR_PTR(-EEXIST); }
Quoted 1 line
node =
__hfs_bnode_create(tree, num);
If we have corrupted HFS/HFS+ volume and we can detect it during the mount operation, then we should not mount the corrupted volume or mount in READ-ONLY mode. As I remember, we already have HFS+ logic that detects b-tree's map corruption for the case of node 0. We haven't this logic for HFS file system logic yet, if I remember correctly. So, you are welcomed to port this logic for HFS case. Removing WARN_ON() simply hides the potential issues. So, I don't think that we need to remove it.
Thanks,
Slava.