From nobody Thu Apr 9 13:33:12 2026 Received: from mail-yx1-f46.google.com (mail-yx1-f46.google.com [74.125.224.46]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3A6DB33E348 for ; Sun, 8 Mar 2026 18:22:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.224.46 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772994130; cv=none; b=QUDe/1FefXctAxa0tu/UsOPmTjCdA/4btXSOG0Kw9pSer5PQsEa/TE87ulxWpUk8VXRbgjpPTWvFScE8mCgWFKzS19pxRfk0SpiqC4ei9BuUiwLziSsiVItkHYAKIyZAtLb+gFW4QVsvxqK0X5/6X6LkMhbRsfJahiYHSvPmkLc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772994130; c=relaxed/simple; bh=tEZyXOsYD3FpGZih561jzbNl2r8vdN2rDWyn49tFUvo=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version:Content-Type; b=fqe0EoZdDdTKs74qr6DPOZm6pLMOYrg1+ylHQO7c2fWeW2ak2g7n+UdNG5rCiqc7kTfSMBEwVeoRCn88ACG3yIWDwWsW1CUwOaQZjiyRxz+A5EEDIKz71WfgJsuCD9FyOq7PBktcrExC7mSIV22FbQnLSgsgx3NtATXuRh3472Y= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=sung-woo.kim; spf=pass smtp.mailfrom=gmail.com; arc=none smtp.client-ip=74.125.224.46 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=sung-woo.kim Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-yx1-f46.google.com with SMTP id 956f58d0204a3-64ad79df972so10204769d50.1 for ; Sun, 08 Mar 2026 11:22:09 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1772994128; x=1773598928; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=ilk3tNOoXXOCLpqUtRhYgurzM03IKV8lFQCWmDJAaOY=; b=U0mTmkjOcqKypVrjZrLRSnhlSRTyiBnSU0Z1oM3XMpw5MEH6UirI7PiAdvissdJR/l pTkr554RZ2webb5YCcLIeobLqNjzpw/TGWvDV5ED9C0UKTRdSyJDhX9tKxB1ygWeknMN gwhSu35BqrlmzsbZdyQwrR0jWvS6ItYyT74L/Nl1b72EQmXP/X0p2Ch23+ghtSK2Rbtf 2GfQGJ+192euUE2IjnbIh+dhizM2grXFNFf0M7WE18Y3ua621HphSaDSIEquWHsi5wvh EfwJ7/09HVJk067PUXvEtpP4qgZhOAHtEb4KGYxrmBEec6y/A98h80d7xO/MIpaFGbMr NDlA== X-Forwarded-Encrypted: i=1; AJvYcCU0At8HSRLn+4+k3sXX2mKhwIG11u7NEnc/Oee2MqJtyr0FCR/kLnm0oFcCJd+/kvxET8vn091COvXblKI=@vger.kernel.org X-Gm-Message-State: AOJu0YzoYI+SautrxZ/owfYk7vYKo230Z8Sz+ieCJN5jpyWaD/Ulwv91 YS0lHg5HDF9uWaBcA/PN09zRtH43t0IQlX8/wFz6F2Hw2paLeFZ+kVbL X-Gm-Gg: ATEYQzwsnxslb6JlLt/6l7O9Rt3rk4RhXw2W9g8izT30r3CyuHTL05D7SQz0wLHgjVJ Qa8auzz0qF8n/dmSq+XvX623yTBxal+g7Yy8ZzxVvrLr4P0V19axgi+q7WPGaIALa8zdKpWpuYM +OsnQyXwsirZZq8ZKgnr6gChxpDSTLtzkZnA+KCSF+PnELY2r6ABcjCsrYuHghHdXKoWoPMBHmV /ayJBXmgjy2DcT536nUnmJUN2K8FTa8A3ImDbUlKinvmZB8Ehh9OqDhMGnYmHf9mDZKUmD94Nfl jJXOLGDv+NLyc3G3FpKbFIrcRErLtAsQs8kxdr4yUgDuDLcGv3UzN4dzGYuxlMq9X7IHjz05RgV TbHc1hEdvc2IOGPGz2Gb31hO92rqRYZKtvKBdh2usoHOrGgaYtmQz//GPcuAQX/4UhZKxwlm/xh 2BPG6gNfZlFw== X-Received: by 2002:a05:690e:1c21:b0:64c:f872:bee9 with SMTP id 956f58d0204a3-64d140626d9mr9098803d50.11.1772994128223; Sun, 08 Mar 2026 11:22:08 -0700 (PDT) Received: from tofu.. ([128.210.0.165]) by smtp.googlemail.com with ESMTPSA id 956f58d0204a3-64d175d2f31sm3598649d50.5.2026.03.08.11.22.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 08 Mar 2026 11:22:07 -0700 (PDT) From: Sungwoo Kim To: Keith Busch , Jens Axboe , Christoph Hellwig , Sagi Grimberg , Minwoo Im Cc: Sungwoo Kim , Chao Shi , Weidong Zhu , Dave Tian , linux-nvme@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH] Fix slab-out-of-bounds in nvme_dbbuf_set Date: Sun, 8 Mar 2026 14:20:59 -0400 Message-ID: <20260308182059.2415316-2-iam@sung-woo.kim> X-Mailer: git-send-email 2.47.3 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable dev->online_queues is a count incremented in nvme_init_queue. Thus, valid indices are 0 through dev->online_queues =E2=88=92 1. This patch fixes the loop condition to ensure the index stays within the valid range. Index 0 is excluded because it is the admin queue. KASAN splat: =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D BUG: KASAN: slab-out-of-bounds in nvme_dbbuf_free drivers/nvme/host/pci.c:3= 77 [inline] BUG: KASAN: slab-out-of-bounds in nvme_dbbuf_set+0x39c/0x400 drivers/nvme/h= ost/pci.c:404 Read of size 2 at addr ffff88800592a574 by task kworker/u8:5/74 CPU: 0 UID: 0 PID: 74 Comm: kworker/u8:5 Not tainted 6.19.0-dirty #10 PREEM= PT(voluntary) Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.16.3-0-ga= 6ed6b701f0a-prebuilt.qemu.org 04/01/2014 Workqueue: nvme-reset-wq nvme_reset_work Call Trace: __dump_stack lib/dump_stack.c:94 [inline] dump_stack_lvl+0xea/0x150 lib/dump_stack.c:120 print_address_description mm/kasan/report.c:378 [inline] print_report+0xce/0x5d0 mm/kasan/report.c:482 kasan_report+0xdc/0x110 mm/kasan/report.c:595 __asan_report_load2_noabort+0x18/0x20 mm/kasan/report_generic.c:379 nvme_dbbuf_free drivers/nvme/host/pci.c:377 [inline] nvme_dbbuf_set+0x39c/0x400 drivers/nvme/host/pci.c:404 nvme_reset_work+0x36b/0x8c0 drivers/nvme/host/pci.c:3252 process_one_work+0x956/0x1aa0 kernel/workqueue.c:3257 process_scheduled_works kernel/workqueue.c:3340 [inline] worker_thread+0x65c/0xe60 kernel/workqueue.c:3421 kthread+0x41a/0x930 kernel/kthread.c:463 ret_from_fork+0x6f8/0x8c0 arch/x86/kernel/process.c:158 ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:246 Allocated by task 34 on cpu 1 at 4.241550s: kasan_save_stack+0x2c/0x60 mm/kasan/common.c:57 kasan_save_track+0x1c/0x70 mm/kasan/common.c:78 kasan_save_alloc_info+0x3c/0x50 mm/kasan/generic.c:570 poison_kmalloc_redzone mm/kasan/common.c:398 [inline] __kasan_kmalloc+0xb5/0xc0 mm/kasan/common.c:415 kasan_kmalloc include/linux/kasan.h:263 [inline] __do_kmalloc_node mm/slub.c:5657 [inline] __kmalloc_node_noprof+0x2bf/0x8d0 mm/slub.c:5663 kmalloc_array_node_noprof include/linux/slab.h:1075 [inline] nvme_pci_alloc_dev drivers/nvme/host/pci.c:3479 [inline] nvme_probe+0x2f1/0x1820 drivers/nvme/host/pci.c:3534 local_pci_probe+0xef/0x1c0 drivers/pci/pci-driver.c:324 pci_call_probe drivers/pci/pci-driver.c:392 [inline] __pci_device_probe drivers/pci/pci-driver.c:417 [inline] pci_device_probe+0x743/0x920 drivers/pci/pci-driver.c:451 call_driver_probe drivers/base/dd.c:583 [inline] really_probe+0x29b/0xb70 drivers/base/dd.c:661 __driver_probe_device+0x3b0/0x4a0 drivers/base/dd.c:803 driver_probe_device+0x56/0x1f0 drivers/base/dd.c:833 __driver_attach_async_helper+0x155/0x340 drivers/base/dd.c:1159 async_run_entry_fn+0xa6/0x4b0 kernel/async.c:129 process_one_work+0x956/0x1aa0 kernel/workqueue.c:3257 process_scheduled_works kernel/workqueue.c:3340 [inline] worker_thread+0x65c/0xe60 kernel/workqueue.c:3421 kthread+0x41a/0x930 kernel/kthread.c:463 ret_from_fork+0x6f8/0x8c0 arch/x86/kernel/process.c:158 ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:246 The buggy address belongs to the object at ffff88800592a000 which belongs to the cache kmalloc-2k of size 2048 The buggy address is located 244 bytes to the right of allocated 1152-byte region [ffff88800592a000, ffff88800592a480) The buggy address belongs to the physical page: page: refcount:0 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x5928 head: order:3 mapcount:0 entire_mapcount:0 nr_pages_mapped:0 pincount:0 anon flags: 0xfffffc0000040(head|node=3D0|zone=3D1|lastcpupid=3D0x1fffff) page_type: f5(slab) raw: 000fffffc0000040 ffff888001042000 0000000000000000 dead000000000001 raw: 0000000000000000 0000000000080008 00000000f5000000 0000000000000000 head: 000fffffc0000040 ffff888001042000 0000000000000000 dead000000000001 head: 0000000000000000 0000000000080008 00000000f5000000 0000000000000000 head: 000fffffc0000003 ffffea0000164a01 00000000ffffffff 00000000ffffffff head: ffffffffffffffff 0000000000000000 00000000ffffffff 0000000000000008 page dumped because: kasan: bad access detected Memory state around the buggy address: ffff88800592a400: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ffff88800592a480: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc >ffff88800592a500: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc ^ ffff88800592a580: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc ffff88800592a600: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D Fixes: 0f0d2c876c96 (nvme: free sq/cq dbbuf pointers when dbbuf set fails) Acked-by: Chao Shi Acked-by: Weidong Zhu Acked-by: Dave Tian Signed-off-by: Sungwoo Kim --- drivers/nvme/host/pci.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c index a7fb88aa8..3c83076a5 100644 --- a/drivers/nvme/host/pci.c +++ b/drivers/nvme/host/pci.c @@ -400,7 +400,7 @@ static void nvme_dbbuf_set(struct nvme_dev *dev) /* Free memory and continue on */ nvme_dbbuf_dma_free(dev); =20 - for (i =3D 1; i <=3D dev->online_queues; i++) + for (i =3D 1; i < dev->online_queues; i++) nvme_dbbuf_free(&dev->queues[i]); } } --=20 2.47.3