Skip to contentSkip to conversation

KASAN: slab-use-after-free in nvmet_fc_tgt_q_put

BUG Shuangpeng 2 participants 3 messages Jun 3 NVMe

lore
Share & tools
lore

Shuangpeng

author
#0 lore raw

Hi Kernel Maintainers,

I hit the following KASAN report while testing current upstream kernel:

KASAN: slab-use-after-free in nvmet_fc_tgt_q_put

on commit: e8c2f9fdadee7cbc75134dc463c1e0d856d6e5c7 (May 25 2026)

To help trigger the bug more reliably, we applied a minimal diagnostic patch that only adds delays and print statements.

The reproducer and .config files are here.
https://gist.github.com/shuangpengbai/57055c1ccb14132218674ec5f3f31d34

I’m happy to test debug patches or provide additional information.

[ 755.638997][ T62] BUG: KASAN: slab-use-after-free in nvmet_fc_tgt_q_put (drivers/nvme/target/fc.c:845 ./include/linux/kref.h:65 drivers/nvme/target/fc.c:855)
[ 755.639021][ T62] Read of size 8 at addr ffff8881789bd010 by task kworker/u9:1/62
[ 755.639025][ T62]
[ 755.639049][ T62] Tainted: [D]=DIE
[ 755.639051][ T62] Hardware name: QEMU Ubuntu 24.04 PC v2 (i440FX + PIIX, arch_caps fix, 1996), BIOS 1.16.3-debian-1.16.3-2 04/01/2014
[ 755.639055][ T62] Workqueue: nvmet-wq fcloop_fcp_recv_work
[ 755.639063][ T62] Call Trace:
[ 755.639066][ T62] <TASK>
[ 755.639075][ T62] dump_stack_lvl (lib/dump_stack.c:94 lib/dump_stack.c:120)
[ 755.639082][ T62] print_report (mm/kasan/report.c:378 mm/kasan/report.c:482)
[ 755.639145][ T62] kasan_report (mm/kasan/report.c:595)
[ 755.639167][ T62] nvmet_fc_tgt_q_put (drivers/nvme/target/fc.c:845 ./include/linux/kref.h:65 drivers/nvme/target/fc.c:855)
[ 755.639172][ T62] nvmet_fc_free_fcp_iod (drivers/nvme/target/fc.c:742)
[ 755.639183][ T62] __nvmet_req_complete (drivers/nvme/target/core.c:800)
[ 755.639228][ T62] nvmet_req_init (drivers/nvme/target/core.c:1228)
[ 755.639235][ T62] nvmet_fc_queue_fcp_req (drivers/nvme/target/fc.c:2574 drivers/nvme/target/fc.c:703)
[ 755.639309][ T62] nvmet_fc_rcv_fcp_req (drivers/nvme/target/fc.c:2706)
[ 755.639320][ T62] fcloop_fcp_recv_work (drivers/nvme/target/fcloop.c:695)
[ 755.639326][ T62] process_scheduled_works (kernel/workqueue.c:3314 kernel/workqueue.c:3397)
[ 755.639334][ T62] worker_thread (kernel/workqueue.c:3478)
[ 755.639346][ T62] kthread (kernel/kthread.c:436)
[ 755.639361][ T62] ret_from_fork (arch/x86/kernel/process.c:158)
[ 755.639382][ T62] ret_from_fork_asm (arch/x86/entry/entry_64.S:245)
[ 755.639388][ T62] </TASK>
[ 755.639391][ T62]
[ 755.695276][ T62] Freed by task 8206 on cpu 1 at 750.648915s:
[ 755.695819][ T62] kasan_save_track (mm/kasan/common.c:57 mm/kasan/common.c:78)
[ 755.696265][ T62] kasan_save_free_info (mm/kasan/generic.c:584)
[ 755.696716][ T62] __kasan_slab_free (mm/kasan/common.c:253 mm/kasan/common.c:285)
[ 755.697150][ T62] kfree (./include/linux/kasan.h:235 mm/slub.c:2689 mm/slub.c:6251 mm/slub.c:6566)
[ 755.697522][ T62] nvmet_fc_delete_assoc_work (drivers/nvme/target/fc.c:1071)
[ 755.698028][ T62] process_scheduled_works (kernel/workqueue.c:3314 kernel/workqueue.c:3397)
[ 755.698518][ T62] worker_thread (kernel/workqueue.c:3478)
[ 755.698929][ T62] kthread (kernel/kthread.c:436)
[ 755.699300][ T62] ret_from_fork (arch/x86/kernel/process.c:158)
[ 755.699713][ T62] ret_from_fork_asm (arch/x86/entry/entry_64.S:245)
[ 755.700142][ T62]
[ 755.700357][ T62] The buggy address belongs to the object at ffff8881789bd000
[ 755.700357][ T62] which belongs to the cache kmalloc-2k of size 2048
[ 755.701604][ T62] The buggy address is located 16 bytes inside of

Best,
Shuangpeng

#1 lore raw

Hi Shuangpeng,

I will look into this and get back to you, but typically the nvme target fcloop module does not indicate a real life issue when utilizing the nvmet-fc stack on actual fibre channel hardware.

Quoted 1 line

on commit: e8c2f9fdadee7cbc75134dc463c1e0d856d6e5c7 (May 25 2026)

Was wondering what this means?  Because it doesn’t look like that is an nvme commit.

Regards,
Justin

author
#2 lore raw

Hi Justin,

Thanks for taking a look.

Just to clarify, the commit e8c2f9fdadee7cbc75134dc463c1e0d856d6e5c7 is only the upstream kernel revision that I tested on. I did not mean to suggest that this commit introduced the bug, or that it is an NVMe-specific commit.

Regarding fcloop, thanks for pointing that out. I understand that nvme-fcloop is a loopback transport and may not directly represent a deployment with physical Fibre Channel hardware. I used it because it provides an in-tree way to trigger the nvmet-fc target path from userspace without requiring hardware.

Best,
Shuangpeng

Quoted 11 lines · Justin Tee

Hi Shuangpeng,

I will look into this and get back to you, but typically the nvme target fcloop module does not indicate a real life issue when utilizing the nvmet-fc stack on actual fibre channel hardware.

Quoted 1 line

on commit: e8c2f9fdadee7cbc75134dc463c1e0d856d6e5c7 (May 25 2026)

Was wondering what this means? Because it doesn’t look like that is an nvme commit.

Regards,
Justin