Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp511631imm; Thu, 30 Aug 2018 04:44:17 -0700 (PDT) X-Google-Smtp-Source: ANB0VdZKaw2ogggiCA5LF6BcHmlnUPYiMqLrHTayah/Gr9yV6p4nFWMzdlFwkTFPkB+yhsTj1r/o X-Received: by 2002:a17:902:74ca:: with SMTP id f10-v6mr9998281plt.260.1535629457513; Thu, 30 Aug 2018 04:44:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535629457; cv=none; d=google.com; s=arc-20160816; b=zX9xT2YAoMx/sT4exaiOApsGly9DhcxFl4786bsZXDxJnDJz1iOVY3yTitJAFJkhcO wuoz2AmChwJkGee2NPjVl4OsQ4RayYXATYljQjh59VINkAI32zhWZwX02IHafyQcVuyn /WYZs6pmZAr8xqLNZmuGJTRLqtUeRb2M/T/hIn3Bm1YakIT1CGsZJ97kdNj7ObEx0HoU RYlyiQvsOdQVk+/v9fo/CJo9dl+HHv67sTQMwg/RH9jPqYT0dPFFH/Ra1+mFvqvxz/5+ dM/46it3IR4atNpUtNEzKErF5Qr3Iad5E/0EtfbC3wlEUrZfiDpZBmJ+gzRcCKO94WBG FLeg== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=ZXrp1luYhJIP4n0GyXQgKnJADxNlE5pIywVcPCMS+cU=; b=JhG97IcLVxKFcQg2INIl41IrgqjYw+j4Yt4rAya7zOHkxhVeX/907el1Yd5qoFArzT yCpWECxiV/ioCJY+06hEMs+xJE4sxX/QqCmUVmi59E10/mvpWB4ShMr86dgxdItSg6s8 B8my1WwHxtOz4PGKPSHA+vHwA0rV2nsxgEcdPKIknOyT5TSEMfSbz7T1XW8I6KF5Xez6 U5zunUraMpH4N7iZ3NYHD1ZY+CyRb0MvE++OVHxwVT6TSMgFd0zIzA6mkOWGGArxnBPb vNjuvqX5hCXsZCctg3FuPs4t1pD9XOjDKeC2b2jjRkLiaZLDdj1HJA9ZUml1JfP6/X+S 6LTA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=CQDTthRq; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n7-v6si5937801plp.363.2018.08.30.04.44.03; Thu, 30 Aug 2018 04:44:17 -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=@google.com header.s=20161025 header.b=CQDTthRq; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728663AbeH3PnR (ORCPT + 99 others); Thu, 30 Aug 2018 11:43:17 -0400 Received: from mail-wr1-f67.google.com ([209.85.221.67]:38557 "EHLO mail-wr1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728623AbeH3PnQ (ORCPT ); Thu, 30 Aug 2018 11:43:16 -0400 Received: by mail-wr1-f67.google.com with SMTP id w11-v6so7755690wrc.5 for ; Thu, 30 Aug 2018 04:41:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ZXrp1luYhJIP4n0GyXQgKnJADxNlE5pIywVcPCMS+cU=; b=CQDTthRqqtcN1ufs2a01fqxdr/kNs6fWI4tuV05Bl51I45yCRaOhwJeuVLq2COoKxl frBJ/N/y1s89YtLmD61lAycbLOLLTF0db8371mdV5CkrUHIB4OqvgwpMqa2HqEJ5erXV cz73I1vf0Q3YRNllcJW9lajKpvoVIc6JFbWD0GQ32BBzzM/YZKvg69fdsbCB+jAY2CJ4 qa5p1DPRxkB3fubKdY5z69yjcIW9inj4czCTZ8Pk2Y9ND/FF3DeAxxNEolW//bI2AMaQ R4nqHfd2pTi6R4MWd0G82haf4q4xC1vvoOFkFWodc62D052G9nhiMGMdvmjrksHp4cNx yWyg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ZXrp1luYhJIP4n0GyXQgKnJADxNlE5pIywVcPCMS+cU=; b=Fz5XnkVAOvXPb7uXVTe4AQZqsP6iQmgbUsH8DjNnGIi4K1llKz4OzJ2Oa9FfJ4dWyV nHXhXayDfbFTAyBTpm5IJ8pFX61JrieshrOB6+6cCcuen+krO9B4KHRxgf9ZwSsQn8tK Rdv7oE37MLHd/btPpp3iMCo+8uTaKbaxvqV1QfdAIjp7/JetqgEwZtI2bNjHqYKMykOj 29Z4JbJTQhcsOzhEQdnC+kG4t0qt2OHcAo/LanU4eoFNlMZPUh38ij3YxUTHfVqjRGCe DiF7sNYO6W4Wz6ZpK4tOHlTr8/KkCY9erXoW6FjQ3C57BnXx+hYRC/A/a5sPKtTWNaxd 4J/Q== X-Gm-Message-State: APzg51Ciw9ato1pjZfLCY3AnvpW6mieONCQd8/hDzBgsuGDYekc/VbeY PUlkiXzXb0wsv3AyR7sK6p41nw== X-Received: by 2002:adf:ff0b:: with SMTP id k11-v6mr7791832wrr.15.1535629292576; Thu, 30 Aug 2018 04:41:32 -0700 (PDT) Received: from andreyknvl0.muc.corp.google.com ([2a00:79e0:15:10:84be:a42a:826d:c530]) by smtp.gmail.com with ESMTPSA id z184-v6sm2175218wmz.0.2018.08.30.04.41.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 30 Aug 2018 04:41:31 -0700 (PDT) From: Andrey Konovalov To: Catalin Marinas , Will Deacon , Mark Rutland , Robin Murphy , Al Viro , Andrey Konovalov , Kees Cook , Kate Stewart , Greg Kroah-Hartman , Andrew Morton , Ingo Molnar , "Kirill A . Shutemov" , Shuah Khan , linux-arm-kernel@lists.infradead.org, linux-doc@vger.kernel.org, linux-mm@kvack.org, linux-arch@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Dmitry Vyukov , Kostya Serebryany , Evgeniy Stepanov , Lee Smith , Ramana Radhakrishnan , Jacob Bramley , Ruben Ayrapetyan , Chintan Pandya Subject: [PATCH v6 08/11] usb, arm64: untag user addresses in devio Date: Thu, 30 Aug 2018 13:41:13 +0200 Message-Id: X-Mailer: git-send-email 2.19.0.rc0.228.g281dcd1b4d0-goog In-Reply-To: References: 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 devio allows to mmap memory regions and keeps them in a list. It also accepts a user address through an ioctl call and searches the memory region list for the region that contains this address. Since the addresses provided to mmap must not be tagged, and the addresses provided to ioctl might be tagged, we might compare tagged and untagged addresses during the search. Untag the provided addresses before searching. Signed-off-by: Andrey Konovalov --- drivers/usb/core/devio.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/usb/core/devio.c b/drivers/usb/core/devio.c index 6ce77b33da61..ed5ab7c8100b 100644 --- a/drivers/usb/core/devio.c +++ b/drivers/usb/core/devio.c @@ -1405,7 +1405,7 @@ find_memory_area(struct usb_dev_state *ps, const struct usbdevfs_urb *uurb) { struct usb_memory *usbm = NULL, *iter; unsigned long flags; - unsigned long uurb_start = (unsigned long)uurb->buffer; + unsigned long uurb_start = (unsigned long)untagged_addr(uurb->buffer); spin_lock_irqsave(&ps->lock, flags); list_for_each_entry(iter, &ps->memory_list, memlist) { @@ -1634,7 +1634,8 @@ static int proc_do_submiturb(struct usb_dev_state *ps, struct usbdevfs_urb *uurb } } else if (uurb->buffer_length > 0) { if (as->usbm) { - unsigned long uurb_start = (unsigned long)uurb->buffer; + unsigned long uurb_start = + (unsigned long)untagged_addr(uurb->buffer); as->urb->transfer_buffer = as->usbm->mem + (uurb_start - as->usbm->vm_start); @@ -1713,7 +1714,8 @@ static int proc_do_submiturb(struct usb_dev_state *ps, struct usbdevfs_urb *uurb as->ps = ps; as->userurb = arg; if (as->usbm) { - unsigned long uurb_start = (unsigned long)uurb->buffer; + unsigned long uurb_start = + (unsigned long)untagged_addr(uurb->buffer); as->urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; as->urb->transfer_dma = as->usbm->dma_handle + -- 2.19.0.rc0.228.g281dcd1b4d0-goog