* [PATCH] jfs : fix array-index-out-of-bounds in diWrite
@ 2023-10-08 17:47 Manas Ghandat
2023-10-16 15:01 ` Manas Ghandat
2023-11-01 15:04 ` Dave Kleikamp
0 siblings, 2 replies; 3+ messages in thread
From: Manas Ghandat @ 2023-10-08 17:47 UTC (permalink / raw)
To: dave.kleikamp, shaggy
Cc: Manas Ghandat, Linux-kernel-mentees, jfs-discussion, linux-kernel,
syzbot+c1056fdfe414463fdb33
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: syzbot+c1056fdfe414463fdb33@syzkaller.appspotmail.com
Fixes: https://syzkaller.appspot.com/bug?extid=c1056fdfe414463fdb33
Signed-off-by: Manas Ghandat <ghandatmanas@gmail.com>
---
fs/jfs/jfs_imap.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/fs/jfs/jfs_imap.c b/fs/jfs/jfs_imap.c
index 799d3837e7c2..d1f897848be0 100644
--- a/fs/jfs/jfs_imap.c
+++ b/fs/jfs/jfs_imap.c
@@ -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 {
--
2.37.2
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] jfs : fix array-index-out-of-bounds in diWrite
2023-10-08 17:47 [PATCH] jfs : fix array-index-out-of-bounds in diWrite Manas Ghandat
@ 2023-10-16 15:01 ` Manas Ghandat
2023-11-01 15:04 ` Dave Kleikamp
1 sibling, 0 replies; 3+ messages in thread
From: Manas Ghandat @ 2023-10-16 15:01 UTC (permalink / raw)
To: dave.kleikamp, shaggy
Cc: Linux-kernel-mentees, jfs-discussion, linux-kernel,
syzbot+c1056fdfe414463fdb33
Just a friendly ping :)
On 08/10/23 23:17, Manas Ghandat wrote:
> 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: syzbot+c1056fdfe414463fdb33@syzkaller.appspotmail.com
> Fixes: https://syzkaller.appspot.com/bug?extid=c1056fdfe414463fdb33
> Signed-off-by: Manas Ghandat <ghandatmanas@gmail.com>
> ---
> fs/jfs/jfs_imap.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/fs/jfs/jfs_imap.c b/fs/jfs/jfs_imap.c
> index 799d3837e7c2..d1f897848be0 100644
> --- a/fs/jfs/jfs_imap.c
> +++ b/fs/jfs/jfs_imap.c
> @@ -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 {
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] jfs : fix array-index-out-of-bounds in diWrite
2023-10-08 17:47 [PATCH] jfs : fix array-index-out-of-bounds in diWrite Manas Ghandat
2023-10-16 15:01 ` Manas Ghandat
@ 2023-11-01 15:04 ` Dave Kleikamp
1 sibling, 0 replies; 3+ messages in thread
From: Dave Kleikamp @ 2023-11-01 15:04 UTC (permalink / raw)
To: Manas Ghandat, shaggy
Cc: Linux-kernel-mentees, jfs-discussion, linux-kernel,
syzbot+c1056fdfe414463fdb33
On 10/8/23 12:47PM, Manas Ghandat wrote:
> 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: syzbot+c1056fdfe414463fdb33@syzkaller.appspotmail.com
> Fixes: https://syzkaller.appspot.com/bug?extid=c1056fdfe414463fdb33
> Signed-off-by: Manas Ghandat <ghandatmanas@gmail.com>
> ---
> fs/jfs/jfs_imap.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/fs/jfs/jfs_imap.c b/fs/jfs/jfs_imap.c
> index 799d3837e7c2..d1f897848be0 100644
> --- a/fs/jfs/jfs_imap.c
> +++ b/fs/jfs/jfs_imap.c
> @@ -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.
> + memcpy(&xp->slot[lv->offset], &p->slot[lv->offset],
> lv->length << L2DTSLOTSIZE);
> }
> } else {
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-11-01 15:06 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-10-08 17:47 [PATCH] jfs : fix array-index-out-of-bounds in diWrite Manas Ghandat
2023-10-16 15:01 ` Manas Ghandat
2023-11-01 15:04 ` Dave Kleikamp
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox