Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp3806329ybi; Mon, 29 Jul 2019 13:00:56 -0700 (PDT) X-Google-Smtp-Source: APXvYqyOHtRq9Ap5h6iNepV13O6HA9tG4puq7ga8Jw3IPId1KXU30tlHcvsascWiXl0pRyNmQDe1 X-Received: by 2002:a17:90a:360c:: with SMTP id s12mr115349242pjb.30.1564430456258; Mon, 29 Jul 2019 13:00:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564430456; cv=none; d=google.com; s=arc-20160816; b=FWyCQYrb9lAaT/H8wvHrvDuvr2Mr9Zq5gHS8Q+JkcdChyMjPr5wHfMWRJv4nVggGpa HfFlmb173RN3T3xV6m+oZYW79PqO/GP9ryCvnq3Qt9ZNHmzkwGo3FGmaLHCTL6PTPIny B350/IyylOd7Tp2P8xOXka+sn9FisTM/4KVwnUimyE7Si0ACyyEkpEVbkK1YctExyY0P 6sbZH6Kk3acCSO7Wjxb3ETrVKdo3hKJKzJhUjvLcGZDFReduXJMLx4sxFPhoCvoMWxTi EFWBoN/7JXxrs7dw2Q3VIxUQnJf355/5qcf+g2c2DHuRB7CdVSYEUeQJ/gyRfVkXv0hZ AYUQ== 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:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=TkoZXuCO/mbwdKIZLERLa5OcF/ejgmsJhCtXWaeISEs=; b=D7bhwYkdkqwrOkCXllecZxBJHA2wNX4AvYqJbNyrk587B8pLu145mqMy1Rff4fYYSU g8ToCbakbuID/ehAJKQFb/Ne5mH1hFlWT9jEfDDQnER0iiADjiRzgw51UfWHEtJNaWNl lQzZx3botHvyidZKTi0THb7h4TMym9RPA9ujaBIlMOn1G4PkwjDs851rnKnHWHiJHsuP FdUulbH1oh1H/w5GdUUsRuCKQFg/AZnieQ0P5h8pILrwjXNaCsGyy7V+CAR5fGj9NYbE rriO7/4eFyG6RHG48wbUVXBY1U9MQ/v6bDoJvv++uB1vByfZCvdUA3byeIWnlaa45ydH wZcg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=i2Kehgaz; 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 s62si24317309pjc.75.2019.07.29.13.00.41; Mon, 29 Jul 2019 13:00:56 -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=@kernel.org header.s=default header.b=i2Kehgaz; 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 S2390438AbfG2Tx4 (ORCPT + 99 others); Mon, 29 Jul 2019 15:53:56 -0400 Received: from mail.kernel.org ([198.145.29.99]:45786 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390767AbfG2Tx0 (ORCPT ); Mon, 29 Jul 2019 15:53:26 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 5EF2E2054F; Mon, 29 Jul 2019 19:53:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1564430005; bh=Tf9pv3jmi3sgVFMBLfygf4O+o/wGdfYJHtYUPKMetng=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=i2KehgazyPQVWW/Z+KVYOsfhrKcMBoI8VvS+2/szHYw0x5z979CyC1Ext8fZO9zD9 V2NKP35YxI+Y18m9dpw2ug40Ed4TI2H1tPJyuKJIzeiCMuJlRDDRhKeEY6oZ5FSN93 hSdJzsm6FrEPFVH0mWOccIJNXBHY51reJEr0IUSo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Maik Stohn , Nicolas Saenz Julienne , Mathias Nyman Subject: [PATCH 5.2 167/215] xhci: Fix crash if scatter gather is used with Immediate Data Transfer (IDT). Date: Mon, 29 Jul 2019 21:22:43 +0200 Message-Id: <20190729190808.779029683@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190729190739.971253303@linuxfoundation.org> References: <20190729190739.971253303@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Mathias Nyman commit d39b5bad8658d6d94cb2d98a44a7e159db4f5030 upstream. A second regression was found in the immediate data transfer (IDT) support which was added to 5.2 kernel IDT is used to transfer small amounts of data (up to 8 bytes) in the field normally used for data dma address, thus avoiding dma mapping. If the data was not already dma mapped, then IDT support assumed data was in urb->transfer_buffer, and did not take into accound that even small amounts of data (8 bytes) can be in a scatterlist instead. This caused a NULL pointer dereference when sg_dma_len() was used with non-dma mapped data. Solve this by not using IDT if scatter gather buffer list is used. Fixes: 33e39350ebd2 ("usb: xhci: add Immediate Data Transfer support") Cc: # v5.2 Reported-by: Maik Stohn Tested-by: Maik Stohn CC: Nicolas Saenz Julienne Signed-off-by: Mathias Nyman Link: https://lore.kernel.org/r/1564044861-1445-1-git-send-email-mathias.nyman@linux.intel.com Signed-off-by: Greg Kroah-Hartman --- drivers/usb/host/xhci.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) --- a/drivers/usb/host/xhci.h +++ b/drivers/usb/host/xhci.h @@ -2170,7 +2170,8 @@ static inline bool xhci_urb_suitable_for if (!usb_endpoint_xfer_isoc(&urb->ep->desc) && usb_urb_dir_out(urb) && usb_endpoint_maxp(&urb->ep->desc) >= TRB_IDT_MAX_SIZE && urb->transfer_buffer_length <= TRB_IDT_MAX_SIZE && - !(urb->transfer_flags & URB_NO_TRANSFER_DMA_MAP)) + !(urb->transfer_flags & URB_NO_TRANSFER_DMA_MAP) && + !urb->num_sgs) return true; return false;