From: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
To: 0wnerD1ed <l7z@0b1t.tech>
Cc: Keith Busch <kbusch@meta.com>,
linux-block@vger.kernel.org, linux-fsdevel@vger.kernel.org,
dm-devel@lists.linux.dev, hch@lst.de, axboe@kernel.dk,
brauner@kernel.org, djwong@kernel.org, viro@zeniv.linux.org.uk,
Keith Busch <kbusch@kernel.org>,
stable@vger.kernel.org, Hannes Reinecke <hare@kernel.org>
Subject: Re: [PATCH RESEND 5/5] block: validate user space vectors during extraction
Date: Thu, 6 Aug 2026 18:54:54 +0900 [thread overview]
Message-ID: <anRZZen4cCw3fCPG@shinmob> (raw)
In-Reply-To: <CAKTh27_RnTA_Q8qAbQ60gBo9Op_OQm7J8KyamQ_tbuTRb4XF2w@mail.gmail.com>
On Aug 06, 2026 / 16:29, 0wnerD1ed wrote:
> On Aug 06, 2026 / 16:04, Shin'ichiro Kawasaki wrote:
> > I took a closer look. I modified the test case to respect the dma alignment [*],
> > and now the test case passes. This approach looks working. Will post the change
> > as a formal patch for review.
>
> Sorry for the slow reply, I have been busy lately.
>
> Thanks for chasing this down. The test is mine and its assumption is
> wrong, not the kernel, src/bio-full-trim puts the destination at
> p + page_size - 1, and null_blk advertises dma_alignment = 1 since
> commit 3451cf34f51b ("null_blk: allow byte aligned memory offsets"),
> so iov_iter_extract_bvecs() now rejects that odd address before
> anything is extracted and bio_iov_iter_align_down() is never reached.
> That restores the behaviour we had until 5ff3f74e145a ("block:
> simplify direct io validity check"), so the test is what has to
> respect dma_alignment. Your approach is the right one.
Good, thanks for the confirmation.
>
> One problem in the trial patch, the guard has to be against the
> logical block size, not the page size. What the test needs is a
> fragment that bio_iov_iter_align_down() removes completely, i.e. one
> smaller than the block size, and the read has to reach the PROT_NONE
> page. With dma_alignment = 511 and a 512 byte block size (the block
> layer default for drivers that do not set dma_alignment),
> dma_aligned_offset becomes 512, which is below page_size and passes
> the check, but the read then lies entirely within the first page,
> succeeds, and the helper reports
>
> pread returned 512 (errno 0)
>
> instead of taking the "unexpected dma_alignment" exit. block/045 only
> uses null_blk so this cannot bite today, but the check does not do
> what it intends. block_size comes from BLKSSZGET, so it also has to
> move below that ioctl:
>
> if (dma_aligned_offset >= block_size)
> errx(EXIT_FAILURE,
> "unexpected dma_alignment %u for block size %u",
> dma_alignment, block_size);
>
> While there, err() should be errx(), errno is not meaningful at that
> point.
Yep, I reflected this change to the patch.
>
> I am short on time at the moment, so please go ahead with the formal
> posting. I will send a Tested-by once I get a chance to run it.
Sure, I have posted the patch. Thanks.
https://lore.kernel.org/linux-block/20260806094218.2077413-1-shinichiro.kawasaki@wdc.com/
next prev parent reply other threads:[~2026-08-06 9:56 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-20 20:10 [PATCH RESEND 0/5] block: validate direct I/O memory alignment Keith Busch
2026-07-20 20:10 ` [PATCH RESEND 1/5] block: use blkdev_iov_iter_get_pages status for errors Keith Busch
2026-07-20 20:10 ` [PATCH RESEND 2/5] block: fix dio leak on metadata mapping error Keith Busch
2026-07-20 20:10 ` [PATCH RESEND 3/5] loop: set dma_alignment from the backing file for direct I/O Keith Busch
2026-07-20 20:10 ` [PATCH RESEND 4/5] zloop: set dma_alignment from the backing files " Keith Busch
2026-07-20 20:10 ` [PATCH RESEND 5/5] block: validate user space vectors during extraction Keith Busch
2026-08-05 12:46 ` Shin'ichiro Kawasaki
2026-08-06 8:03 ` Shin'ichiro Kawasaki
2026-08-06 8:29 ` 0wnerD1ed
2026-08-06 9:54 ` Shin'ichiro Kawasaki [this message]
2026-07-29 19:15 ` [PATCH RESEND 0/5] block: validate direct I/O memory alignment Keith Busch
2026-07-29 19:18 ` Jens Axboe
2026-07-29 20:03 ` Keith Busch
2026-07-29 23:34 ` Jens Axboe
2026-07-30 11:26 ` Christoph Hellwig
2026-07-30 12:52 ` Keith Busch
2026-07-30 16:22 ` Jens Axboe
2026-07-30 13:25 ` Thorsten Leemhuis
2026-07-30 16:23 ` Jens Axboe
2026-07-30 16:46 ` Linus Torvalds
2026-07-31 14:11 ` Jens Axboe
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=anRZZen4cCw3fCPG@shinmob \
--to=shinichiro.kawasaki@wdc.com \
--cc=axboe@kernel.dk \
--cc=brauner@kernel.org \
--cc=djwong@kernel.org \
--cc=dm-devel@lists.linux.dev \
--cc=hare@kernel.org \
--cc=hch@lst.de \
--cc=kbusch@kernel.org \
--cc=kbusch@meta.com \
--cc=l7z@0b1t.tech \
--cc=linux-block@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=stable@vger.kernel.org \
--cc=viro@zeniv.linux.org.uk \
/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