The Linux Kernel Mailing List
 help / color / mirror / Atom feed
* [BUG] blk_update_request: NULL integrity complete_fn on loop via dm-crypt integrity:none
@ 2026-11-30 11:52 Yu Junzhe
  0 siblings, 0 replies; 3+ messages in thread
From: Yu Junzhe @ 2026-11-30 11:52 UTC (permalink / raw)
  To: Jens Axboe, Alasdair Kergon, Mike Snitzer, Mikulas Patocka,
	Benjamin Marzinski
  Cc: linux-block, dm-devel, linux-kernel

Hello,

I am reporting a NULL-pointer dereference in blk_update_request() on a
successful REQ_INTEGRITY read. The request flag is set by dm-crypt
"integrity:<bytes>:none" and the request completes on a loop queue that
never registered an integrity profile.

Summary
=======

On 6.6, blk_update_request() does:

  if (blk_integrity_rq(req) && req_op(req) == REQ_OP_READ &&
      error == BLK_STS_OK)
          req->q->integrity.profile->complete_fn(req, nr_bytes);

blk_integrity_rq() tests only rq->cmd_flags & REQ_INTEGRITY. The same
unguarded call is in blk_complete_request().

dm-crypt "integrity:16:none" sets on_disk_tag_size. crypt_integrity_ctr(),
which requires an underlying DM-DIF-EXT-TAG profile, runs only for AEAD
or an integrity IV, so "none" loads on a plain loop device. On a read,
kcryptd_io_read() clones the bio onto that loop device and
dm_crypt_integrity_io_alloc() calls bio_integrity_alloc(), which sets
REQ_INTEGRITY. Loop never calls blk_integrity_register(), so
q->integrity.profile is NULL and the completion faults at offset 0x18.

Affected
========

Same PoC (loop + dm-crypt integrity:16:none + read), KASAN, 2026-11-30:

- Crashes: 6.6.163, 6.1.193, 5.15.226, 5.10.275
  (RIP in blk_update_request, KASAN range [0x18-0x1f], profile pointer 0)
- Does not crash: 7.4-rc5, 6.18.65, 6.12.119
  (crypt table loads, 32 reads return, no oops)
- First seen on 6.6.144 (campaign crash 7b701911f170e96193541cff13ccd4729c7fc5b6)
- v6.11 removed struct blk_integrity_profile
  (e9f5f44ad372 "block: remove the blk_integrity_profile structure").
  On 6.12 and later, integrity:N:none also leaves tuple_size at 0, so
  the read is not tagged REQ_INTEGRITY.
- Files: block/blk-mq.c, drivers/md/dm-crypt.c
- Config: CONFIG_BLK_DEV_INTEGRITY=y, CONFIG_DM_CRYPT=y, CONFIG_BLK_DEV_LOOP=y
- Needs CAP_SYS_ADMIN

Crash excerpt (packaged PoC, Linux 6.6.163 #1, ksoftirqd)
==========================================================

KASAN: null-ptr-deref in range [0x0000000000000018-0x000000000000001f]
CPU: 1 PID: 21 Comm: ksoftirqd/1 Not tainted 6.6.163 #1
RIP: 0010:blk_update_request+0xa5d/0x1190
Call Trace:
 <TASK>
  blk_mq_end_request
  blk_complete_reqs
  handle_softirqs
  run_ksoftirqd
 </TASK>

A self-contained reproducer creates a loop device, loads one dm-crypt
table ("aes-cbc-plain … integrity:16:none") over it, and preads the
mapped device. I can send the Docker/QEMU package or test a patch.

Thanks,
Yu Junzhe
FuzzAnything <fuzzanything@gmail.com>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [BUG] blk_update_request: NULL integrity complete_fn on loop via dm-crypt integrity:none
@ 2026-12-02  9:15 Yu Junzhe
  2026-12-02 10:54 ` Yu Junzhe
  0 siblings, 1 reply; 3+ messages in thread
From: Yu Junzhe @ 2026-12-02  9:15 UTC (permalink / raw)
  To: Jens Axboe, Alasdair Kergon, Mike Snitzer, Mikulas Patocka,
	Benjamin Marzinski
  Cc: linux-block, dm-devel, linux-kernel

Hello,

I am reporting a NULL-pointer dereference in blk_update_request() on a
successful REQ_INTEGRITY read. The request flag is set by dm-crypt
"integrity:<bytes>:none" and the request completes on a loop queue that
never registered an integrity profile.

Summary
=======

On 6.6, blk_update_request() does:

  if (blk_integrity_rq(req) && req_op(req) == REQ_OP_READ &&
      error == BLK_STS_OK)
          req->q->integrity.profile->complete_fn(req, nr_bytes);

blk_integrity_rq() tests only rq->cmd_flags & REQ_INTEGRITY. The same
unguarded call is in blk_complete_request().

dm-crypt "integrity:16:none" sets on_disk_tag_size. crypt_integrity_ctr(),
which requires an underlying DM-DIF-EXT-TAG profile, runs only for AEAD
or an integrity IV, so "none" loads on a plain loop device. On a read,
kcryptd_io_read() clones the bio onto that loop device and
dm_crypt_integrity_io_alloc() calls bio_integrity_alloc(), which sets
REQ_INTEGRITY. Loop never calls blk_integrity_register(), so
q->integrity.profile is NULL and the completion faults at offset 0x18.

Affected
========

Same PoC (loop + dm-crypt integrity:16:none + read), KASAN, 2026-11-30:

- Crashes: 6.6.163, 6.1.193, 5.15.226, 5.10.275
  (RIP in blk_update_request, KASAN range [0x18-0x1f], profile pointer 0)
- Does not crash: 7.4-rc5, 6.18.65, 6.12.119
  (crypt table loads, 32 reads return, no oops)
- First seen on 6.6.144 (campaign crash 7b701911f170e96193541cff13ccd4729c7fc5b6)
- v6.11 removed struct blk_integrity_profile
  (e9f5f44ad372 "block: remove the blk_integrity_profile structure").
  On 6.12 and later, integrity:N:none also leaves tuple_size at 0, so
  the read is not tagged REQ_INTEGRITY.
- Files: block/blk-mq.c, drivers/md/dm-crypt.c
- Config: CONFIG_BLK_DEV_INTEGRITY=y, CONFIG_DM_CRYPT=y, CONFIG_BLK_DEV_LOOP=y
- Needs CAP_SYS_ADMIN

Crash excerpt (packaged PoC, Linux 6.6.163 #1, ksoftirqd)
==========================================================

KASAN: null-ptr-deref in range [0x0000000000000018-0x000000000000001f]
CPU: 1 PID: 21 Comm: ksoftirqd/1 Not tainted 6.6.163 #1
RIP: 0010:blk_update_request+0xa5d/0x1190
Call Trace:
 <TASK>
  blk_mq_end_request
  blk_complete_reqs
  handle_softirqs
  run_ksoftirqd
 </TASK>

A self-contained reproducer creates a loop device, loads one dm-crypt
table ("aes-cbc-plain … integrity:16:none") over it, and preads the
mapped device. I can send the Docker/QEMU package or test a patch.

Thanks,
Yu Junzhe
FuzzAnything <fuzzanything@gmail.com>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [BUG] blk_update_request: NULL integrity complete_fn on loop via dm-crypt integrity:none
  2026-12-02  9:15 [BUG] blk_update_request: NULL integrity complete_fn on loop via dm-crypt integrity:none Yu Junzhe
@ 2026-12-02 10:54 ` Yu Junzhe
  0 siblings, 0 replies; 3+ messages in thread
From: Yu Junzhe @ 2026-12-02 10:54 UTC (permalink / raw)
  To: Jens Axboe, Alasdair Kergon, Mike Snitzer, Mikulas Patocka,
	Benjamin Marzinski
  Cc: linux-block, dm-devel, linux-kernel, stable, regressions

Hello,

Adding the stable and regression tracking lists because the same reproducer also crashes on 6.6.163, 6.1.193, 5.15.226, and 5.10.275.

The reproducer does not crash on 6.12.119, 6.18.65, or 7.4-rc5. Please assess whether a fix or backport is needed for the affected stable/LTS branches.

The original report and reproducer are in the parent message.

Thanks,
Yu Junzhe

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-12-02 10:54 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-02  9:15 [BUG] blk_update_request: NULL integrity complete_fn on loop via dm-crypt integrity:none Yu Junzhe
2026-12-02 10:54 ` Yu Junzhe
  -- strict thread matches above, loose matches on Subject: below --
2026-11-30 11:52 Yu Junzhe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox