mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: syzbot <syzbot+b4a2af3000eaa84d95d5@syzkaller.appspotmail.com>
To: linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com
Subject: Forwarded: [PATCH] btrfs: reject devices with block size larger than PAGE_SIZE
Date: Fri, 09 Jan 2026 00:43:22 -0800	[thread overview]
Message-ID: <6960bfaa.050a0220.1c677c.03bd.GAE@google.com> (raw)
In-Reply-To: <695faa63.050a0220.1c677c.039b.GAE@google.com>

For archival purposes, forwarding an incoming command email to
linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com.

***

Subject: [PATCH] btrfs: reject devices with block size larger than PAGE_SIZE
Author: kartikey406@gmail.com

#syz test: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master

When a block device has a block size larger than PAGE_SIZE, the page
cache allocates folios that are too small for the device's requirements.
This causes folio_alloc_buffers() to return NULL (loop never executes
when blocksize > folio_size), leading to a NULL pointer dereference in
create_empty_buffers() when accessing bh->b_state.

The bug was triggered by mounting a null_blk device configured with
large block size as btrfs. The crash path is:

  btrfs_read_disk_super()
    read_cache_page_gfp()        <- allocates 4KB folio
      do_read_cache_folio()
        block_read_full_folio()
          folio_create_buffers()
            create_empty_buffers()
              folio_alloc_buffers()  <- returns NULL (16KB > 4KB)
              bh->b_state            <- NULL deref crash

Add a check to reject block devices with block size larger than
PAGE_SIZE before attempting to read the superblock.

Reported-by: syzbot+b4a2af3000eaa84d95d5@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=b4a2af3000eaa84d95d5
Signed-off-by: Deepanshu Kartikey <kartikey406@gmail.com>
---
 fs/btrfs/volumes.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
index 13c514684cfb..1d529e408f5c 100644
--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -1341,6 +1341,10 @@ struct btrfs_super_block *btrfs_read_disk_super(struct block_device *bdev,
 	struct address_space *mapping = bdev->bd_mapping;
 	int ret;
 
+	/* Reject devices with block size larger than PAGE_SIZE */
+	if (bdev_logical_block_size(bdev) > PAGE_SIZE)
+		return ERR_PTR(-EINVAL);
+
 	bytenr_orig = btrfs_sb_offset(copy_num);
 	ret = btrfs_sb_log_location_bdev(bdev, copy_num, READ, &bytenr);
 	if (ret < 0) {
-- 
2.43.0


  parent reply	other threads:[~2026-01-09  8:43 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-08 13:00 [syzbot] [btrfs?] general protection fault in create_empty_buffers (5) syzbot
2026-01-09  4:30 ` Edward Adam Davis
2026-01-09  4:50   ` syzbot
2026-01-09  5:44 ` Forwarded: [PATCH] btrfs: validate block device block size before reading superblock syzbot
2026-01-09  8:06 ` Forwarded: [PATCH] btrfs: debug folio_alloc_buffers parameters syzbot
2026-01-09  8:43 ` syzbot [this message]
2026-01-09  9:09 ` Forwarded: [PATCH] btrfs: debug block device parameters before reading superblock syzbot
2026-01-09 10:49 ` [syzbot] [btrfs?] general protection fault in create_empty_buffers (5) Edward Adam Davis
2026-01-09 11:04   ` syzbot
2026-01-09 11:14 ` Edward Adam Davis
2026-01-09 11:36   ` syzbot
2026-01-09 11:37 ` [PATCH] btrfs: Sync read disk supper and set block size Edward Adam Davis
2026-01-09 12:43   ` Filipe Manana
2026-01-09 13:02     ` [PATCH v2] btrfs: Sync read disk super " Edward Adam Davis
2026-01-09 17:21       ` Filipe Manana
2026-01-09 21:04       ` Qu Wenruo
2026-01-09 12:56 ` [PATCH] " Edward Adam Davis

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=6960bfaa.050a0220.1c677c.03bd.GAE@google.com \
    --to=syzbot+b4a2af3000eaa84d95d5@syzkaller.appspotmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=syzkaller-bugs@googlegroups.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome