Skip to contentSkip to conversation

jfs: Initialize synclist in metapage allocation

PATCH Superseded [email protected] 2 participants 4 messages Nov 8, 2025 – Dec 1, 2025 JFS filesystem

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 jfs: Initialize synclist in metapage allocation

From: Shaurya Rane <[email protected]>

The synclist field in struct metapage was not being initialized during allocation in alloc_metapage(), leading to list corruption when the metapage is later added to a transaction's sync list.

When diUpdatePMap() calls list_add(&mp->synclist, &tblk->synclist), if the synclist field contains stale data from a previous allocation (such as LIST_POISON values from a freed list node), the list debugging code detects the corruption and triggers a stack segment fault.

This issue is intermittent because it only manifests when recycled memory happens to contain poison values in the synclist field. The bug was discovered by syzbot, which creates specific filesystem patterns that reliably trigger this uninitialized memory usage.

Initialize the synclist field with INIT_LIST_HEAD() in alloc_metapage() to ensure it's in a valid state before being used in list operations. This is consistent with how the wait queue is initialized in the same function.

---
Tested:
- Tested locally with syzbot reproducer, no errors observed
Changelog:
- Correct bug link
- Corrected patch format

 fs/jfs/jfs_metapage.c | 1 +
 1 file changed, 1 insertion(+)
fs/jfs/jfs_metapage.c +1 -0
index 871cf4fb3636..77c512a0a42b 100644
@@ -269,6 +269,7 @@ static inline struct metapage *alloc_metapage(gfp_t gfp_mask)
 		mp->data = NULL;
 		mp->clsn = 0;
 		mp->log = NULL;
+		INIT_LIST_HEAD(&mp->synclist);
 		init_waitqueue_head(&mp->wait);
 	}
 	return mp;
Signature · 1 line
2.34.1
#1 lore raw

PATCH v3 1/1 jfs: Initialize synclist in metapage allocation

From: Shaurya Rane <[email protected]>

The synclist field in struct metapage was not being initialized during allocation in alloc_metapage(), leading to list corruption when the metapage is later added to a transaction's sync list.

When diUpdatePMap() calls list_add(&mp->synclist, &tblk->synclist), if the synclist field contains stale data from a previous allocation (such as LIST_POISON values from a freed list node), the list debugging code detects the corruption and triggers a stack segment fault.

This issue is intermittent because it only manifests when recycled memory happens to contain poison values in the synclist field. The bug was discovered by syzbot, which creates specific filesystem patterns that reliably trigger this uninitialized memory usage.

Initialize the synclist field with INIT_LIST_HEAD() in alloc_metapage() to ensure it's in a valid state before being used in list operations. This is consistent with how the wait queue is initialized in the same function.

---
Tested:
- Tested locally with syzbot reproducer, no errors observed
Changelog:
- Correct bug link
- Corrected patch format

 fs/jfs/jfs_metapage.c | 1 +
 1 file changed, 1 insertion(+)
fs/jfs/jfs_metapage.c +1 -0
index 871cf4fb3636..77c512a0a42b 100644
@@ -269,6 +269,7 @@ static inline struct metapage *alloc_metapage(gfp_t gfp_mask)
 		mp->data = NULL;
 		mp->clsn = 0;
 		mp->log = NULL;
+		INIT_LIST_HEAD(&mp->synclist);
 		init_waitqueue_head(&mp->wait);
 	}
 	return mp;
Signature · 1 line
2.34.1
#2 lore raw

Pinging if missed

Quoted 51 lines · On Sat, Nov 8, 2025 at 7:48 PM <[email protected]> wrote:

From: Shaurya Rane <[email protected]>

The synclist field in struct metapage was not being initialized during allocation in alloc_metapage(), leading to list corruption when the metapage is later added to a transaction's sync list.

When diUpdatePMap() calls list_add(&mp->synclist, &tblk->synclist), if the synclist field contains stale data from a previous allocation (such as LIST_POISON values from a freed list node), the list debugging code detects the corruption and triggers a stack segment fault.

This issue is intermittent because it only manifests when recycled memory happens to contain poison values in the synclist field. The bug was discovered by syzbot, which creates specific filesystem patterns that reliably trigger this uninitialized memory usage.

Initialize the synclist field with INIT_LIST_HEAD() in alloc_metapage() to ensure it's in a valid state before being used in list operations. This is consistent with how the wait queue is initialized in the same function.

---
Tested:
- Tested locally with syzbot reproducer, no errors observed
Changelog:
- Correct bug link
- Corrected patch format

 fs/jfs/jfs_metapage.c | 1 +
 1 file changed, 1 insertion(+)
fs/jfs/jfs_metapage.c +1 -1
index 871cf4fb3636..77c512a0a42b 100644
@@ -269,6 +269,7 @@ static inline struct metapage *alloc_metapage(gfp_t gfp_mask)
                mp->data = NULL;
                mp->clsn = 0;
                mp->log = NULL;
+               INIT_LIST_HEAD(&mp->synclist);
                init_waitqueue_head(&mp->wait);
        }
        return mp;
--

2.34.1

#3 lore raw
Quoted 1 line · SHAURYA RANE

Pinging if missed

Sorry, I've been flooded with some other work and was also out on vacation a bit during the past month. I'm trying to catch up on a bunch of submitted patches now. Please be patient.

Thanks,
Shaggy

Quoted 53 lines · On Sat, Nov 8, 2025 at 7:48 PM <[email protected]> wrote:
Quoted 51 lines

From: Shaurya Rane <[email protected]>

The synclist field in struct metapage was not being initialized during allocation in alloc_metapage(), leading to list corruption when the metapage is later added to a transaction's sync list.

When diUpdatePMap() calls list_add(&mp->synclist, &tblk->synclist), if the synclist field contains stale data from a previous allocation (such as LIST_POISON values from a freed list node), the list debugging code detects the corruption and triggers a stack segment fault.

This issue is intermittent because it only manifests when recycled memory happens to contain poison values in the synclist field. The bug was discovered by syzbot, which creates specific filesystem patterns that reliably trigger this uninitialized memory usage.

Initialize the synclist field with INIT_LIST_HEAD() in alloc_metapage() to ensure it's in a valid state before being used in list operations. This is consistent with how the wait queue is initialized in the same function.

---
Tested:
- Tested locally with syzbot reproducer, no errors observed
Changelog:
- Correct bug link
- Corrected patch format

  fs/jfs/jfs_metapage.c | 1 +
  1 file changed, 1 insertion(+)
fs/jfs/jfs_metapage.c +1 -1
index 871cf4fb3636..77c512a0a42b 100644
@@ -269,6 +269,7 @@ static inline struct metapage *alloc_metapage(gfp_t gfp_mask)
                 mp->data = NULL;
                 mp->clsn = 0;
                 mp->log = NULL;
+               INIT_LIST_HEAD(&mp->synclist);
                 init_waitqueue_head(&mp->wait);
         }
         return mp;
--

2.34.1