The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: "Naohiro Aota" <Naohiro.Aota@wdc.com>
To: "Yifan Feng" <evanfengff@gmail.com>, "David Sterba" <dsterba@suse.com>
Cc: "Chris Mason" <mason@kernel.org>,
	"Naohiro Aota" <naohiro.aota@wdc.com>,
	"Johannes Thumshirn" <johannes.thumshirn@wdc.com>,
	<linux-btrfs@vger.kernel.org>, <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] btrfs: tests: zoned: fix NULL check of the active bitmap
Date: Tue, 17 Nov 2026 14:00:40 +0900	[thread overview]
Message-ID: <DMX7ZGF2CIPU.LLR0XYTGV2Q0@wdc.com> (raw)
In-Reply-To: <20261117035155.86323-1-evanfengff@gmail.com>

On Tue Nov 17, 2026 at 12:51 PM JST, Yifan Feng wrote:
> test_load_zone_info() allocates the active bitmap with bitmap_zalloc()
> but then tests zone_info, which was already checked a few lines above.
> A failed allocation is not detected, and the NULL bitmap is then used
> by __set_bit() and by btrfs_load_block_group_by_raid_type().
>
> Check the active bitmap instead.
>
> Tested in QEMU with the bitmap size temporarily changed to UINT_MAX so
> that the allocation fails. Without this patch the kernel oopses in
> btrfs_test_zoned() with a NULL pointer dereference. With it the test
> prints "cannot allocate active bitmap" and fails cleanly.
>
> Found by searching for a NULL check that tests a different pointer than
> the one just allocated, with the help of an AI coding assistant
> (Claude).
>
> Fixes: 1ba19a6ea9f2 ("btrfs: tests: zoned: add tests cases for zoned code")
> Signed-off-by: Yifan Feng <evanfengff@gmail.com>

Reviewed-by: Naohiro Aota <naohiro.aota@wdc.com>

      parent reply	other threads:[~2026-11-17  5:01 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-17  3:51 [PATCH] btrfs: tests: zoned: fix NULL check of the active bitmap Yifan Feng
2026-11-17  4:35 ` Qu Wenruo
2026-11-17  5:00 ` Naohiro Aota [this message]

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=DMX7ZGF2CIPU.LLR0XYTGV2Q0@wdc.com \
    --to=naohiro.aota@wdc.com \
    --cc=dsterba@suse.com \
    --cc=evanfengff@gmail.com \
    --cc=johannes.thumshirn@wdc.com \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mason@kernel.org \
    /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