* [PATCH] dtInsertEntry can result in buffer overflow on corrupted jfs filesystems
@ 2025-10-28 23:23 Jori Koolstra
2025-11-18 16:46 ` Jori Koolstra
0 siblings, 1 reply; 5+ messages in thread
From: Jori Koolstra @ 2025-10-28 23:23 UTC (permalink / raw)
To: Dave Kleikamp, Jeff Layton, Christian Brauner,
Gabriel Krisman Bertazi, NeilBrown, Al Viro
Cc: jfs-discussion, linux-kernel, jkoolstra, syzbot+cd7590567cc388f064f3
Syzbot reported a general protection fault in inode_set_ctime_current.
This resulted from the following circumstances: when creating a new file
via dtInsert, BT_GETSEARCH may yield a pointer to a dtroot which is
embedded directly in the jfs_inode_info. When finally dtInsertEntry is
called, if the freelist field or any next field of a slot of the dtpage
is corrupted, this may result in memory corruption of the parent
directory inode.
In this case the i_sb field was corrupted, which raised the gpf when
in inode_set_ctime_current i_sb was dereferenced to access s_time_gran.
I tested the patch using the syzbot reproducer and doing some basic
filesystem operations on a fresh jfs fs, such as "cp -r /usr/include/
/mnt/jfs/" and "rm -r /mnt/jfs/include/n*"
Signed-off-by: Jori Koolstra <jkoolstra@xs4all.nl>
Reported-by: syzbot+cd7590567cc388f064f3@syzkaller.appspotmail.com
Closes: https://syzbot.org/bug?extid=cd7590567cc388f064f3
---
fs/jfs/jfs_dtree.c | 22 +++++++++++++++++-----
1 file changed, 17 insertions(+), 5 deletions(-)
diff --git a/fs/jfs/jfs_dtree.c b/fs/jfs/jfs_dtree.c
index 0ab83bb7bbdf..e37278596afe 100644
--- a/fs/jfs/jfs_dtree.c
+++ b/fs/jfs/jfs_dtree.c
@@ -170,8 +170,8 @@ static void dtGetKey(dtpage_t * p, int i, struct component_name * key,
static int ciGetLeafPrefixKey(dtpage_t * lp, int li, dtpage_t * rp,
int ri, struct component_name * key, int flag);
-static void dtInsertEntry(dtpage_t * p, int index, struct component_name * key,
- ddata_t * data, struct dt_lock **);
+static int dtInsertEntry(dtpage_t * p, int index, struct component_name * key,
+ ddata_t * data, struct dt_lock **);
static void dtMoveEntry(dtpage_t * sp, int si, dtpage_t * dp,
struct dt_lock ** sdtlock, struct dt_lock ** ddtlock,
@@ -891,7 +891,8 @@ int dtInsert(tid_t tid, struct inode *ip,
lv->length = 1;
dtlck->index++;
- dtInsertEntry(p, index, name, &data, &dtlck);
+ if ((rc = dtInsertEntry(p, index, name, &data, &dtlck)))
+ return rc;
/* linelock stbl of non-root leaf page */
if (!(p->header.flag & BT_ROOT)) {
@@ -3625,9 +3626,10 @@ static void dtGetKey(dtpage_t * p, int i, /* entry index */
* function: allocate free slot(s) and
* write a leaf/internal entry
*
- * return: entry slot index
+ * * return: 0 - success;
+ * errno - failure;
*/
-static void dtInsertEntry(dtpage_t * p, int index, struct component_name * key,
+static int dtInsertEntry(dtpage_t * p, int index, struct component_name * key,
ddata_t * data, struct dt_lock ** dtlock)
{
struct dtslot *h, *t;
@@ -3649,6 +3651,10 @@ static void dtInsertEntry(dtpage_t * p, int index, struct component_name * key,
/* allocate a free slot */
hsi = fsi = p->header.freelist;
+ if (fsi >= ((p->header.flag & BT_ROOT) ? DTROOTMAXSLOT : p->header.maxslot)) {
+ jfs_err("Encountered corrupted dtpage before insert");
+ return -EIO;
+ }
h = &p->slot[fsi];
p->header.freelist = h->next;
--p->header.freecnt;
@@ -3697,6 +3703,10 @@ static void dtInsertEntry(dtpage_t * p, int index, struct component_name * key,
while (klen) {
/* get free slot */
fsi = p->header.freelist;
+ if (fsi >= ((p->header.flag & BT_ROOT) ? DTROOTMAXSLOT : p->header.maxslot)) {
+ jfs_err("Encountered corrupted dtpage before insert");
+ return -EIO;
+ }
t = &p->slot[fsi];
p->header.freelist = t->next;
--p->header.freecnt;
@@ -3774,6 +3784,8 @@ static void dtInsertEntry(dtpage_t * p, int index, struct component_name * key,
/* advance next available entry index of stbl */
++p->header.nextindex;
+
+ return 0;
}
--
2.51.1.dirty
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH] dtInsertEntry can result in buffer overflow on corrupted jfs filesystems
2025-10-28 23:23 [PATCH] dtInsertEntry can result in buffer overflow on corrupted jfs filesystems Jori Koolstra
@ 2025-11-18 16:46 ` Jori Koolstra
2025-12-01 13:20 ` [PATCH] jfs: " Jori Koolstra
0 siblings, 1 reply; 5+ messages in thread
From: Jori Koolstra @ 2025-11-18 16:46 UTC (permalink / raw)
To: brauner, gabriel, jlayton, neil, shaggy, viro
Cc: jkoolstra, jfs-discussion, linux-kernel,
syzbot+cd7590567cc388f064f3, skhan
Below syzbot bug has not been fixed yet. If anyone has time I would
greatly appreciate a review of my patch, so it can be moved along.
It has been sitting for a few weeks.
Thanks,
Jori.
Apologies for the resend, I messed up the email headers.
> Op 29-10-2025 00:23 CET schreef Jori Koolstra <jkoolstra@xs4all.nl>:
>
>
> Syzbot reported a general protection fault in inode_set_ctime_current.
> This resulted from the following circumstances: when creating a new file
> via dtInsert, BT_GETSEARCH may yield a pointer to a dtroot which is
> embedded directly in the jfs_inode_info. When finally dtInsertEntry is
> called, if the freelist field or any next field of a slot of the dtpage
> is corrupted, this may result in memory corruption of the parent
> directory inode.
>
> In this case the i_sb field was corrupted, which raised the gpf when
> in inode_set_ctime_current i_sb was dereferenced to access s_time_gran.
>
> I tested the patch using the syzbot reproducer and doing some basic
> filesystem operations on a fresh jfs fs, such as "cp -r /usr/include/
> /mnt/jfs/" and "rm -r /mnt/jfs/include/n*"
>
> Signed-off-by: Jori Koolstra <jkoolstra@xs4all.nl>
> Reported-by: syzbot+cd7590567cc388f064f3@syzkaller.appspotmail.com
> Closes: https://syzbot.org/bug?extid=cd7590567cc388f064f3
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH] jfs: dtInsertEntry can result in buffer overflow on corrupted jfs filesystems
2025-11-18 16:46 ` Jori Koolstra
@ 2025-12-01 13:20 ` Jori Koolstra
2025-12-01 22:35 ` Dave Kleikamp
0 siblings, 1 reply; 5+ messages in thread
From: Jori Koolstra @ 2025-12-01 13:20 UTC (permalink / raw)
To: brauner, gabriel, jlayton, neil, shaggy, viro
Cc: jfs-discussion, linux-kernel, syzbot+cd7590567cc388f064f3, skhan
Below syzbot bug has not been fixed yet. If anyone has time I would
greatly appreciate a review of my patch, so it can be moved along.
It has been sitting for quite a few weeks.
Thanks,
Jori.
> Op 29-10-2025 00:23 CET schreef Jori Koolstra <jkoolstra@xs4all.nl>:
>
>
> Syzbot reported a general protection fault in inode_set_ctime_current.
> This resulted from the following circumstances: when creating a new file
> via dtInsert, BT_GETSEARCH may yield a pointer to a dtroot which is
> embedded directly in the jfs_inode_info. When finally dtInsertEntry is
> called, if the freelist field or any next field of a slot of the dtpage
> is corrupted, this may result in memory corruption of the parent
> directory inode.
>
> In this case the i_sb field was corrupted, which raised the gpf when
> in inode_set_ctime_current i_sb was dereferenced to access s_time_gran.
>
> I tested the patch using the syzbot reproducer and doing some basic
> filesystem operations on a fresh jfs fs, such as "cp -r /usr/include/
> /mnt/jfs/" and "rm -r /mnt/jfs/include/n*"
>
> Signed-off-by: Jori Koolstra <jkoolstra@xs4all.nl>
> Reported-by: syzbot+cd7590567cc388f064f3@syzkaller.appspotmail.com
> Closes: https://syzbot.org/bug?extid=cd7590567cc388f064f3
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] jfs: dtInsertEntry can result in buffer overflow on corrupted jfs filesystems
2025-12-01 13:20 ` [PATCH] jfs: " Jori Koolstra
@ 2025-12-01 22:35 ` Dave Kleikamp
2025-12-16 16:04 ` Jori Koolstra
0 siblings, 1 reply; 5+ messages in thread
From: Dave Kleikamp @ 2025-12-01 22:35 UTC (permalink / raw)
To: Jori Koolstra, brauner, gabriel, jlayton, neil, viro
Cc: jfs-discussion, linux-kernel, syzbot+cd7590567cc388f064f3, skhan
On 12/1/25 7:20AM, Jori Koolstra wrote:
> Below syzbot bug has not been fixed yet. If anyone has time I would
> greatly appreciate a review of my patch, so it can be moved along.
> It has been sitting for quite a few weeks.
I've been busy with some other work as well as being out on vacation
lately. I have several patches to review, but have not forgotten this.
I'll try to get to it later this week.
Thanks,
Shaggy
>
> Thanks,
> Jori.
>
>> Op 29-10-2025 00:23 CET schreef Jori Koolstra <jkoolstra@xs4all.nl>:
>>
>>
>> Syzbot reported a general protection fault in inode_set_ctime_current.
>> This resulted from the following circumstances: when creating a new file
>> via dtInsert, BT_GETSEARCH may yield a pointer to a dtroot which is
>> embedded directly in the jfs_inode_info. When finally dtInsertEntry is
>> called, if the freelist field or any next field of a slot of the dtpage
>> is corrupted, this may result in memory corruption of the parent
>> directory inode.
>>
>> In this case the i_sb field was corrupted, which raised the gpf when
>> in inode_set_ctime_current i_sb was dereferenced to access s_time_gran.
>>
>> I tested the patch using the syzbot reproducer and doing some basic
>> filesystem operations on a fresh jfs fs, such as "cp -r /usr/include/
>> /mnt/jfs/" and "rm -r /mnt/jfs/include/n*"
>>
>> Signed-off-by: Jori Koolstra <jkoolstra@xs4all.nl>
>> Reported-by: syzbot+cd7590567cc388f064f3@syzkaller.appspotmail.com
>> Closes: https://syzbot.org/bug?extid=cd7590567cc388f064f3
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] jfs: dtInsertEntry can result in buffer overflow on corrupted jfs filesystems
2025-12-01 22:35 ` Dave Kleikamp
@ 2025-12-16 16:04 ` Jori Koolstra
0 siblings, 0 replies; 5+ messages in thread
From: Jori Koolstra @ 2025-12-16 16:04 UTC (permalink / raw)
To: Dave Kleikamp, brauner, gabriel, jlayton, neil, viro
Cc: jfs-discussion, linux-kernel, syzbot+cd7590567cc388f064f3, skhan
Hello David,
Thanks for the update. I hope you can get to it soon, but I understand you
are busy. I am doing the Linux Kernel Mentorship Program, and trying to get
my patches in. Hope you don't mind the occasional reminder.
> Op 01-12-2025 23:35 CET schreef Dave Kleikamp <dave.kleikamp@oracle.com>:
>
>
> On 12/1/25 7:20AM, Jori Koolstra wrote:
> > Below syzbot bug has not been fixed yet. If anyone has time I would
> > greatly appreciate a review of my patch, so it can be moved along.
> > It has been sitting for quite a few weeks.
>
> I've been busy with some other work as well as being out on vacation
> lately. I have several patches to review, but have not forgotten this.
> I'll try to get to it later this week.
>
> Thanks,
> Shaggy
>
Thanks,
Jori.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2025-12-16 16:05 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-10-28 23:23 [PATCH] dtInsertEntry can result in buffer overflow on corrupted jfs filesystems Jori Koolstra
2025-11-18 16:46 ` Jori Koolstra
2025-12-01 13:20 ` [PATCH] jfs: " Jori Koolstra
2025-12-01 22:35 ` Dave Kleikamp
2025-12-16 16:04 ` Jori Koolstra
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®