jfs: Add check for array bounds in dtDelete
PATCH 1/1 jfs: Add check for array bounds in dtDelete
stbl is s8 but it must contain offsets into slot which can go from 0 to 127.
Add a bound check for that error inside dtDelete function.
Reported-by [email protected]
Signed-off-by Pedro Demarchi Gomes <[email protected]>
--- fs/jfs/jfs_dtree.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-)
fs/jfs/jfs_dtree.c +11 -5
@@ -2129,11 +2129,17 @@ int dtDelete(tid_t tid, next_index =-1 ; else { stbl =DT_GETSTBL (np); - ldtentry = - (struct ldtentry *) & np-> - slot[stbl[0 ]]; - next_index = -le32_to_cpu (ldtentry->index); +if (stbl[0 ] <0 || stbl[0 ] >=DTPAGEMAXSLOT ) { +jfs_err ("JFS: Invalid stbl[0] = %d for inode %ld, block = %lld" , + stbl[0 ], (long )ip->i_ino, (long long )le64_to_cpu (p->header.next)); + next_index =-1 ; + }else { + ldtentry = + (struct ldtentry *) & np-> + slot[stbl[0 ]]; + next_index = +le32_to_cpu (ldtentry->index); + }DT_PUTPAGE (nmp); } }
Signature · 1 line
2.39.5