From patchwork Mon Jun 3 16:55:16 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Konovalov X-Patchwork-Id: 10973433 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 131B414E5 for ; Mon, 3 Jun 2019 16:57:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EF75728658 for ; Mon, 3 Jun 2019 16:57:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E2D532873A; Mon, 3 Jun 2019 16:57:49 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 9337B28658 for ; Mon, 3 Jun 2019 16:57:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:To:From:Subject:References:Mime-Version :Message-Id:In-Reply-To:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=EJDVc0qKP75tzt3Q3658jokCb78ht9Erd1AwnyhKQYI=; b=UDaCNjZ7T6cASt qXAaqVlkLnWku9uCWC3Nmc5p248pwkSUKFcLKPIiSeyZVrZfhEH3i5QSkqY7cNcDbNHhACkA1Gx0A c6Lr873UnjyUAMrNOC5fWbk//NEOEHy94XeQBAveYSrAy62oJ4/LqyP6DPMHuCryzfD8o2E4pvpiY UMh2lnCdz2T96t8RriQK2UgG9Il6wNrFqu235rl8+goFRXvG2EJVLIKheIYNYGonOJR1bdytQssfj 2qMZoEaevUVVPUiEiX7wnTIBwbha1MPtSTMG+KTkOzlqiq7GlRR/Y5LSnmV1n9a14rSIO+PJPPt0P m0EF/2gLh17HInBVvLVw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1hXqHI-0002fX-PC; Mon, 03 Jun 2019 16:57:44 +0000 Received: from merlin.infradead.org ([2001:8b0:10b:1231::1]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1hXqFu-0000oU-LN for linux-arm-kernel@bombadil.infradead.org; Mon, 03 Jun 2019 16:56:18 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=Content-Type:Cc:To:From:Subject: References:Mime-Version:Message-Id:In-Reply-To:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=UdKHGBZnbXnYOdacGwXVLbo2mp7I3OpbNnEy2rn9dE0=; b=bBIQ4gV7CbkSuT5PXt9T+u0v1 ep3Sim+2AwYN81nqLoUhrJd8MkRSLo4XC1b694hm8c+j293gsQwyuA+zrxckUS+5Qb0cG2Y9L6HFp xI4dhU/ex4Xqpvx0jcCqK0QiqrQXPGDq+9+lBfHrqNYv8Y0qnLfOocFcGR+WsUr3fGPfn1Fzzxpu2 5KTv/UGENevoR+Z86FU4yFRvWVPKFg483TRLfCrVWZonWCltTlLLjmLACoppBggdgQjexRDK3PabN jSDWV2l4AT+uTwMBh/Cde7ftivGnhXe0RNg+flQaiBpKg6mwGcnFpt33vCrCcZsMVny1pDLqg5dD/ R0H/1MmqA==; Received: from mail-ot1-x34a.google.com ([2607:f8b0:4864:20::34a]) by merlin.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1hXqFr-0004ks-NU for linux-arm-kernel@lists.infradead.org; Mon, 03 Jun 2019 16:56:16 +0000 Received: by mail-ot1-x34a.google.com with SMTP id h12so3275909otn.18 for ; Mon, 03 Jun 2019 09:56:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=UdKHGBZnbXnYOdacGwXVLbo2mp7I3OpbNnEy2rn9dE0=; b=aMwQlO/uqKNquhxQCaOybakc925QpZfJO8wh15xEZQIyCg72vlDGXrUg/ROAuoQDUD yCBHc/elg2gmmBaFllCt7o9fko/cMYEXNqMBN5Ib8jP974H6cgrFWFCLBOtmTziaRGQQ SwI/Xt1vXIDm1HuVmNbFHcArxU2bsmwx6xs/PbNEoDywCtOeBm47QoZ+wae08e7pzq/K a7mRKG2GqnFCVji4AY+94HQ5eVsYgsMp8E/PA4r/OPS0psFqvjDQbyz4YEbR/PgBj2Aq 436HnabGuSm3Rvtg2LN9VhA8Rs2mRcn4xgL77EZC0LMuRu0EvZQAUUg9zFkbP9a8AWHr YN2w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=UdKHGBZnbXnYOdacGwXVLbo2mp7I3OpbNnEy2rn9dE0=; b=hGAZY7CsBr3Mt4uFBw5UR/9OxFUeenR3pkmXX0kQ0YHn1z/RD7E0XGPjXnnVVd95B3 gCBa8C/q/EkDoweIuKFyCWiZuMv85jRQnIiacFs2rCHl2JjSwpndcsemPFxW6Hmg8G1A Jnuz4vIZ1ExKiWXesXjMOG2P36lA8LRcDCitMNO9Pk7HVMmtaHhQNi1sc23L/DJuMLFI uF/B69ARC9a8aQY2+dG5txITB7U7vyRWrDBNvyxmygb2VL6kFpW5DxxY3XR59rkOjDFN duD/JU8Cp+hBFuX50PUvjp5+9wOKnvKoHlsXAC7s8N/bJETv+gZ9GTsuGalaoy+GfD3W RyEQ== X-Gm-Message-State: APjAAAWAZajCBNkdJq1CIwevS1p6EdnWQ7JPNofl3/J4xBq3F8aUmSJv 710AJ/7ihsB6/7ydfyuMLQCAfWqgvwe9pZq9gK5DN9f9FAoy+M0Pfl3qG0tqi+bG41Pjs+EohHu DVIQMMmUSu87JDNNbsl8Wf/yspnilSCsrA2tWbL9sW/JgNrv+GSOguZqT6WigcfVQ/wEy1C7pge LgB8nTRUpP3V/+/q0= X-Google-Smtp-Source: APXvYqxMjN/4yHR2ThXEEFJeDuxNxY18SC+MmNXgYJ7rlNGji/L0sGyo9f6aEs2c6lSgFUC7mMKDb3c6mMlyiMDt X-Received: by 2002:a9d:4109:: with SMTP id o9mr1768838ote.353.1559580969728; Mon, 03 Jun 2019 09:56:09 -0700 (PDT) Date: Mon, 3 Jun 2019 18:55:16 +0200 In-Reply-To: Message-Id: Mime-Version: 1.0 References: X-Mailer: git-send-email 2.22.0.rc1.311.g5d7573a151-goog Subject: [PATCH v16 14/16] tee, arm64: untag user pointers in tee_shm_register From: Andrey Konovalov To: linux-arm-kernel@lists.infradead.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-rdma@vger.kernel.org, linux-media@vger.kernel.org, kvm@vger.kernel.org, linux-kselftest@vger.kernel.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190603_125615_771657_213A6FAA X-CRM114-Status: GOOD ( 13.26 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , Szabolcs Nagy , Catalin Marinas , Will Deacon , Kostya Serebryany , Khalid Aziz , Felix Kuehling , Vincenzo Frascino , Jacob Bramley , Leon Romanovsky , Christoph Hellwig , Jason Gunthorpe , Dave Martin , Evgeniy Stepanov , Kevin Brodsky , Kees Cook , Ruben Ayrapetyan , Andrey Konovalov , Ramana Radhakrishnan , Alex Williamson , Mauro Carvalho Chehab , Dmitry Vyukov , Greg Kroah-Hartman , Yishai Hadas , Jens Wiklander , Lee Smith , Alexander Deucher , Andrew Morton , enh , Robin Murphy , Christian Koenig , Luc Van Oostenryck Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP This patch is a part of a series that extends arm64 kernel ABI to allow to pass tagged user pointers (with the top byte set to something else other than 0x00) as syscall arguments. tee_shm_register()->optee_shm_unregister()->check_mem_type() uses provided user pointers for vma lookups (via __check_mem_type()), which can only by done with untagged pointers. Untag user pointers in this function. Signed-off-by: Andrey Konovalov Acked-by: Jens Wiklander Reviewed-by: Kees Cook --- drivers/tee/tee_shm.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/tee/tee_shm.c b/drivers/tee/tee_shm.c index 49fd7312e2aa..96945f4cefb8 100644 --- a/drivers/tee/tee_shm.c +++ b/drivers/tee/tee_shm.c @@ -263,6 +263,7 @@ struct tee_shm *tee_shm_register(struct tee_context *ctx, unsigned long addr, shm->teedev = teedev; shm->ctx = ctx; shm->id = -1; + addr = untagged_addr(addr); start = rounddown(addr, PAGE_SIZE); shm->offset = addr - start; shm->size = length;