Received: by 2002:a25:e7d8:0:0:0:0:0 with SMTP id e207csp2488494ybh; Mon, 9 Mar 2020 06:56:55 -0700 (PDT) X-Google-Smtp-Source: ADFU+vtDIp6EXPQx+rUrHpoBCQZ2wuR8QmeyNPzNfdnxNVxbHRVJTs9QtzVIFVwovndTMeqTQd+Y X-Received: by 2002:a54:4f16:: with SMTP id e22mr11732736oiy.170.1583762215351; Mon, 09 Mar 2020 06:56:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1583762215; cv=none; d=google.com; s=arc-20160816; b=GG/cCvYfm4nokXZ01Tl3OpeEN/LtSEo+K4KZcGX8r6dAJ20J4V+X8OTi1LjRMAd2NI psU5Uaiy97DtppoE9RK2FCinYv4Peb+tAe49phBL7v1e/bBnJTa2W1tzLvrHJYevfkgh EVJaLMByJHOPc57XhKwxwcLv2PGaIqcJvXsPZWX9tQEEciclzFpcPDl8fxpHutjAfndf MPUUpMK9jz5RgaqvF0HpNWaULLHBGvjNp0z200ZP8m1olyQ7cMaY5NnF66Ib0WBExEQV zG0lRBzoTJlcE1+7Khjn62S+eQvCmPhISAiICFCz+vbZe3HrWoexL9kJtlG7vWtdK5fl qdxA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:mail-followup-to :message-id:subject:cc:to:from:date:dkim-signature; bh=nDBAlUhcSYBKIaek9S1ySWQkNuPZQhpRQxOxLs4U7cE=; b=zeyaRj6qCP4e2Dlg2+6NQRb1vqbJ8P0npujo5W9npQHDCLCCON60HMbwIdzWO3pNfr pmjFxh6Yx1WWLbW1aF84s+M992E3/KPvUCz5Fje5HwBHHO1NzmURiFnRMm4Ka1Qd7a6g ge345kv+oWZIiDbi66yV3HTwqa0KJgOD25SQJYL0Vs/X7KjreoKM5FqFMbzvNvOSJpGc vdLjWEpjhG5321nbRboCQRffoN6gDpO38Zd3IfhqsG0wboQezaJ43Srl/3oRrGVjSfvl t4gl7N9SAXV5Mkya8NTv4OSa+xguV9RDdlz+pRwc44DKmCBiL0VlJhoQK+u7TyrkFF5k Q8VQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=V8BRRqr6; 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; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c6si1882799otm.298.2020.03.09.06.56.42; Mon, 09 Mar 2020 06:56:55 -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; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=V8BRRqr6; 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; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726718AbgCINzX (ORCPT + 99 others); Mon, 9 Mar 2020 09:55:23 -0400 Received: from lelv0143.ext.ti.com ([198.47.23.248]:38306 "EHLO lelv0143.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726383AbgCINzX (ORCPT ); Mon, 9 Mar 2020 09:55:23 -0400 Received: from fllv0035.itg.ti.com ([10.64.41.0]) by lelv0143.ext.ti.com (8.15.2/8.15.2) with ESMTP id 029DtIPs108459; Mon, 9 Mar 2020 08:55:18 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1583762118; bh=nDBAlUhcSYBKIaek9S1ySWQkNuPZQhpRQxOxLs4U7cE=; h=Date:From:To:CC:Subject:References:In-Reply-To; b=V8BRRqr6EvVSnOntUmqDr4NLvCn+zNh9LErK5iKjxYPVCxLV9OVsGN5N+t+Lwe+6O g8UuXQHrPFlkG/t6/KucVXFIwNBqWRo1VTpcUfGdp7MtU5p+PqD86rPeQ37QekXQPG B63coBjq83kycoNHCK75JePHvc+mdSbkm7ykdWRE= Received: from DLEE104.ent.ti.com (dlee104.ent.ti.com [157.170.170.34]) by fllv0035.itg.ti.com (8.15.2/8.15.2) with ESMTP id 029DtIrN033581; Mon, 9 Mar 2020 08:55:18 -0500 Received: from DLEE111.ent.ti.com (157.170.170.22) by DLEE104.ent.ti.com (157.170.170.34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1847.3; Mon, 9 Mar 2020 08:55:18 -0500 Received: from localhost.localdomain (10.64.41.19) by DLEE111.ent.ti.com (157.170.170.22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1847.3 via Frontend Transport; Mon, 9 Mar 2020 08:55:17 -0500 Received: from localhost (ileax41-snat.itg.ti.com [10.172.224.153]) by localhost.localdomain (8.15.2/8.15.2) with ESMTP id 029DtHbS087470; Mon, 9 Mar 2020 08:55:17 -0500 Date: Mon, 9 Mar 2020 09:01:06 -0500 From: Bin Liu To: Mans Rullgard CC: Greg Kroah-Hartman , , Subject: Re: [PATCH] usb: musb: fix crash with highmen PIO and usbmon Message-ID: <20200309140106.GA31115@iaqt7> Mail-Followup-To: Bin Liu , Mans Rullgard , Greg Kroah-Hartman , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org References: <20200307130720.16652-1-mans@mansr.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: <20200307130720.16652-1-mans@mansr.com> User-Agent: Mutt/1.9.4 (2018-02-28) X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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? -Bin.