jfs: fix uninit-value read in BT_STACK_DUMP
PATCH 1/1 jfs: fix uninit-value read in BT_STACK_DUMP
From: Tristan Madani <[email protected]>
BT_STACK_DUMP() iterates over MAXTREEHEIGHT entries in the btstack regardless of how many entries were actually pushed. This reads uninitialized stack entries beyond the current depth.
Fix by computing the actual depth from btstack->top and limiting the loop to only initialized entries.
Reported-by [email protected]
Fixes 1da177e4c3f4 ("Linux-2.6.12-rc2")
Signed-off-by Tristan Madani <[email protected]>
--- fs/jfs/jfs_btree.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
fs/jfs/jfs_btree.h +3 -1
@@ -131,8 +131,10 @@ struct btstack {static inline void BT_STACK_DUMP (struct btstack *btstack) {int i; +int depth = btstack->top - btstack->stack; +printk ("btstack dump:\n" ); -for (i =0 ; i <MAXTREEHEIGHT ; i++) +for (i =0 ; i < depth; i++)printk (KERN_ERR "bn = %Lx, index = %d\n" , (long long )btstack->stack[i].bn, btstack->stack[i].index);
Signature · 1 line
2.47.3