Re: [PATCH RESEND] block: pin user PI pages for writing when ref tags are remapped

From: Caleb Sander Mateos

Date: Fri Nov 20 2026 - 12:45:22 EST


On Fri, Nov 20, 2026 at 9:23 AM Keith Busch <kbusch@xxxxxxxxxx> wrote:
>
> On Fri, Nov 20, 2026 at 09:13:41AM -0800, Christoph Hellwig wrote:
> > On Fri, Nov 20, 2026 at 09:58:32AM -0700, Keith Busch wrote:
> > > > Agreed. I'll keep the PI iterator as ITER_SOURCE. In v2,
> > > > bio_integrity_map_user() will bounce the user PI buffer for REQ_OP_WRITE
> > > > when the integrity profile has BLK_INTEGRITY_REF_TAG. That way the
> > > > block layer can remap the tags in its own copy.
> > >
> > > Can avoid bouncing? I think the remapping flags can be tied to the
> > > user's reftag check request.
> > >
> > > If BIP_CHECK_REFTAG is set from the user setting IO_INTEGRITY_CHK_REFTAG
> > > on a write, we can map the PI buffer for writing. The user explicitly
> > > asked to have the ref tags checked by the device, and partitions require
> > > remapping them, so they've told the kernel to write to their buffer.
> >
> > No, the user did not ask for violating the mapping direction. The
> > whole remapping thing very much is an internal implementation detail
>
> Okay, fine. But can we skip bouncing and remapping if the flag isn't
> set?

Currently, the remapping happens regardless of BIP_CHECK_REFTAG. It
depends only on whether the block device reports ref tag support via
BLK_INTEGRITY_REF_TAG (i.e. Type 1 or Type 2 PI). I think it would be
a UAPI behavior change to make the ref tag remapping conditional on
BIP_CHECK_REFTAG.

I don't see a way to tell ahead of time whether remapping will be
required without walking the metadata buffer an additional time in
bio_integrity_map_iter() to check the current ref tags. I'd vote for
making the simplest fix for the vulnerability (e.g. always bounce
buffering) and optimizing later.

Best,
Caleb