Received: by 2002:a25:e7d8:0:0:0:0:0 with SMTP id e207csp570413ybh; Sat, 7 Mar 2020 05:10:54 -0800 (PST) X-Google-Smtp-Source: ADFU+vsiP0JJmAgerEf2hOYVAE+Loj5HBpusBKvGVTzXZb4+Pxl4TNVa0BIFeZsWvLOAmQYS+P37 X-Received: by 2002:aca:3f09:: with SMTP id m9mr774297oia.55.1583586654835; Sat, 07 Mar 2020 05:10:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1583586654; cv=none; d=google.com; s=arc-20160816; b=umCRinlvwFtqrnR4s7igLikMhzG/AJZFePjIZh3MNdt63pwb8fFS6jPDf6ZlpC0QLV 9bELzG0jOc0+2JZ8ngMgFV6ehE7rfeB0HDk2EHFNT1HZkmUp3NdmULvmLTh2rr2SoGaS JAWN95aLAQbYEDZEyJCGAubg1vuBv+WcPqwT/QMAmhmVSVFUXnPcM4rLSMz8ax7JO+ET llkNsEy9nH66sH4D0dW99dFEBU9k97aIOroXHBjWtknVlk7ZfNqmXD+M4UqfyYYfIOc8 Boi7yM9VUwxyl9bLqWtH11mQd72x2vYrtwZvGGfhvV9IVhip/yo/GTTxVzBfVDfFwuyP zsgg== 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 :message-id:date:subject:cc:to:from; bh=qj4CzARLxYM9RSt1xUKMsopUBtTP6OABOsA6EpaY7dc=; b=bbVIn/m0WR0zqzcVjinTLuWgKivcDYWpZIe3kDB91oSqZuBZKHZJh+BrThmdkW424M aaOO3Ohe7d1H4X90crKxNkm+ut0D7d4C2Va2L8rM59tLLhIdp8xtyAQtVyYuHlJHfTFl suSL7Ip1zaypcJgGtTqc1cSNBq3t826789F5BF0UZEWQooPK/53ppW6B1Q5wIA+oU8UL Im4CE6dLRieQLzS7XIgVIcaFh4xdsoSRqBTgcwoRn+JJA4uTJcZXtPCTsPClTuM+uPrK M4F3T/qJvHDSmZgW8M+J5+ANiFytu8ayo8JLMzlUcRE6ScICv97JM1m/7dGUn1Gb23mw t3cw== 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 x16si3317882otj.178.2020.03.07.05.10.18; Sat, 07 Mar 2020 05:10:54 -0800 (PST) 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 S1726193AbgCGNIS (ORCPT + 99 others); Sat, 7 Mar 2020 08:08:18 -0500 Received: from unicorn.mansr.com ([81.2.72.234]:59430 "EHLO unicorn.mansr.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726043AbgCGNIR (ORCPT ); Sat, 7 Mar 2020 08:08:17 -0500 Received: by unicorn.mansr.com (Postfix, from userid 51770) id 165E615F0E; Sat, 7 Mar 2020 13:08:16 +0000 (GMT) From: Mans Rullgard To: Bin Liu Cc: Greg Kroah-Hartman , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] usb: musb: fix crash with highmen PIO and usbmon Date: Sat, 7 Mar 2020 13:07:20 +0000 Message-Id: <20200307130720.16652-1-mans@mansr.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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; + } } musb_ep_select(mbase, epnum); @@ -1977,8 +1979,10 @@ void musb_host_rx(struct musb *musb, u8 epnum) urb->actual_length += xfer_len; qh->offset += xfer_len; if (done) { - if (qh->use_sg) + if (qh->use_sg) { qh->use_sg = false; + urb->transfer_buffer = NULL; + } if (urb->status == -EINPROGRESS) urb->status = status; -- 2.25.1