From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754869AbdKAQjg (ORCPT ); Wed, 1 Nov 2017 12:39:36 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:59128 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751653AbdKAQjf (ORCPT ); Wed, 1 Nov 2017 12:39:35 -0400 Date: Wed, 1 Nov 2017 17:39:47 +0100 From: Greg Kroah-Hartman To: Mathias Nyman Cc: Jeffy Chen , linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org Subject: Re: [PATCH] xhci: Cancel cmd_timer before cleanup the command queue in xhci_hc_died() Message-ID: <20171101163947.GA8206@kroah.com> References: <20170929091247.28604-1-jeffy.chen@rock-chips.com> <20171101160336.GA22440@kroah.com> <59F9F611.2050607@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <59F9F611.2050607@intel.com> User-Agent: Mutt/1.9.1 (2017-09-22) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Nov 01, 2017 at 06:28:01PM +0200, Mathias Nyman wrote: > On 01.11.2017 18:03, Greg Kroah-Hartman wrote: > > On Fri, Sep 29, 2017 at 05:12:47PM +0800, Jeffy Chen wrote: > > > When the cmd_timer fired, it would try to access the command struct. > > > So cancel it before cleanup the command queue in xhci_hc_died(), to > > > avoid use-after-free reported by KASAN: > > > [ 176.952537] BUG: KASAN: use-after-free in xhci_handle_command_timeout+0x68/0x224 > > > [ 176.960846] Write of size 4 at addr ffffffc0cbb01608 by task kworker/3:3/1680 > > > ... > > > [ 177.180644] Freed by task 0: > > > [ 177.183882] kasan_slab_free+0x90/0x15c > > > [ 177.188194] kfree+0x114/0x28c > > > [ 177.191630] xhci_cleanup_command_queue+0xc8/0xf8 > > > [ 177.196916] xhci_hc_died+0x84/0x358 > > > > > > Fixes: d9f11ba9f107 ("xhci: Rework how we handle unresponsive or hoptlug removed hosts") > > > Signed-off-by: Jeffy Chen > > > --- > > > > Mathias, did you miss this one? Want me to queue it up? > > > > There is a v2 of that patch already upstreamed. > > d1aad52 xhci: Cleanup current_cmd in xhci_cleanup_command_queue() > > https://marc.info/?l=linux-usb&m=150668331802206&w=2 > > A bit confusing as patch subject changed as well in v2 Ah, thanks, missed that. greg k-h