From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-qt1-f182.google.com (mail-qt1-f182.google.com [209.85.160.182]) (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 D289A7E0E4 for ; Tue, 18 Aug 2026 15:58:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.182 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787068697; cv=none; b=ZKYHzs2KdYMQhJ3vMpwp0hEPkAuaFKRZDBU19MahIgSYVZwTZMq0ELUdqGEnZH1pPNRGKUfQw31wE+4Sv7gPYqy1d8DX91ipbmrU/A/0t8XSnSWNlIF1jmocOCR1u+4u4dYqdsJxVa35cEUIOVJyYjmk0CnYWD3o+J/E54zifWE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787068697; c=relaxed/simple; bh=EMjJvFYFUyo0jlLVoUwq56z0iM/h3bzklSv/vgkbFbc=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=qVmHv9kbt4i+yqVrPIsu/HUuJwby71EGbG0hjjsrrfCPTfqqaH7jLIkk5xvzSBpFkBPcZVbRyif8eUBp7qRn5Hr/y1UMf7dCY87DzQ3k7Umnm8qPTNstDJTbBrXlc6r/EeMk2nfWFTFGpcql8pDmen/wOeWl1iwNsmpi8NSX/qw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=rowland.harvard.edu; spf=fail smtp.mailfrom=g.harvard.edu; dkim=pass (2048-bit key) header.d=rowland.harvard.edu header.i=@rowland.harvard.edu header.b=FzK0g3hq; arc=none smtp.client-ip=209.85.160.182 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=rowland.harvard.edu Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=g.harvard.edu Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=rowland.harvard.edu header.i=@rowland.harvard.edu header.b="FzK0g3hq" Received: by mail-qt1-f182.google.com with SMTP id d75a77b69052e-51c04bf4711so46480151cf.2 for ; Tue, 18 Aug 2026 08:58:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rowland.harvard.edu; s=google; t=1787068694; x=1787673494; darn=vger.kernel.org; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:from:to:cc:subject :date:message-id:reply-to:content-type; bh=aLFK+CS/9o2sBuETagn7m9l+5x3yjhHN6Gg3zPg3uG0=; b=FzK0g3hqBfL0V53wKz20DuK0UV3ivE4fpzYja7IdKK2GiYuAhxRMi2y6Qwcf5qVKNj HzK5cBaikEahvq8fcGIsEPglYk/14CXwOLcURlnQqFeNn4L+nTuBGIi1NXDAcXWundog U8OP/lFSU4GTmEnuTylgwVjfBl4c6pNtdbPnyTE/OqRGo0i+T/mFYxIPRC3fFlVdrovT UVe2TeCp2+Htf0Vma3jpf4SUAh3rxF0/HDE6b54FCmocBDajNLs2T7MeTLeVz0zk2ZGt tnq1oZ+MPepLym8ElVYV7sarl0Gav2va2lBVrOnzdlHnfyJ5Zp5xEmF+/zxj3zoJ0zSS gtQQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1787068694; x=1787673494; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=aLFK+CS/9o2sBuETagn7m9l+5x3yjhHN6Gg3zPg3uG0=; b=GFhs6QsggOycSH7icmgyPKp5WS8arcj6RmLLUAVEvXK+nCm0SdWRm9rQeyFJ1qXztc +lTynfjHf2Td8zZHWZm2um9FA5eKP6M3GWa25pWalvB0PwuxO2CRbw2gzbhl/DOQr+L+ 4us21ZwKuQefdPomiq8UkxYlm2w6vL28pRcrEOcKalm+NushWAjoXRP/ojLn6d+v3NOa 2CK/WTBjEOkmd9VKJbwsuNAxcOnQlR2w+6fFxl/CnD0bDMEBt6SYcMSec2v5eHtO3JIL ydesMgLQ7urdbVpQPmvDvrUIiPGNUU5vNAO14M0fhT0cEGLPv04WiMywUrk0DInBrTjB CMtA== X-Forwarded-Encrypted: i=1; AHgh+Rr45LOJCI/TrjaIp2TrnQ/Rq+7IsAacD3iJ0Q77+BWLEThHNxgJgfjqEEWSMJrrf2KeKJ25SJzv8AbOBVM=@vger.kernel.org X-Gm-Message-State: AOJu0YxPxh9qBlRD4USHtoel57oj3n61FujMlVUDAYJSDbj2BcfCFr8a bt5hgcvCgbG3wMrNGCCPYf6nlNZH7rpljVlIvxBuLtl7jMerNe12GlXAHdabEEqxug== X-Gm-Gg: AR+sD113OrweYhYqx7HCSAe1eLkvJD2BU3EDIEV2Fu32iCkbeBRwvFQNLLwn5118W1p mRjeVImFuj6Jb5F7q8yOs/reNH/o/bubEfMKFWmJNVl9pTGwhtwljad1wY1rq0R0CwRB9du/AH8 mnyV3mowKe7qejSUvXErCoaZPWB4mCqY7dGl1EfUKNgE+B6mrgE1zeNlVgYbnrR/hjMrZPfiswM gmyOgeleMshZ6umTW5H7NlpchC57oMrVMWz7CGDsQW5KwfRJ6ThJpE9T5cz3+IXlfwOqAP0wDQy 1N6DvOHTuGxg88CnX58lYxl6E5m6cCN78q7RoQIYQb4Nxi4Tppp+P/Idr0m8ohBYyZyy1OG9M5Q KNda/NtVSbmkEYjlYAcALfcnY40JNR9AzcN4aVvvNtoqhjTjZIhQOQFMmV3ZIdkbGV6rXwFBEGA Azq2qsNZI8z6UPB02YNpt6v3Rv0CH+D0AwZIvjZJAc5D6SDej9xyjYrp8ICa55u5x2bhkAG5vEN A== X-Received: by 2002:ac8:5cd1:0:b0:52d:5e88:4246 with SMTP id d75a77b69052e-52d8534c2ffmr396037101cf.16.1787068694013; Tue, 18 Aug 2026 08:58:14 -0700 (PDT) Received: from rowland.harvard.edu ([2601:19b:d01:d210::dfd8]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-90c4597568fsm34614046d6.39.2026.08.18.08.58.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Aug 2026 08:58:12 -0700 (PDT) Date: Tue, 18 Aug 2026 11:58:10 -0400 From: Alan Stern To: Vaibhav Nagare Cc: gregkh@linuxfoundation.org, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org, Vaibhav Nagare Subject: Re: [PATCH] usb: ehci: fix QTD list corruption in qh_completions Message-ID: <03dec848-580a-476c-bdc4-8a8b9d2e80e9@rowland.harvard.edu> References: <20260818083323.2270580-1-vnagare@redhat.com> 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=us-ascii Content-Disposition: inline In-Reply-To: <20260818083323.2270580-1-vnagare@redhat.com> On Tue, Aug 18, 2026 at 02:03:23PM +0530, Vaibhav Nagare wrote: > In qh_completions(), when completing a URB at a URB boundary > (last->urb != urb), ehci_urb_done() is called which drops ehci->lock > via usb_hcd_giveback_urb() for the completion callback. While the lock > is dropped, a concurrent ehci_urb_dequeue() (e.g. from a TX timeout > recovery) can modify the QTD list, making the 'tmp' pointer saved by > list_for_each_safe() stale. Continuing iteration with a stale pointer > leads to list_del() corruption and a kernel panic: > > list_del corruption. prev->next should be ff27e4e01aefa580, > but was ff27e4e01aefa1c0 > kernel BUG at lib/list_debug.c:51! > Call Trace: > qh_completions+0x28f/0x640 > ehci_work.part.0+0x1d5/0x330 > ehci_irq+0x3d2/0x490 > > This was observed on systems with an HPE iLO5 Virtual NIC (cdc_ncm) > where repeated NETDEV WATCHDOG TX timeouts trigger concurrent URB > unlinks that race with the qh_completions lock-drop window. > > Fix this by freeing the completed QTD and restarting the list scan > via the existing rescan label after ehci_urb_done(). This is safe > because already-processed QTDs have been removed via list_del() and > the list is strictly shrinking, guaranteeing forward progress. This is good thing to fix, but have you considered what should happen to the "end" ehci_qtd pointer when the scan is restarted? Alan Stern > > Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") > Cc: stable@vger.kernel.org > Signed-off-by: Vaibhav Nagare > --- > drivers/usb/host/ehci-q.c | 11 ++++++++++- > 1 file changed, 10 insertions(+), 1 deletion(-) > > diff --git a/drivers/usb/host/ehci-q.c b/drivers/usb/host/ehci-q.c > index ba37a9fcab92..c715648e97ab 100644 > --- a/drivers/usb/host/ehci-q.c > +++ b/drivers/usb/host/ehci-q.c > @@ -328,7 +328,16 @@ qh_completions (struct ehci_hcd *ehci, struct ehci_qh *qh) > if (last) { > if (likely (last->urb != urb)) { > ehci_urb_done(ehci, last->urb, last_status); > - last_status = -EINPROGRESS; > + /* > + * ehci_urb_done() drops ehci->lock for the > + * completion callback. The QTD list may have > + * been modified (e.g. by URB unlink during > + * TX timeout recovery). The 'tmp' saved by > + * list_for_each_safe() may be stale. > + * Free last and restart the scan. > + */ > + ehci_qtd_free(ehci, last); > + goto rescan; > } > ehci_qtd_free (ehci, last); > last = NULL; > -- > 2.54.0 >