Skip to contentSkip to conversation

buffer: fix NULL dereference of bh->b_folio in __bh_submit()

PATCH In review Joseph Qi 12 participants 14 messages Sep 2 – Sep 22

Subsystems (3)
lore
Share & tools
lore

Joseph Qi

author maintainer
#0 lore raw

PATCH 1/1 buffer: fix NULL dereference of bh->b_folio in __bh_submit()

Commit a2c924c240e7 ("buffer: set BIO_COMPLETE_IN_TASK for dropbehind writeback") added an unconditional folio_test_dropbehind(bh->b_folio) in __bh_submit(). But jbd2 shadow buffers have a NULL b_folio since commit 5febcba29792 ("jbd2: point the shadow buffer at the frozen data directly") made them point b_data at the kmalloced frozen data rather than a folio. Submitting such a buffer during journal commit oopses:

  BUG: kernel NULL pointer dereference, address: 0000000000000000
  RIP: 0010:__bh_submit.constprop.0+0x87/0x120
  Call Trace:
   jbd2_journal_commit_transaction+0x932/0x1b10
   kjournald2+0xb2/0x250

Hit by the ocfs2-testsuite fill_verify_holes test running with data=writeback.

Dropbehind only applies to buffers backed by a folio, so skip the check when b_folio is NULL.

Fixes 5febcba29792 ("jbd2: point the shadow buffer at the frozen data directly")
---
 fs/buffer.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
fs/buffer.c +2 -1
index 427d8a817cd5..f46fa6413032 100644
@@ -1106,7 +1106,8 @@ static void __bh_submit(struct buffer_head *bh, blk_opf_t opf,
 
 	bio = bio_alloc(bh->b_bdev, 1, opf, GFP_NOIO);
 
-	if (folio_test_dropbehind(bh->b_folio) && op_is_write(opf))
+	if (bh->b_folio && folio_test_dropbehind(bh->b_folio) &&
+	    op_is_write(opf))
 		bio_set_flag(bio, BIO_COMPLETE_IN_TASK);
 
 	if (IS_ENABLED(CONFIG_FS_ENCRYPTION))
Signature · 1 line
2.39.3
#1 lore raw
Sashiko has reviewed this patch and found no issues. It looks great!
Quoted 16 lines

Commit a2c924c240e7 ("buffer: set BIO_COMPLETE_IN_TASK for dropbehind writeback") added an unconditional folio_test_dropbehind(bh->b_folio) in __bh_submit(). But jbd2 shadow buffers have a NULL b_folio since commit 5febcba29792 ("jbd2: point the shadow buffer at the frozen data directly") made them point b_data at the kmalloced frozen data rather than a folio. Submitting such a buffer during journal commit oopses:

  BUG: kernel NULL pointer dereference, address: 0000000000000000
  RIP: 0010:__bh_submit.constprop.0+0x87/0x120
  Call Trace:
   jbd2_journal_commit_transaction+0x932/0x1b10
   kjournald2+0xb2/0x250

Hit by the ocfs2-testsuite fill_verify_holes test running with data=writeback.

Quoted 8 lines

Dropbehind only applies to buffers backed by a folio, so skip the check when b_folio is NULL.

Fixes 5febcba29792 ("jbd2: point the shadow buffer at the frozen data directly")

Sashiko has reviewed this patch and found no issues. It looks great!

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
#2 lore raw
In reply to Joseph Qi
Quoted 13 lines · Joseph Qi

Commit a2c924c240e7 ("buffer: set BIO_COMPLETE_IN_TASK for dropbehind writeback") added an unconditional folio_test_dropbehind(bh->b_folio) in __bh_submit(). But jbd2 shadow buffers have a NULL b_folio since commit 5febcba29792 ("jbd2: point the shadow buffer at the frozen data directly") made them point b_data at the kmalloced frozen data rather than a folio. Submitting such a buffer during journal commit oopses:

  BUG: kernel NULL pointer dereference, address: 0000000000000000
  RIP: 0010:__bh_submit.constprop.0+0x87/0x120
  Call Trace:
   jbd2_journal_commit_transaction+0x932/0x1b10
   kjournald2+0xb2/0x250
Quoted 6 lines

Hit by the ocfs2-testsuite fill_verify_holes test running with data=writeback.

Dropbehind only applies to buffers backed by a folio, so skip the check when b_folio is NULL.

Hi,

I was working on a fix for this syzbot report [1] and didn't realize that you were already working on it. I noticed your patch on the mailing list, so i won't send a duplicate patch.

Quoted 1 line
Fixes 5febcba29792 ("jbd2: point the shadow buffer at the frozen data directly")

Could you please add the Reported-by: and Closes: tags from the syzbot report to your patch? This will help syzbot associate the patch with the reported issue and track the fix.

[1]: https://syzkaller.appspot.com/bug?extid=41453ea05ab61c075f1f

Thank you,
Pavan

Quoted 25 lines
---
 fs/buffer.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
fs/buffer.c +2 -1
index 427d8a817cd5..f46fa6413032 100644
@@ -1106,7 +1106,8 @@ static void __bh_submit(struct buffer_head *bh, blk_opf_t opf,
 
 	bio = bio_alloc(bh->b_bdev, 1, opf, GFP_NOIO);
 
-	if (folio_test_dropbehind(bh->b_folio) && op_is_write(opf))
+	if (bh->b_folio && folio_test_dropbehind(bh->b_folio) &&
+	    op_is_write(opf))
 		bio_set_flag(bio, BIO_COMPLETE_IN_TASK);
 
 	if (IS_ENABLED(CONFIG_FS_ENCRYPTION))
Signature · 1 line
2.39.3
author maintainer
#3 lore raw
Quoted 26 lines · Yalagada Pavan Kumar
Quoted 13 lines · Joseph Qi

Commit a2c924c240e7 ("buffer: set BIO_COMPLETE_IN_TASK for dropbehind writeback") added an unconditional folio_test_dropbehind(bh->b_folio) in __bh_submit(). But jbd2 shadow buffers have a NULL b_folio since commit 5febcba29792 ("jbd2: point the shadow buffer at the frozen data directly") made them point b_data at the kmalloced frozen data rather than a folio. Submitting such a buffer during journal commit oopses:

  BUG: kernel NULL pointer dereference, address: 0000000000000000
  RIP: 0010:__bh_submit.constprop.0+0x87/0x120
  Call Trace:
   jbd2_journal_commit_transaction+0x932/0x1b10
   kjournald2+0xb2/0x250
Quoted 6 lines

Hit by the ocfs2-testsuite fill_verify_holes test running with data=writeback.

Dropbehind only applies to buffers backed by a folio, so skip the check when b_folio is NULL.

Hi,

I was working on a fix for this syzbot report [1] and didn't realize that you were already working on it. I noticed your patch on the mailing list, so i won't send a duplicate patch.

Quoted 8 lines
Quoted 1 line
Fixes 5febcba29792 ("jbd2: point the shadow buffer at the frozen data directly")

Could you please add the Reported-by: and Closes: tags from the syzbot report to your patch? This will help syzbot associate the patch with the reported issue and track the fix.

[1]: https://syzkaller.appspot.com/bug?extid=41453ea05ab61c075f1f

Hi Christian,
Could you please address the above when apply the patch? Or should I resend the patch with them?

Thanks,
Joseph

#4 lore raw
Quoted 35 lines · Joseph Qi
Quoted 32 lines · Yalagada Pavan Kumar
Quoted 13 lines · Joseph Qi

Commit a2c924c240e7 ("buffer: set BIO_COMPLETE_IN_TASK for dropbehind writeback") added an unconditional folio_test_dropbehind(bh->b_folio) in __bh_submit(). But jbd2 shadow buffers have a NULL b_folio since commit 5febcba29792 ("jbd2: point the shadow buffer at the frozen data directly") made them point b_data at the kmalloced frozen data rather than a folio. Submitting such a buffer during journal commit oopses:

  BUG: kernel NULL pointer dereference, address: 0000000000000000
  RIP: 0010:__bh_submit.constprop.0+0x87/0x120
  Call Trace:
   jbd2_journal_commit_transaction+0x932/0x1b10
   kjournald2+0xb2/0x250
Quoted 6 lines

Hit by the ocfs2-testsuite fill_verify_holes test running with data=writeback.

Dropbehind only applies to buffers backed by a folio, so skip the check when b_folio is NULL.

Hi,

I was working on a fix for this syzbot report [1] and didn't realize that you were already working on it. I noticed your patch on the mailing list, so i won't send a duplicate patch.

Quoted 1 line
Fixes 5febcba29792 ("jbd2: point the shadow buffer at the frozen data directly")

Could you please add the Reported-by: and Closes: tags from the syzbot report to your patch? This will help syzbot associate the patch with the reported issue and track the fix.

Quoted 5 lines
Quoted 2 lines

[1]: https://syzkaller.appspot.com/bug?extid=41453ea05ab61c075f1f

Hi Christian,
Could you please address the above when apply the patch? Or should I resend the patch with them?

I'll do it. Thanks!

#5 lore raw
Quoted 22 lines · Christian Brauner
Quoted 21 lines · Joseph Qi
Quoted 20 lines · Yalagada Pavan Kumar
Quoted 8 lines · Joseph Qi

Commit a2c924c240e7 ("buffer: set BIO_COMPLETE_IN_TASK for dropbehind writeback") added an unconditional folio_test_dropbehind(bh->b_folio) in __bh_submit(). But jbd2 shadow buffers have a NULL b_folio since commit 5febcba29792 ("jbd2: point the shadow buffer at the frozen data directly") made them point b_data at the kmalloced frozen data rather than a folio. Submitting such a buffer during journal commit oopses:

  BUG: kernel NULL pointer dereference, address: 0000000000000000

[...]
I was working on a fix for this syzbot report [1] and didn't realize that you were already working on it. I noticed your patch on the mailing list, so i won't send a duplicate patch.

Quoted 1 line
Fixes 5febcba29792 ("jbd2: point the shadow buffer at the frozen data directly")

Could you please add the Reported-by: and Closes: tags from the syzbot report to your patch? This will help syzbot associate the patch with the reported issue and track the fix.

Quoted 6 lines
Quoted 4 lines
Quoted 2 lines

[1]: https://syzkaller.appspot.com/bug?extid=41453ea05ab61c075f1f

Could you please address the above when apply the patch? Or should I resend the patch with them?

I'll do it. Thanks!

Christian, just wondering, did this fix maybe fall through the cracks? This got on my radar because there were a few other reports about this regression since then -- and I can't see this or some other fix like this in -next.

At the same time it feels a lot like I'm missing something -- or like some deeper problem with all of this turned up meanwhile, which required more changes that people are still working on. If it's something like that and everything is on track, feel free to just ignore this message.

Ciao, Thorsten

reviewer
#6 lore raw
Quoted 34 lines · Thorsten Leemhuis
Quoted 22 lines · Christian Brauner
Quoted 21 lines · Joseph Qi
Quoted 20 lines · Yalagada Pavan Kumar
Quoted 8 lines · Joseph Qi

Commit a2c924c240e7 ("buffer: set BIO_COMPLETE_IN_TASK for dropbehind writeback") added an unconditional folio_test_dropbehind(bh->b_folio) in __bh_submit(). But jbd2 shadow buffers have a NULL b_folio since commit 5febcba29792 ("jbd2: point the shadow buffer at the frozen data directly") made them point b_data at the kmalloced frozen data rather than a folio. Submitting such a buffer during journal commit oopses:

  BUG: kernel NULL pointer dereference, address: 0000000000000000

[...]
I was working on a fix for this syzbot report [1] and didn't realize that you were already working on it. I noticed your patch on the mailing list, so i won't send a duplicate patch.

Quoted 1 line
Fixes 5febcba29792 ("jbd2: point the shadow buffer at the frozen data directly")

Could you please add the Reported-by: and Closes: tags from the syzbot report to your patch? This will help syzbot associate the patch with the reported issue and track the fix.

Quoted 6 lines
Quoted 4 lines
Quoted 2 lines

[1]: https://syzkaller.appspot.com/bug?extid=41453ea05ab61c075f1f

Could you please address the above when apply the patch? Or should I resend the patch with them?

I'll do it. Thanks!

Christian, just wondering, did this fix maybe fall through the cracks? This got on my radar because there were a few other reports about this regression since then -- and I can't see this or some other fix like this in -next.

Quoted 4 lines

At the same time it feels a lot like I'm missing something -- or like some deeper problem with all of this turned up meanwhile, which required more changes that people are still working on. If it's something like that and everything is on track, feel free to just ignore this message.

The problem is fixed. The bug never got outside of linux-next so Christian just fixed the original commit in his tree.

Honza

Signature · 2 lines
Jan Kara <[email protected]>
SUSE Labs, CR
Tested-by on v1 1/1
#7 lore raw
In reply to Joseph Qi
Quoted 2 lines · Joseph Qi

Since commit 8deae2284976 ("buffer: allow a buffer_head to point at memory outside the page cache"), bh->b_folio may be NULL.

We hit the same NULL dereference independently on real hardware, and it is nastier than a fuzzer-only finding: on an ext4 root filesystem every boot of next-20260831 (and every later tag up to next-20260903) dies about two minutes in. jbd2's shadow buffers have no b_folio by design, so the first journal commit after mount oopses in __bh_submit(), kjournald2 is killed by make_task_dead() and every subsequent metadata write blocks forever - journald, the flush workers and eventually all of userspace wedge in uninterruptible sleep with no block-layer errors reported. After an unclean shutdown the crash moves into early boot (journal recovery commits immediately), which makes the machine effectively unbootable until a different kernel is chosen.

  Unable to handle kernel NULL pointer dereference at virtual address 0000000000000000
  CPU: 0 UID: 0 PID: 357 Comm: jbd2/nvme0n1p18 Tainted: G        W  7.3.0-rc1-next-20260831
  pc : __bh_submit+0xa8/0x210
  Call trace:
   __bh_submit+0xa8/0x210 (P)
   bh_submit+0x24/0x38
   jbd2_journal_commit_transaction+0xb80/0x1ce8
   kjournald2+0xb8/0x238

With this exact change applied on top of next-20260831 the same machine (ASUS Zenbook A16 UX3607OA, Snapdragon X2 Elite, arm64) boots reliably and has been running normally for 11+ hours.

Tested-by on v1 1/1
#8 lore raw
In reply to Joseph Qi
Quoted 19 lines

Commit a2c924c240e7 ("buffer: set BIO_COMPLETE_IN_TASK for dropbehind writeback") added an unconditional folio_test_dropbehind(bh->b_folio) in __bh_submit(). But jbd2 shadow buffers have a NULL b_folio since commit 5febcba29792 ("jbd2: point the shadow buffer at the frozen data directly") made them point b_data at the kmalloced frozen data rather than a folio. Submitting such a buffer during journal commit oopses:

  BUG: kernel NULL pointer dereference, address: 0000000000000000
  RIP: 0010:__bh_submit.constprop.0+0x87/0x120
  Call Trace:
   jbd2_journal_commit_transaction+0x932/0x1b10
   kjournald2+0xb2/0x250

Hit by the ocfs2-testsuite fill_verify_holes test running with data=writeback.

Dropbehind only applies to buffers backed by a folio, so skip the check when b_folio is NULL.

Quoted 6 lines
Fixes 5febcba29792 ("jbd2: point the shadow buffer at the frozen data directly")

---

Hi Joseph,

Thanks for the fix.

On the OrangePi RV2 single-board (SpacemiT K1, riscv64) I hit the NULL pointer dereference while testing other patches on top of linux-next (next-20260904).

The jbd2/mmcblk1p3-N commit thread crashed in __bh_submit() when submitting a journal shadow buffer whose b_folio is NULL. On this board the crash reproduced reliably, roughly 3 minutes after boot, under normal filesystem activity on the ext4 rootfs (buildroot-based minimal userspace).

After applying this fix, the same kernel/board combination has been running stably for several hours with no errors.

Best regards,
Shuai

Quoted 20 lines
 fs/buffer.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
fs/buffer.c +2 -1
index 427d8a817cd5..f46fa6413032 100644
@@ -1106,7 +1106,8 @@ static void __bh_submit(struct buffer_head *bh, blk_opf_t opf,
 
 	bio = bio_alloc(bh->b_bdev, 1, opf, GFP_NOIO);
 
-	if (folio_test_dropbehind(bh->b_folio) && op_is_write(opf))
+	if (bh->b_folio && folio_test_dropbehind(bh->b_folio) &&
+	    op_is_write(opf))
 		bio_set_flag(bio, BIO_COMPLETE_IN_TASK);
 
 	if (IS_ENABLED(CONFIG_FS_ENCRYPTION))
Signature · 1 line
2.39.3
Tested-by on v1 1/1
#9 lore raw
In reply to Joseph Qi

Hi Joseph Qi,

I have the same issue on my Orange Pi 5 (next-20260904) and this patch fixed it. Been running for at least an hour without any issues.

Quoted 45 lines · Joseph Qi

Commit a2c924c240e7 ("buffer: set BIO_COMPLETE_IN_TASK for dropbehind writeback") added an unconditional folio_test_dropbehind(bh->b_folio) in __bh_submit(). But jbd2 shadow buffers have a NULL b_folio since commit 5febcba29792 ("jbd2: point the shadow buffer at the frozen data directly") made them point b_data at the kmalloced frozen data rather than a folio. Submitting such a buffer during journal commit oopses:

  BUG: kernel NULL pointer dereference, address: 0000000000000000
  RIP: 0010:__bh_submit.constprop.0+0x87/0x120
  Call Trace:
   jbd2_journal_commit_transaction+0x932/0x1b10
   kjournald2+0xb2/0x250

Hit by the ocfs2-testsuite fill_verify_holes test running with data=writeback.

Dropbehind only applies to buffers backed by a folio, so skip the check when b_folio is NULL.

Fixes 5febcba29792 ("jbd2: point the shadow buffer at the frozen data directly")
---
 fs/buffer.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
fs/buffer.c +2 -1
index 427d8a817cd5..f46fa6413032 100644
@@ -1106,7 +1106,8 @@ static void __bh_submit(struct buffer_head *bh, blk_opf_t opf,
 
 	bio = bio_alloc(bh->b_bdev, 1, opf, GFP_NOIO);
 
-	if (folio_test_dropbehind(bh->b_folio) && op_is_write(opf))
+	if (bh->b_folio && folio_test_dropbehind(bh->b_folio) &&
+	    op_is_write(opf))
 		bio_set_flag(bio, BIO_COMPLETE_IN_TASK);
 
 	if (IS_ENABLED(CONFIG_FS_ENCRYPTION))
Signature · 1 line
2.39.3
Tested-by on v1 1/1
#10 lore raw
In reply to Joseph Qi
Quoted 16 lines · Joseph Qi

Commit a2c924c240e7 ("buffer: set BIO_COMPLETE_IN_TASK for dropbehind writeback") added an unconditional folio_test_dropbehind(bh->b_folio) in __bh_submit(). But jbd2 shadow buffers have a NULL b_folio since commit 5febcba29792 ("jbd2: point the shadow buffer at the frozen data directly") made them point b_data at the kmalloced frozen data rather than a folio. Submitting such a buffer during journal commit oopses:

  BUG: kernel NULL pointer dereference, address: 0000000000000000
  RIP: 0010:__bh_submit.constprop.0+0x87/0x120
  Call Trace:
   jbd2_journal_commit_transaction+0x932/0x1b10
   kjournald2+0xb2/0x250

Hit by the ocfs2-testsuite fill_verify_holes test running with data=writeback.

Quoted 8 lines

Dropbehind only applies to buffers backed by a folio, so skip the check when b_folio is NULL.

Fixes 5febcba29792 ("jbd2: point the shadow buffer at the frozen data directly")

This patch fixes the same error we've been seeing on various Renesas RZ platforms. Tested on RZ/V2H EVK, RZ/V2N EVK and SMARC RZ/G3E EVK.

Thanks!
Chris

Tested-by on v1 1/1
#11 lore raw
In reply to Joseph Qi
Quoted 33 lines · Joseph Qi

Commit a2c924c240e7 ("buffer: set BIO_COMPLETE_IN_TASK for dropbehind writeback") added an unconditional folio_test_dropbehind(bh->b_folio) in __bh_submit(). But jbd2 shadow buffers have a NULL b_folio since commit 5febcba29792 ("jbd2: point the shadow buffer at the frozen data directly") made them point b_data at the kmalloced frozen data rather than a folio. Submitting such a buffer during journal commit oopses:

  BUG: kernel NULL pointer dereference, address: 0000000000000000
  RIP: 0010:__bh_submit.constprop.0+0x87/0x120
  Call Trace:
   jbd2_journal_commit_transaction+0x932/0x1b10
   kjournald2+0xb2/0x250

Hit by the ocfs2-testsuite fill_verify_holes test running with data=writeback.

Dropbehind only applies to buffers backed by a folio, so skip the check when b_folio is NULL.

Fixes 5febcba29792 ("jbd2: point the shadow buffer at the frozen data directly")
---
 fs/buffer.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
fs/buffer.c +0 -0
index 427d8a817cd5..f46fa6413032 100644

fs/buffer.c static void __bh_submit(struct buffer_head *bh, blk_opf_t opf, · line 1111

Quoted 7 lines
fs/buffer.c +2 -1
@@ -1106,7 +1106,8 @@ static void __bh_submit(struct buffer_head *bh, blk_opf_t opf,
 
 	bio = bio_alloc(bh->b_bdev, 1, opf, GFP_NOIO);
 
-	if (folio_test_dropbehind(bh->b_folio) && op_is_write(opf))
+	if (bh->b_folio && folio_test_dropbehind(bh->b_folio) &&
+	    op_is_write(opf))
 		bio_set_flag(bio, BIO_COMPLETE_IN_TASK);

-next has been broken for a week+ already, please pick this up..

Konrad

reviewer
#12 lore raw
Quoted 37 lines · Konrad Dybcio
Quoted 36 lines · Joseph Qi

Commit a2c924c240e7 ("buffer: set BIO_COMPLETE_IN_TASK for dropbehind writeback") added an unconditional folio_test_dropbehind(bh->b_folio) in __bh_submit(). But jbd2 shadow buffers have a NULL b_folio since commit 5febcba29792 ("jbd2: point the shadow buffer at the frozen data directly") made them point b_data at the kmalloced frozen data rather than a folio. Submitting such a buffer during journal commit oopses:

  BUG: kernel NULL pointer dereference, address: 0000000000000000
  RIP: 0010:__bh_submit.constprop.0+0x87/0x120
  Call Trace:
   jbd2_journal_commit_transaction+0x932/0x1b10
   kjournald2+0xb2/0x250

Hit by the ocfs2-testsuite fill_verify_holes test running with data=writeback.

Dropbehind only applies to buffers backed by a folio, so skip the check when b_folio is NULL.

Fixes 5febcba29792 ("jbd2: point the shadow buffer at the frozen data directly")
---
 fs/buffer.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
fs/buffer.c +0 -0
index 427d8a817cd5..f46fa6413032 100644
@@ -1106,7 +1106,8 @@ static void __bh_submit(struct buffer_head *bh, blk_opf_t opf,
 
 	bio = bio_alloc(bh->b_bdev, 1, opf, GFP_NOIO);
 
Quoted 7 lines

fs/buffer.c static void __bh_submit(struct buffer_head *bh, blk_opf_t opf, · line 1111

Quoted 4 lines
fs/buffer.c +2 -1
-	if (folio_test_dropbehind(bh->b_folio) && op_is_write(opf))
+	if (bh->b_folio && folio_test_dropbehind(bh->b_folio) &&
+	    op_is_write(opf))
 		bio_set_flag(bio, BIO_COMPLETE_IN_TASK);

-next has been broken for a week+ already, please pick this up..

Christian has pushed out a branch with the fixed version of the code today so hopefully it should get fixed in linux-next soon.

Honza

Signature · 2 lines
Jan Kara <[email protected]>
SUSE Labs, CR
Tested-by on v1 1/1
#13 lore raw
In reply to Joseph Qi
Quoted 19 lines · Joseph Qi

Commit a2c924c240e7 ("buffer: set BIO_COMPLETE_IN_TASK for dropbehind writeback") added an unconditional folio_test_dropbehind(bh->b_folio) in __bh_submit().  But jbd2 shadow buffers have a NULL b_folio since commit 5febcba29792 ("jbd2: point the shadow buffer at the frozen data directly") made them point b_data at the kmalloced frozen data rather than a folio.  Submitting such a buffer during journal commit oopses:

  BUG: kernel NULL pointer dereference, address: 0000000000000000
  RIP: 0010:__bh_submit.constprop.0+0x87/0x120
  Call Trace:
   jbd2_journal_commit_transaction+0x932/0x1b10
   kjournald2+0xb2/0x250

Hit by the ocfs2-testsuite fill_verify_holes test running with data=writeback.

Dropbehind only applies to buffers backed by a folio, so skip the check when b_folio is NULL.

Quoted 8 lines
Fixes 5febcba29792 ("jbd2: point the shadow buffer at the frozen data directly")

---
 fs/buffer.c | 3 ++-

 1 file changed, 2 insertions(+), 1 deletion(-)