* [PATCH] block: reject polled dio with user integrity metadata
@ 2026-09-23 9:37 Yang Xiuwei
2026-09-23 11:20 ` Jens Axboe
2026-09-23 14:39 ` Christoph Hellwig
0 siblings, 2 replies; 4+ messages in thread
From: Yang Xiuwei @ 2026-09-23 9:37 UTC (permalink / raw)
To: Jens Axboe
Cc: Martin K . Petersen, Christian Brauner, Christoph Hellwig,
linux-block, Yang Xiuwei
IOCB_HAS_METADATA leaves iocb->private as a uio_meta, while
iocb_bio_iopoll() expects a bio. Since 2729a60bbfb9, metadata I/O
always uses __blkdev_direct_IO(), which never publishes the bio for
polling, so IOPOLL calls bio_poll() on the uio_meta.
Reproducer: io_uring IOPOLL plus a PI attribute on an integrity device
(scsi_debug dif=1 dix=1). KASAN reports:
Oops: general protection fault, probably for non-canonical
address 0xdffffc0000000004
KASAN: null-ptr-deref in range
[0x0000000000000020-0x0000000000000027]
RIP: 0010:bio_poll+0x9d/0x4b0
Call Trace:
iocb_bio_iopoll+0x5b/0x80
io_uring_classic_poll+0xf3/0x140
io_do_iopoll+0x4e3/0xc00
io_iopoll_check+0x275/0x560
__do_sys_io_uring_enter+0x2e5/0x720
Return -EOPNOTSUPP when HIPRI is combined with user metadata.
Fixes: 2729a60bbfb9 ("block: don't silently ignore metadata for sync read/write")
Assisted-by: LLM
Signed-off-by: Yang Xiuwei <yangxiuwei@kylinos.cn>
---
block/fops.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/block/fops.c b/block/fops.c
index 2ce7c6c4714e..c915ec0126d7 100644
--- a/block/fops.c
+++ b/block/fops.c
@@ -402,6 +402,11 @@ static ssize_t blkdev_direct_IO(struct kiocb *iocb, struct iov_iter *iter)
if (blkdev_dio_invalid(bdev, iocb, iter))
return -EINVAL;
+ /* HIPRI needs private as bio; HAS_METADATA keeps it as uio_meta */
+ if ((iocb->ki_flags & IOCB_HIPRI) &&
+ (iocb->ki_flags & IOCB_HAS_METADATA))
+ return -EOPNOTSUPP;
+
if (iov_iter_rw(iter) == WRITE) {
u16 max_write_streams = bdev_max_write_streams(bdev);
--
2.25.1
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH] block: reject polled dio with user integrity metadata
2026-09-23 9:37 [PATCH] block: reject polled dio with user integrity metadata Yang Xiuwei
@ 2026-09-23 11:20 ` Jens Axboe
2026-09-23 14:39 ` Christoph Hellwig
1 sibling, 0 replies; 4+ messages in thread
From: Jens Axboe @ 2026-09-23 11:20 UTC (permalink / raw)
To: Yang Xiuwei
Cc: Martin K . Petersen, Christian Brauner, Christoph Hellwig,
linux-block
On Wed, 23 Sep 2026 17:37:32 +0800, Yang Xiuwei wrote:
> IOCB_HAS_METADATA leaves iocb->private as a uio_meta, while
> iocb_bio_iopoll() expects a bio. Since 2729a60bbfb9, metadata I/O
> always uses __blkdev_direct_IO(), which never publishes the bio for
> polling, so IOPOLL calls bio_poll() on the uio_meta.
>
> Reproducer: io_uring IOPOLL plus a PI attribute on an integrity device
> (scsi_debug dif=1 dix=1). KASAN reports:
>
> [...]
Applied, thanks!
[1/1] block: reject polled dio with user integrity metadata
commit: 2a42e6fe1293f2e2d579c9fe5bbab056dd8b880e
Best regards,
--
Jens Axboe
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH] block: reject polled dio with user integrity metadata
2026-09-23 9:37 [PATCH] block: reject polled dio with user integrity metadata Yang Xiuwei
2026-09-23 11:20 ` Jens Axboe
@ 2026-09-23 14:39 ` Christoph Hellwig
2026-09-24 0:35 ` Yang Xiuwei
1 sibling, 1 reply; 4+ messages in thread
From: Christoph Hellwig @ 2026-09-23 14:39 UTC (permalink / raw)
To: Yang Xiuwei
Cc: Jens Axboe, Martin K . Petersen, Christian Brauner,
Christoph Hellwig, linux-block
On Wed, Sep 23, 2026 at 05:37:32PM +0800, Yang Xiuwei wrote:
> IOCB_HAS_METADATA leaves iocb->private as a uio_meta, while
> iocb_bio_iopoll() expects a bio. Since 2729a60bbfb9, metadata I/O
> always uses __blkdev_direct_IO(), which never publishes the bio for
> polling, so IOPOLL calls bio_poll() on the uio_meta.
>
> Reproducer: io_uring IOPOLL plus a PI attribute on an integrity device
> (scsi_debug dif=1 dix=1). KASAN reports:
Can you add a reproducer for this to blktests?
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-09-24 0:35 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-23 9:37 [PATCH] block: reject polled dio with user integrity metadata Yang Xiuwei
2026-09-23 11:20 ` Jens Axboe
2026-09-23 14:39 ` Christoph Hellwig
2026-09-24 0:35 ` Yang Xiuwei
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox