[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <tencent_E298974436464AA47527762F67923C3D3609@qq.com>
Date: Wed, 6 Nov 2024 17:58:07 +0800
From: Edward Adam Davis <eadavis@...com>
To: syzbot+968ecf5dc01b3e0148ec@...kaller.appspotmail.com
Cc: linux-fsdevel@...r.kernel.org,
linux-kernel@...r.kernel.org,
syzkaller-bugs@...glegroups.com
Subject: [PATCH] hfsplus: add check for cat key length
Syzbot reported a uninit-value in hfsplus_cat_bin_cmp_key.
The result of reading from the raw data of the node in hfs_bnode_read_u16()
is 0, and the final calculated catalog key length is 2, which will eventually
lead to too little key data read from the node to initialize the parent member
of struct hfsplus_cat_key.
The solution is to increase the key length judgment, and terminate the
subsequent operations if it is too small.
#syz test
Reported-by: syzbot+968ecf5dc01b3e0148ec@...kaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=968ecf5dc01b3e0148ec
Signed-off-by: Edward Adam Davis <eadavis@...com>
---
fs/hfsplus/brec.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/fs/hfsplus/brec.c b/fs/hfsplus/brec.c
index 1918544a7871..da38638ad808 100644
--- a/fs/hfsplus/brec.c
+++ b/fs/hfsplus/brec.c
@@ -51,6 +51,13 @@ u16 hfs_brec_keylen(struct hfs_bnode *node, u16 rec)
}
retval = hfs_bnode_read_u16(node, recoff) + 2;
+ if (node->tree->cnid == HFSPLUS_CAT_CNID &&
+ retval < offsetof(struct hfsplus_cat_key, parent) +
+ sizeof(hfsplus_cnid)) {
+ pr_err("keylen %d too small\n",
+ retval);
+ return 0;
+ }
if (retval > node->tree->max_key_len + 2) {
pr_err("keylen %d too large\n",
retval);
--
2.43.0
Powered by blists - more mailing lists