jfs: fix array-index-out-of-bounds in dtInsertEntry
PATCH 1/1 jfs: fix array-index-out-of-bounds in dtInsertEntry
The value of p->header.freelist can be less than zero which causes an error in dtInsertEntry. Added a check in dtInsert to address it.
--- fs/jfs/jfs_dtree.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/jfs/jfs_dtree.c +1 -1
@@ -834,7 +834,7 @@ int dtInsert(tid_t tid, struct inode *ip,* the full page. */ DT_GETSEARCH (ip, btstack->top, bn, mp, p, index); -if (p->header.freelist ==0 ) +if (p->header.freelist <=0 )return -EINVAL ;/*
Signature · 1 line
2.34.1
Quoted 7 lines · Ghanshyam Agrawal
The value of
p->header.freelistcan be less than zero which causes an error in dtInsertEntry. Added a check in dtInsert to address it.Reported-by [email protected]Signed-off-by Ghanshyam Agrawal <[email protected]>
Looks good. I'll apply this one.
Quoted 17 lines
--- fs/jfs/jfs_dtree.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)fs/jfs/jfs_dtree.c +1
-1@@ -834,7 +834,7 @@ int dtInsert(tid_t tid, struct inode *ip,* the full page. */ DT_GETSEARCH (ip, btstack->top, bn, mp, p, index); -if (p->header.freelist ==0 ) +if (p->header.freelist <=0 )return -EINVAL ;/*
Quoted 10 lines · Dave Kleikamp
Quoted 7 lines · Ghanshyam Agrawal
The value of
p->header.freelistcan be less than zero which causes an error in dtInsertEntry. Added a check in dtInsert to address it.Reported-by [email protected]Signed-off-by Ghanshyam Agrawal <[email protected]>Looks good. I'll apply this one.
Unapplying it. This caused regressions running xfstests. I'll need to look into it more carefully.
Shaggy
Quoted 17 lines
Quoted 17 lines
---
fs/jfs/jfs_dtree.c| 2 +-1 file changed, 1 insertion(+), 1 deletion(-)fs/jfs/jfs_dtree.c +1
-1@@ -834,7 +834,7 @@ int dtInsert(tid_t tid, struct inode *ip,* the full page. */ DT_GETSEARCH(ip, btstack->top, bn, mp, p, index); - if (p->header.freelist == 0) + if (p->header.freelist <= 0) return -EINVAL; /*
Quoted 23 lines · Dave Kleikamp
Quoted 10 lines · Dave Kleikamp
Quoted 7 lines · Ghanshyam Agrawal
The value of
p->header.freelistcan be less than zero which causes an error in dtInsertEntry. Added a check in dtInsert to address it.Reported-by [email protected]Signed-off-by Ghanshyam Agrawal <[email protected]>Looks good. I'll apply this one.
Unapplying it. This caused regressions running xfstests. I'll need to look into it more carefully.
Shaggy
Quoted 5 lines
Quoted 5 lines
--- fs/jfs/jfs_dtree.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 13 lines
Quoted 4 lines
Quoted 4 lines
fs/jfs/jfs_dtree.c +0
-0Quoted 8 lines
fs/jfs/jfs_dtree.c int dtInsert(tid_t tid, struct inode *ip, · line 839
Quoted 8 lines
fs/jfs/jfs_dtree.c +1
-1@@ -834,7 +834,7 @@ int dtInsert(tid_t tid, struct inode *ip,* the full page. */ DT_GETSEARCH (ip, btstack->top, bn, mp, p, index); -if (p->header.freelist ==0 ) +if (p->header.freelist <=0 )return -EINVAL ;/*
Hello Dave,
Thank you for reviewing and testing my patch. Let me go through the xfstests results, find the issue and send a v2 for this patch.
Thanks & Regards,
Ghanshyam Agrawal