jfs : fix array-index-out-of-bounds in diWrite
PATCH 1/1 jfs : fix array-index-out-of-bounds in diWrite
Currently while copying dtree root from inode to dnode in the xp slot there is a out of bound memcpy. Added a bound check to the memcpy.
--- fs/jfs/jfs_imap.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
fs/jfs/jfs_imap.c +2 -1
@@ -746,7 +746,8 @@ int diWrite(tid_t tid, struct inode *ip) xp = (dtpage_t *) & dp->di_dtroot; lv = ilinelock->lv;for (n =0 ; n < ilinelock->index; n++, lv++) { -memcpy (&xp->slot[lv->offset], &p->slot[lv->offset], +if (lv->offset <128 ) +memcpy (&xp->slot[lv->offset], &p->slot[lv->offset], lv->length <<L2DTSLOTSIZE ); } }else {
Signature · 6 lines
2.37.2 _______________________________________________ Linux-kernel-mentees mailing list [email protected] https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees
Just a friendly ping :)
Quoted 15 lines · Manas Ghandat
Currently while copying dtree root from inode to dnode in the xp slot there is a out of bound memcpy. Added a bound check to the memcpy.
Reported-by [email protected]Signed-off-by Manas Ghandat <[email protected]>--- fs/jfs/jfs_imap.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)fs/jfs/jfs_imap.c +0
-0
fs/jfs/jfs_imap.c int diWrite(tid_t tid, struct inode *ip) · line 753
Quoted 9 lines
fs/jfs/jfs_imap.c +2
-1@@ -746,7 +746,8 @@ int diWrite(tid_t tid, struct inode *ip) xp = (dtpage_t *) & dp->di_dtroot; lv = ilinelock->lv;for (n =0 ; n < ilinelock->index; n++, lv++) { -memcpy (&xp->slot[lv->offset], &p->slot[lv->offset], +if (lv->offset <128 ) +memcpy (&xp->slot[lv->offset], &p->slot[lv->offset], lv->length <<L2DTSLOTSIZE ); } }else {
_______________________________________________
Linux-kernel-mentees mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees
Quoted 15 lines · Manas Ghandat
Currently while copying dtree root from inode to dnode in the xp slot there is a out of bound memcpy. Added a bound check to the memcpy.
Reported-by [email protected]Signed-off-by Manas Ghandat <[email protected]>--- fs/jfs/jfs_imap.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)fs/jfs/jfs_imap.c +0
-0
fs/jfs/jfs_imap.c int diWrite(tid_t tid, struct inode *ip) · line 749
Quoted 5 lines
fs/jfs/jfs_imap.c +1
-1@@ -746,7 +746,8 @@ int diWrite(tid_t tid, struct inode *ip) xp = (dtpage_t *) & dp->di_dtroot; lv = ilinelock->lv;for (n =0 ; n < ilinelock->index; n++, lv++) { - memcpy(&xp->slot[lv->offset], &p->slot[lv->offset], +if (lv->offset <128 )
I'd use DTPAGEMAXSLOT instead of hard-coding 128.
Also, we could at least set rc to -EIO, or we could do something more.
Calling jfs_error() would mark the superblock dirty and usually makes the file system read-only until it's fixed.
fs/jfs/jfs_imap.c int diWrite(tid_t tid, struct inode *ip) · line 753
Quoted 4 lines
fs/jfs/jfs_imap.c +1
-0+memcpy (&xp->slot[lv->offset], &p->slot[lv->offset], lv->length <<L2DTSLOTSIZE ); } }else {
_______________________________________________
Linux-kernel-mentees mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees