From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751277AbdJBLpN (ORCPT ); Mon, 2 Oct 2017 07:45:13 -0400 Received: from mga05.intel.com ([192.55.52.43]:43156 "EHLO mga05.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751031AbdJBLpL (ORCPT ); Mon, 2 Oct 2017 07:45:11 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.42,469,1500966000"; d="scan'208";a="905835859" Subject: Re: [PATCH v2] xhci: Cleanup current_cmd in xhci_cleanup_command_queue() To: Jeffy Chen , linux-kernel@vger.kernel.org References: <20170929110757.25345-1-jeffy.chen@rock-chips.com> Cc: Greg Kroah-Hartman , linux-usb@vger.kernel.org, Mathias Nyman From: Mathias Nyman Message-ID: <59D227AB.30906@linux.intel.com> Date: Mon, 2 Oct 2017 14:48:59 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.8.0 MIME-Version: 1.0 In-Reply-To: <20170929110757.25345-1-jeffy.chen@rock-chips.com> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 29.09.2017 14:07, Jeffy Chen wrote: > KASAN reported use-after-free bug when xhci host controller died: > [ 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 > > Problem here is that when the cmd_timer fired, it would try to access > current_cmd while the command queue is already freed by xhci_hc_died(). > > Cleanup current_cmd in xhci_cleanup_command_queue() to avoid that. > > Fixes: d9f11ba9f107 ("xhci: Rework how we handle unresponsive or hoptlug removed hosts") > Signed-off-by: Jeffy Chen > --- > > Thanks, adding patch to queue -Mathias