From patchwork Thu Aug 30 11:41:12 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Konovalov X-Patchwork-Id: 10581521 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 7B11914BD for ; Thu, 30 Aug 2018 11:41:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6A7552BA60 for ; Thu, 30 Aug 2018 11:41:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5E4502BA68; Thu, 30 Aug 2018 11:41:35 +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=-15.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, USER_IN_DEF_DKIM_WL autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 090D82BA60 for ; Thu, 30 Aug 2018 11:41:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728624AbeH3PnQ (ORCPT ); Thu, 30 Aug 2018 11:43:16 -0400 Received: from mail-wm0-f68.google.com ([74.125.82.68]:53289 "EHLO mail-wm0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728334AbeH3PnP (ORCPT ); Thu, 30 Aug 2018 11:43:15 -0400 Received: by mail-wm0-f68.google.com with SMTP id b19-v6so1651119wme.3 for ; Thu, 30 Aug 2018 04:41:31 -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=ppVHi2qDpVAko4oywEUyVH03nYNtDWMaAZh6pkh+TAI=; b=vM2W1vbB7o60flHuNJ/bgTQROh+Zt2m1p0PT33/imyxEkZK1/Esv7iYw9LpWqbIh3m hobo1vU1c+v0Sblwfgp+dimNnJPZy/F0NvOautf7atu0tq8HTohJpgdmmMrdl4AYk151 y1FKxABUZJiw/FShkiF4Vjx+avpapwRzC5R32XJn5fMZrR+LCeV7OWD7REcGraJpxEGx pZQS5IbOZ+yijKZDr2ka3/sxT/vVG5mZpKvFVey/NkAxEkpyZY7MDNEqyN0Dv5ql+VJW 4UYj6K8/zcqE3BRWKLrn8aXymf+gcl3zDhnzQaYNb/VkQUlbBIQ8Zyx56geVgZccD9MO FSxw== 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=ppVHi2qDpVAko4oywEUyVH03nYNtDWMaAZh6pkh+TAI=; b=PY11/k98oXldpclsmf6KjhSpNHZHdLhY0Yj0aNat0SAPG1/DaoVWihEGooeexPJah/ oc7cPJbt89TGjYCAa3wDvpWkqILZwU7kfQm6SUos3tas9qvPgi6TA0v8quYaDEh2LXnY DqyeZVn2y9kfClT+sLvEFxaqlLcxGuIRVQiQlY3+5GN8yylSilqfHgnix/5O4Ugq7GjC MPFrBi3SdJDj5n1wBQE64x6MP5B9qaEc9lk0qOttsayAypknYvaNpo6by1HyvFf+jpf5 +lnIJG+xSxCqdTv8FCfbtxBwaYcIoH5ypaKYYTZfbm4z4NIQ+49pbWS5VVG+VKJsqF/o TLcw== X-Gm-Message-State: APzg51CCPcE5Td5AHqqZBjxzhsKvLTrV0/XKVk/OdnEnpPCJcUx+zjqc d3O3DId5CaHuu3U8asGHNMKlTw== X-Google-Smtp-Source: ANB0VdYOFoy1sxoEnv1Wgj/+prhG1/Y/jGlov/9lPGGe6D7gsNtu3J1gP5Nihdp90zj4LxikZG+9lw== X-Received: by 2002:a1c:4c0c:: with SMTP id z12-v6mr1615687wmf.57.1535629291034; Thu, 30 Aug 2018 04:41:31 -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.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 30 Aug 2018 04:41:30 -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 07/11] fs, arm64: untag user address in copy_mount_options Date: Thu, 30 Aug 2018 13:41:12 +0200 Message-Id: <89806bc1c1f85fa97c62887075cc2d46b8bdeee2.1535629099.git.andreyknvl@google.com> X-Mailer: git-send-email 2.19.0.rc0.228.g281dcd1b4d0-goog In-Reply-To: References: MIME-Version: 1.0 Sender: linux-kselftest-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 99186556f8d3..51f763fb9430 100644 --- a/fs/namespace.c +++ b/fs/namespace.c @@ -2672,7 +2672,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;