diff mbox series

[RFC,1/6] block: refuse a dma-buf bio that carries a crypto context

Message ID 20261105065847.196540-2-mengmeng.zhao@linux.dev
State New
Headers show
Series ext4: Add dma-buf read/write support | expand

Commit Message

Mengmeng Zhao Nov. 5, 2026, 6:58 a.m. UTC
From: Mengmeng Zhao <zhaomengmeng@kylinos.cn>

A dma-buf bio has no pages for the crypto layer to walk: the
software fallback would read the map as bio_vecs.  Refuse it in
blk_mq_submit_bio() before it can reach that path.

Signed-off-by: Mengmeng Zhao <zhaomengmeng@kylinos.cn>
Signed-off-by: Li Wang <liwang@kylinos.cn>
---
 block/blk-mq.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Comments

Christoph Hellwig Nov. 6, 2026, 10:41 a.m. UTC | #1
On Thu, Nov 05, 2026 at 02:58:42PM +0800, Mengmeng Zhao wrote:
> +	/* a dma-buf bio has no pages for integrity work or contents crypto */
>  	if (unlikely(op_is_dmabuf(bio->bi_opf) &&
> -		bdev_has_integrity_csum(bio->bi_bdev))) {
> +	    (bdev_has_integrity_csum(bio->bi_bdev) ||
> +	     bio_has_crypt_ctx(bio)))) {

This could really use a factored helper explaining all the refusals.
And maybe we should use the chance to sit back and think what else
would blow up and add it there as well.
Mengmeng Zhao Nov. 9, 2026, 2:51 a.m. UTC | #2
On 11/6/26 18:41, Christoph Hellwig wrote:
> On Thu, Nov 05, 2026 at 02:58:42PM +0800, Mengmeng Zhao wrote:
>> +	/* a dma-buf bio has no pages for integrity work or contents crypto */
>>  	if (unlikely(op_is_dmabuf(bio->bi_opf) &&
>> -		bdev_has_integrity_csum(bio->bi_bdev))) {
>> +	    (bdev_has_integrity_csum(bio->bi_bdev) ||
>> +	     bio_has_crypt_ctx(bio)))) {
> 
> This could really use a factored helper explaining all the refusals.
> And maybe we should use the chance to sit back and think what else
> would blow up and add it there as well.
> 
Hi Christoph, thanks for the review. I will extract a helper in V2 soon. 
There are several buffered io fallbacks, it's really necessary to discuss
how to avoid these. Glad to join it.
diff mbox series

Patch

diff --git a/block/blk-mq.c b/block/blk-mq.c
index be5671966787..f0d978b1724f 100644
--- a/block/blk-mq.c
+++ b/block/blk-mq.c
@@ -3138,8 +3138,10 @@  void blk_mq_submit_bio(struct bio *bio)
 		goto queue_exit;
 	}
 
+	/* a dma-buf bio has no pages for integrity work or contents crypto */
 	if (unlikely(op_is_dmabuf(bio->bi_opf) &&
-		bdev_has_integrity_csum(bio->bi_bdev))) {
+	    (bdev_has_integrity_csum(bio->bi_bdev) ||
+	     bio_has_crypt_ctx(bio)))) {
 		bio_endio_status(bio, BLK_STS_NOTSUPP);
 		goto queue_exit;
 	}