From: Baokun Li <libaokun@linux.alibaba.com>
To: sashiko-reviews@lists.linux.dev, David Sterba <dsterba@suse.com>,
mason@kernel.org, linux-btrfs@vger.kernel.org
Cc: tytso@mit.edu, linux-ext4@vger.kernel.org,
linux-fscrypt@vger.kernel.org, linux-fscrypt@vger.kernel.org,
linux-block@vger.kernel.org, linux-fsdevel@vger.kernel.org,
linux-xfs@vger.kernel.org, ebiggers@kernel.org,
jaegeuk@kernel.org, axboe@kernel.dk, hch@lst.de,
djwong@kernel.org, brauner@kernel.org, tytso@mit.edu,
berto@igalia.com, adilger.kernel@dilger.ca, jack@suse.cz,
yi.zhang@huawei.com, ojaswin@linux.ibm.com,
ritesh.list@gmail.com
Subject: Re: [PATCH 10/13] block: don't require data unit aligned bio_vecs for encrypted bios
Date: Mon, 12 Oct 2026 16:09:25 +0800 [thread overview]
Message-ID: <8c8a81b5-bde0-45c2-b673-ddd3daf7b6ce@linux.alibaba.com> (raw)
In-Reply-To: <sashiko-outbox-167346@kernel.org>
Added David, Chris and the btrfs list.
On 2026/10/12 01:24, sashiko-bot@kernel.org wrote:
> Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
> - [Critical] btrfs: infinite loop and double submission in btrfs_submit_bbio() due to unhandled negative error from bio_split_rw_at()
> --
>
> [Severity: Critical]
> Since bio_split_io_at() (and functions wrapping it like bio_split_rw_at())
> returns negative error codes such as -EINVAL, can this lead to an infinite
> loop in btrfs callers?
>
> In fs/btrfs/bio.c:btrfs_append_map_length(), the return value is not
> checked for negative error codes:
>
> sector_offset = bio_split_rw_at(&bbio->bio, &fs_info->limits,
> &nr_segs, map_length);
> if (sector_offset) {
> /* ... */
> return ALIGN_DOWN(sector_offset << SECTOR_SHIFT,
> fs_info->sectorsize);
> }
>
> If bio_split_rw_at() returns a negative error code (such as -EINVAL or
> -EAGAIN), ALIGN_DOWN() will operate on a negative value and return a massive
> u64.
>
> This huge value is then returned as map_length to btrfs_submit_chunk(),
> where it causes the bio split to be skipped since map_length < length is
> false.
>
> Because btrfs_submit_chunk() returns false, it causes its caller
> btrfs_submit_bbio() to enter an infinite loop:
>
> while (!btrfs_submit_chunk(bbio, mirror_num))
> ;
>
> Do the btrfs callers need to be updated to handle these negative return
> values, or does this patch change the conditions under which
> bio_split_io_at() returns an error for encrypted bios?
>
This patch doesn't change when bio_split_io_at() returns an error.
For bios without a crypto context start_align_mask was already
lim->dma_alignment, and the data unit masks were only added inside
the "if (bc)" branch, so the bvec checks are byte-for-byte identical
before and after this patch.
For encrypted bios the patch only drops the data unit alignment
requirement, so it can make -EINVAL less likely, never more.
The missing negative check in btrfs_append_map_length() is thus a
pre-existing btrfs issue. It came with fec2e705729d ("block: check
for valid bio while splitting"), which added the -EINVAL returns but
didn't update the btrfs caller, and it is only reachable on the
zoned append path.
The fix should check for a negative return and fail the bio, as
bio_submit_split() does.
Regards,
Baokun
next prev parent reply other threads:[~2026-10-12 8:09 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-11 17:09 [PATCH 00/13] block, ext4: allow encryption with a block size larger than the page size Baokun Li
2026-10-11 17:09 ` [PATCH 01/13] ext4: refuse encryption when block size > " Baokun Li
2026-10-11 17:09 ` [PATCH 02/13] ext4: reject encrypted inodes " Baokun Li
2026-10-11 17:09 ` [PATCH 03/13] blk-crypto: reject fallback data unit sizes it can't handle Baokun Li
[not found] ` <sashiko-outbox-167341@kernel.org>
2026-10-12 7:50 ` Baokun Li
2026-10-11 17:09 ` [PATCH 04/13] blk-crypto: decrypt one data unit per crypto request Baokun Li
2026-10-11 17:09 ` [PATCH 05/13] blk-crypto: encrypt " Baokun Li
2026-10-11 17:09 ` [PATCH 06/13] blk-crypto: support data units larger than a page Baokun Li
2026-10-11 17:09 ` [PATCH 07/13] iomap: align the direct I/O bios of encrypted files to the block size Baokun Li
2026-10-11 17:09 ` [PATCH 08/13] block: split encrypted bios at data unit boundaries Baokun Li
2026-10-11 17:09 ` [PATCH 09/13] block: warn about bios that can't be split Baokun Li
2026-10-11 17:09 ` [PATCH 10/13] block: don't require data unit aligned bio_vecs for encrypted bios Baokun Li
[not found] ` <sashiko-outbox-167346@kernel.org>
2026-10-12 8:09 ` Baokun Li [this message]
2026-10-11 17:09 ` [PATCH 11/13] ext4: allow encryption with a block size larger than the page size Baokun Li
2026-10-11 17:09 ` [PATCH 12/13] ext4: send folios that cover a wraparound to the buffer_head path Baokun Li
2026-10-11 17:09 ` [PATCH 13/13] ext4: allow large folios for encrypted files Baokun Li
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=8c8a81b5-bde0-45c2-b673-ddd3daf7b6ce@linux.alibaba.com \
--to=libaokun@linux.alibaba.com \
--cc=adilger.kernel@dilger.ca \
--cc=axboe@kernel.dk \
--cc=berto@igalia.com \
--cc=brauner@kernel.org \
--cc=djwong@kernel.org \
--cc=dsterba@suse.com \
--cc=ebiggers@kernel.org \
--cc=hch@lst.de \
--cc=jack@suse.cz \
--cc=jaegeuk@kernel.org \
--cc=linux-block@vger.kernel.org \
--cc=linux-btrfs@vger.kernel.org \
--cc=linux-ext4@vger.kernel.org \
--cc=linux-fscrypt@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-xfs@vger.kernel.org \
--cc=mason@kernel.org \
--cc=ojaswin@linux.ibm.com \
--cc=ritesh.list@gmail.com \
--cc=sashiko-reviews@lists.linux.dev \
--cc=tytso@mit.edu \
--cc=yi.zhang@huawei.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