From: Shuangpeng <shuangpeng.kernel@gmail.com>
To: justin.tee@broadcom.com, nareshgottumukkala83@gmail.com,
paul.ely@broadcom.com, kbusch@kernel.org, axboe@kernel.dk,
sagi@grimberg.me, hch@lst.de
Cc: linux-nvme@lists.infradead.org, linux-kernel@vger.kernel.org
Subject: [BUG] KASAN: slab-use-after-free in nvme_fc_fcpio_done
Date: Thu, 4 Jun 2026 14:22:07 -0400 [thread overview]
Message-ID: <C0EE55F1-9ACD-494A-9EEC-D94EDC220AF9@gmail.com> (raw)
Hi Kernel Maintainers,
I hit the following KASAN report while testing current upstream kernel:
KASAN: slab-use-after-free in nvme_fc_fcpio_done
on upstream commit: e8c2f9fdadee7cbc75134dc463c1e0d856d6e5c7 (May 25 2026)
This was found with nvme-fcloop. A previous fcloop-related report I sent hit
nvmet_fc_tgt_q_put on the target side:
https://lore.kernel.org/linux-nvme/56c826df-efe7-4c48-9142-c32c8e3415a8@gmail.com/
This report is different in that the freed object is the host-side
nvme_fc_ctrl, freed through nvme_sysfs_delete() -> nvme_free_ctrl(), and the
later access happens in nvme_fc_fcpio_done() after fcloop calls the host
completion path.
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/b88810aba94d68ae11ac65b8d1e03a5b
I’m happy to test debug patches or provide additional information.
Reported-by: Shuangpeng Bai <shuangpeng.kernel@gmail.com>
[ 117.632186][ T1165] ==================================================================
[ 117.632793][ T1165] BUG: KASAN: slab-use-after-free in nvme_fc_fcpio_done (./drivers/nvme/host/nvme.h:473 drivers/nvme/host/fc.c:2063)
[ 117.634328][ T1165] Read of size 4 at addr ffff8881269fc3f4 by task kworker/u9:2/1165
[ 117.634865][ T1165]
[ 117.635075][ T1165] 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
[ 117.635078][ T1165] Workqueue: nvmet-wq fcloop_fcp_abort_recv_work
[ 117.635098][ T1165] Call Trace:
[ 117.635108][ T1165] <TASK>
[ 117.635111][ T1165] dump_stack_lvl (lib/dump_stack.c:94 lib/dump_stack.c:120)
[ 117.635145][ T1165] print_report (mm/kasan/report.c:378 mm/kasan/report.c:482)
[ 117.635201][ T1165] kasan_report (mm/kasan/report.c:595)
[ 117.635207][ T1165] nvme_fc_fcpio_done (./drivers/nvme/host/nvme.h:473 drivers/nvme/host/fc.c:2063)
[ 117.635215][ T1165] fcloop_call_host_done (drivers/nvme/target/fcloop.c:607)
[ 117.635219][ T1165] process_scheduled_works (kernel/workqueue.c:3314 kernel/workqueue.c:3397)
[ 117.635232][ T1165] worker_thread (kernel/workqueue.c:3478)
[ 117.635248][ T1165] kthread (kernel/kthread.c:436)
[ 117.635258][ T1165] ret_from_fork (arch/x86/kernel/process.c:158)
[ 117.635297][ T1165] ret_from_fork_asm (arch/x86/entry/entry_64.S:245)
[ 117.635301][ T1165] </TASK>
[ 117.635302][ T1165]
[ 117.644920][ T1165] Freed by task 8162 on cpu 1 at 117.604613s:
[ 117.645351][ T1165] kasan_save_track (mm/kasan/common.c:57 mm/kasan/common.c:78)
[ 117.645683][ T1165] kasan_save_free_info (mm/kasan/generic.c:584)
[ 117.646041][ T1165] __kasan_slab_free (mm/kasan/common.c:253 mm/kasan/common.c:285)
[ 117.646377][ T1165] kfree (./include/linux/kasan.h:235 mm/slub.c:2689 mm/slub.c:6251 mm/slub.c:6566)
[ 117.646664][ T1165] nvme_free_ctrl (drivers/nvme/host/core.c:5102)
[ 117.646997][ T1165] device_release (drivers/base/core.c:2562)
[ 117.647344][ T1165] kobject_put (lib/kobject.c:689 lib/kobject.c:720 ./include/linux/kref.h:65 lib/kobject.c:737)
[ 117.648052][ T1165] nvme_sysfs_delete (drivers/nvme/host/sysfs.c:401)
[ 117.648392][ T1165] kernfs_fop_write_iter (fs/kernfs/file.c:352)
[ 117.648769][ T1165] vfs_write (fs/read_write.c:595 fs/read_write.c:688)
[ 117.649088][ T1165] ksys_write (fs/read_write.c:740)
[ 117.649390][ T1165] do_syscall_64 (arch/x86/entry/syscall_64.c:63 arch/x86/entry/syscall_64.c:94)
[ 117.649737][ T1165] entry_SYSCALL_64_after_hwframe (arch/x86/entry/entry_64.S:121)
[ 117.650124][ T1165]
[ 117.650282][ T1165] The buggy address belongs to the object at ffff8881269fc000
[ 117.650282][ T1165] which belongs to the cache kmalloc-4k of size 4096
[ 117.651226][ T1165] The buggy address is located 1012 bytes inside of
[ 117.651226][ T1165] freed 4096-byte region [ffff8881269fc000, ffff8881269fd000)
Best,
Shuangpeng
reply other threads:[~2026-06-04 18:22 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=C0EE55F1-9ACD-494A-9EEC-D94EDC220AF9@gmail.com \
--to=shuangpeng.kernel@gmail.com \
--cc=axboe@kernel.dk \
--cc=hch@lst.de \
--cc=justin.tee@broadcom.com \
--cc=kbusch@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-nvme@lists.infradead.org \
--cc=nareshgottumukkala83@gmail.com \
--cc=paul.ely@broadcom.com \
--cc=sagi@grimberg.me \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®