Received: by 2002:a25:e7d8:0:0:0:0:0 with SMTP id e207csp2535935ybh; Mon, 9 Mar 2020 07:51:10 -0700 (PDT) X-Google-Smtp-Source: ADFU+vtXjOvnfgo5DOlvXSZjHCFrn+1VdE+PpnWEwnad5gWEeaijU8RKmF1wipnE1VBGYeF4KT3B X-Received: by 2002:a05:6830:1684:: with SMTP id k4mr13777117otr.75.1583765470333; Mon, 09 Mar 2020 07:51:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1583765470; cv=none; d=google.com; s=arc-20160816; b=obZCXExACnTzdVDKS3lXbchPyvTa8zSru/XZTStLITH+mTI76/zrIOjPIvSIQbH2rX Z+9a65c2y+ZITky2yt2Br6FSWwhdHZUcXvOpsVfa0/lhHquL6N5WAx3hACHBRAdGEjZ6 goQvQ+y/YJmavEfsvSv3Ktlm4fMMLZ/p1qQ6ThZ0YSYypghmjfZBrwDyUB8MWl2SjARs cZ70sLGnIBA0dWjT7hchByng+2cw63aqA0NsJIpsK6PBQlejAe96bWwhTZbxwjv1KdVx kBhi0T9QoSz1MqLtISMAwIXnGAaJoDE4GvwG+fvaW1QhxFFginXp59F83vSqHqtgdqSA KaIQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:message-id:in-reply-to:date:references:subject:cc:to :from; bh=z7VK7XPmcPHtLrUFPR3g4gEeC2GJFHYBOz1W3ykFrkY=; b=BLncpOADpmppsUWxPwJUwAXwTSCGhWq892CdYHGybZcYL7ywtn1o4eBbIo5w2zxopg BEg0fOxlWZfZQIXz1spS/u3lCT7X0Nq8PjJyvtXMhrhQmmk6q9UxnBg1JW4MrjOkkiZf ZyBUH6jqLZVwKwfI8mmCVs4AYWY2vqEw7GZM5EZagX7klvJ+9Mc0wzLfs+4WEW8K7Hzm nYGWhMAirB40p9Y8QCxmflBkiw6xlbHCPjzifx8XpZTjyyCUdJNDfT17XkKuP5JTy4HM gXsJ0ZtwVlj+87j/WHw5BdduJFj20fWnAoM95hHCTn2jfH5eTLUQYhpXHvir9XvyUGH0 /OlQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d83si2387305oig.5.2020.03.09.07.50.57; Mon, 09 Mar 2020 07:51:10 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726774AbgCIOum convert rfc822-to-8bit (ORCPT + 99 others); Mon, 9 Mar 2020 10:50:42 -0400 Received: from unicorn.mansr.com ([81.2.72.234]:54228 "EHLO unicorn.mansr.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726650AbgCIOum (ORCPT ); Mon, 9 Mar 2020 10:50:42 -0400 X-Greylist: delayed 580 seconds by postgrey-1.27 at vger.kernel.org; Mon, 09 Mar 2020 10:50:42 EDT Received: by unicorn.mansr.com (Postfix, from userid 51770) id 727D415F11; Mon, 9 Mar 2020 14:41:01 +0000 (GMT) From: =?iso-8859-1?Q?M=E5ns_Rullg=E5rd?= To: Bin Liu Cc: Greg Kroah-Hartman , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] usb: musb: fix crash with highmen PIO and usbmon References: <20200307130720.16652-1-mans@mansr.com> <20200309140106.GA31115@iaqt7> Date: Mon, 09 Mar 2020 14:41:01 +0000 In-Reply-To: <20200309140106.GA31115@iaqt7> (Bin Liu's message of "Mon, 9 Mar 2020 09:01:06 -0500") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8BIT Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Bin Liu writes: > Hi Mans, > > On Sat, Mar 07, 2020 at 01:07:20PM +0000, Mans Rullgard wrote: >> When handling a PIO bulk transfer with highmem buffer, a temporary >> mapping is assigned to urb->transfer_buffer. After the transfer is >> complete, an invalid address is left behind in this pointer. This is >> not ordinarily a problem since nothing touches that buffer before the >> urb is released. However, when usbmon is active, usbmon_urb_complete() >> calls (indirectly) mon_bin_get_data() which does access the transfer >> buffer if it is set. To prevent an invalid memory access here, reset >> urb->tranfer_buffer to NULL when finished. >> >> Fixes: 8e8a55165469 ("usb: musb: host: Handle highmem in PIO mode") >> Signed-off-by: Mans Rullgard > > Thanks for fixing the bug. > >> --- >> drivers/usb/musb/musb_host.c | 8 ++++++-- >> 1 file changed, 6 insertions(+), 2 deletions(-) >> >> diff --git a/drivers/usb/musb/musb_host.c b/drivers/usb/musb/musb_host.c >> index 1c813c37462a..b67b40de1947 100644 >> --- a/drivers/usb/musb/musb_host.c >> +++ b/drivers/usb/musb/musb_host.c >> @@ -1459,8 +1459,10 @@ void musb_host_tx(struct musb *musb, u8 epnum) >> qh->segsize = length; >> >> if (qh->use_sg) { >> - if (offset + length >= urb->transfer_buffer_length) >> + if (offset + length >= urb->transfer_buffer_length) { >> qh->use_sg = false; >> + urb->transfer_buffer = NULL; >> + } > > In this tx case, can you directly pass qh->sg_miter.addr to > musb_write_fifo() so that urb->transfer_buffer is not touched at all? Yes, that seems to work. I'll prepare a new patch. -- M?ns Rullg?rd