From patchwork Tue Apr 30 13:25:05 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Konovalov X-Patchwork-Id: 10923623 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 40D8414DB for ; Tue, 30 Apr 2019 13:27:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2C7E627EE2 for ; Tue, 30 Apr 2019 13:27:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1FCA928A63; Tue, 30 Apr 2019 13:27:58 +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 A138127EE2 for ; Tue, 30 Apr 2019 13:27:57 +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=7GyK96x2aUWKvMkE5A1sl9q9+jGvkz7IfxjGW0UZXDI=; b=mCTqDEOdtieP7p voDEUnY0lNM8QCX8Ssf6MyW54xcfSuGO1T7CQ6klpmkuljtMoJZpPWjbEVrvac39zmqEahIVmcfNX WEzAW585eFsW7ZLB8l3kMoLJGpkKnSCSL5HaTgBqiPgA/AywkktFSX3HRc+47Z1tdh6FHXoSrSF70 aG4O8zC80e69Un5cepUtjUFpaBHFhXEiU4RK+3bhxCmRYaPq3Nq2DXobDYxPV9kpm3+kNk8EqPL4t Qn2BdFnD3M3YMhqJGQvYqEhxYyGli93HwOIDeaYy/TI/jpiE8w+nx4MpNEJsOqQR0kfeVd8uVjkBe 3G1iM5bMzJTWKq96q13g==; 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 1hLSnX-0004Ey-EU; Tue, 30 Apr 2019 13:27:51 +0000 Received: from mail-qt1-x849.google.com ([2607:f8b0:4864:20::849]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1hLSlX-0001uX-LC for linux-arm-kernel@lists.infradead.org; Tue, 30 Apr 2019 13:25:53 +0000 Received: by mail-qt1-x849.google.com with SMTP id n39so4019464qtn.0 for ; Tue, 30 Apr 2019 06:25:46 -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=XhTfun6kQ0RRzRGxeYV1Lxl9M9fvGqRUvmzO5QW1/Iw=; b=wJdQ1UGK5yN+4uNr4h/B5QAZg4CL5PwyVx/Pw0wXlRL/1oGZsU8xxjXpZhWnko4SRI fd58gicIFCILzVPy4t7gpYBYkZYkBR3FmblDk49rQtqjc+3RWgZP2PESfhPKYuSabBw/ B0hXw+/teu1vbGfMkq/9KC8ilccnVzEvxDboYdIBbHp/DJQFCI0D5tDe+o/VISE54DyV St7L+ZfiWURBvKb49SaxC44tIWiHtqDmkV/TM32oplri8v6dnEdHN+6rXyhwe32Swezt x0OHZZDCsWZFgoiC74TFCi6OtAop9i/h8/+cUKSH3r+foqub7XosNX+XNvDEf+4uDkZz /4Vg== 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=XhTfun6kQ0RRzRGxeYV1Lxl9M9fvGqRUvmzO5QW1/Iw=; b=lpKfgk14w4neU52Px9jpT/ePcWuekkkyt4g+1AZjAg45RY48diqM94aFyQCAFigTkw I10ped+7BTW/Q1dCqsqqNvKV+5BJ4E1fz8rVC1JJscmFZ99bHunT0ZkvX8VHJ18g3OtG HT/lpkz0+mJ83XRtiG0aRLAzaVwRZZPWdLP5oIkhsi/WuZuQu1MIrTHaaP470Gejpcqf cW37XQOAFmwkXFfH/qhKPKR5Ic007M4t+vdNt3rCEGL/O1xsYV0Tski9CsLck8pcTsGO rcgwOSpBVL1abq0TlNxfLtcuNUKtMcpmYZ6h8MTFMblxKzA5bS9twJkLVDHp1aIef57M H3sQ== X-Gm-Message-State: APjAAAVhTxWvC7lmUC387ON9+3ns19UfPR/AShpfxV0LjpzJudZHtd3X ctC2ksVHdAHgNE36buNrucoabDxSRbyjn2C8DEJODu6Q0VaHYAboOwwL6evuyhINvcYyEIqF2Tb OFrB811afyoP36q1wpZiDtABtYvdgtsWZNQ20p1RxTUbxnmC1NuUKJZruIJHQQmR7CSavDb9eXM skaArXV21yde2mGF8= X-Google-Smtp-Source: APXvYqznoxmsWRf0TRsMetoUzYzE4dAnT0nzUuom4UB8P1UAcmj3+/tm6hiTUWLYkHc/SM6nPM/1vvtkZ4BWAaOU X-Received: by 2002:a37:b683:: with SMTP id g125mr147309qkf.249.1556630745179; Tue, 30 Apr 2019 06:25:45 -0700 (PDT) Date: Tue, 30 Apr 2019 15:25:05 +0200 In-Reply-To: Message-Id: Mime-Version: 1.0 References: X-Mailer: git-send-email 2.21.0.593.g511ec345e18-goog Subject: [PATCH v14 09/17] fs, arm64: untag user pointers in copy_mount_options 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-20190430_062548_379388_91342414 X-CRM114-Status: GOOD ( 15.27 ) 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 , Koenig@google.com, Szabolcs Nagy , Catalin Marinas , Will Deacon , Kostya Serebryany , Chintan Pandya , Felix , Vincenzo Frascino , Jacob Bramley , Leon Romanovsky , Kuehling@google.com, Dave Martin , Evgeniy Stepanov , Kevin Brodsky , Kees Cook , Ruben Ayrapetyan , Andrey Konovalov , Ramana Radhakrishnan , Deucher@google.com, Alex Williamson , Mauro Carvalho Chehab , Dmitry Vyukov , Greg Kroah-Hartman , Yishai Hadas , Jens Wiklander , Lee Smith , Alexander , Andrew Morton , Robin Murphy , Christian , 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. In copy_mount_options a user address is being subtracted from TASK_SIZE. If the address is lower than TASK_SIZE, the size is calculated to not allow the exact_copy_from_user() call to cross TASK_SIZE boundary. However if the address is tagged, then the size will be calculated incorrectly. Untag the address before subtracting. Signed-off-by: Andrey Konovalov --- fs/namespace.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/namespace.c b/fs/namespace.c index c9cab307fa77..c27e5713bf04 100644 --- a/fs/namespace.c +++ b/fs/namespace.c @@ -2825,7 +2825,7 @@ void *copy_mount_options(const void __user * data) * the remainder of the page. */ /* copy_from_user cannot cross TASK_SIZE ! */ - size = TASK_SIZE - (unsigned long)data; + size = TASK_SIZE - (unsigned long)untagged_addr(data); if (size > PAGE_SIZE) size = PAGE_SIZE;