From: Greg KH <gregkh@linuxfoundation.org>
To: 徐晗翔 <xuhx@hust.edu.cn>
Cc: stern@rowland.harvard.edu, linux-usb@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: usb: ohci: double dma_pool_destroy of td_cache when the second pool allocation fails in ohci_mem_init()
Date: Fri, 30 Oct 2026 12:46:49 +0100 [thread overview]
Message-ID: <2026103020-acuteness-tree-d8ea@gregkh> (raw)
In-Reply-To: <592c9a2a.1ae54.1a18c9b41db.Coremail.xuhx@hust.edu.cn>
On Fri, Oct 30, 2026 at 07:39:07PM +0800, 徐晗翔 wrote:
> When the second DMA pool allocation in ohci_mem_init() fails, the
> error branch destroys the first pool (td_cache) but leaves
> ohci->td_cache dangling, and ohci_init() then calls the FULL
> ohci_stop() on the failure path -- whose ohci_mem_cleanup() destroys
> the same pool a second time through freed memory: the second
> dma_pool_destroy() re-does list_del on LIST_POISON'ed links (or
> silently corrupts whatever now owns the reused slab object),
> dereferences pool->dev, walks the freed page list double-freeing the
> coherent DMA pages, and kfrees the pool object again. I confirmed it
> deterministically on a pristine Linux 7.3 KASAN kernel by injecting
> exactly the allocation failure (kretprobe flipping the second
> dma_pool_create() return to NULL, equivalent to slab fault
> injection): the very next controller probe produced
> "BUG: KASAN: slab-use-after-free in dma_pool_destroy" with the use
> stack dma_pool_destroy <- ohci_stop <- ohci_init <- ohci_pci_reset <-
> usb_add_hcd and the allocation stack kmalloc <- dma_pool_create_node
> <- ohci_init. The fix is one line (NULL the pointer), and a broader
> cleanup would stop ohci_init()'s failure path from running a full
> ohci_stop() that was designed for started controllers (it also calls
> free_irq() with hcd->irq==0 at this stage, printing "Trying to free
> already-free IRQ 0" on the same path).
Great, please send a patch to fix this. Creating random kernel modules
to break existing kernel modules is a bit odd of a thing to do :)
thanks,
greg k-h
prev parent reply other threads:[~2026-10-30 11:46 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-30 11:39 usb: ohci: double dma_pool_destroy of td_cache when the second pool allocation fails in ohci_mem_init() 徐晗翔
2026-10-30 11:46 ` Greg KH [this message]
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=2026103020-acuteness-tree-d8ea@gregkh \
--to=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=stern@rowland.harvard.edu \
--cc=xuhx@hust.edu.cn \
/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