Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp5938951ybi; Wed, 12 Jun 2019 11:03:21 -0700 (PDT) X-Google-Smtp-Source: APXvYqzF0vVSRwfCcJ5noFO8KWv6RoUPCFRucroK8+Ew+VS5u7iRXkCjiWlBECpFXcfbzbSZlruo X-Received: by 2002:a63:5a18:: with SMTP id o24mr26227721pgb.69.1560362600726; Wed, 12 Jun 2019 11:03:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560362600; cv=none; d=google.com; s=arc-20160816; b=lluPf24P/qq3czF/S/beLm1npLxjWuPYKNGN+CnJ969KzYsf+BIQiLJPO2RLjPxv3C SKL2/5ArzGFH4BJ7XVMYRkh5SBWZ1J1wJp88mlh1esECQCr2sGW3PfexvAnB82ccorlz RmZFermkRMXGrLeiECdwM1TdsH1aEDzimgQ3SKwgtyqiUaZjtOWobx+wLd9t/9X/8RIn HeBIy7B+CZWqJpqs6kfkvm2O7xtvDAnmbDxO1nKB95XeWzJzNUQCG1jXUpBgZUkpPuPj q+PDKJ6dhxEpT+Cnrxtq1SOgwPep4eTsK0p+lwDmGOSfau3q4cP814GK+0qxTqsm7tp9 CCIA== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=k6mFP7+3kljKTiUG3KJLD1eJ9mBoWJVeZG/bqEQg9YE=; b=lMAwBug7IK7Y3uOwDptg4GNZqi7oo4/G+XMklp6SFQJ5qLXxgfb0PiwXVlFF16V73y A2bJLseD+RwHYCtMyJY6egB/C1wY2sZPQCjb9eP8tZd2sJJeZq1K2PwQML/b+jXU1spc 4RKibQnqxlGycfz5wFtHUsDvRP53d+OIqHZmDT4GbKUQftEav9QTtfITOMmo2F/rmjNo 0DaaRZoXDiNtowtjFjufDlPYxo28+C/lSlx5rKnBg/3nDcQDvUYRkeg0Bfj2InetPds1 +YAvVtEBx02XYZzwHgithDIo6hmxnatFWfIOjdz4m4L1+kAJkZ05V0cWJ6tXDji2konM zYYA== ARC-Authentication-Results: i=1; mx.google.com; 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 a14si411927pgm.206.2019.06.12.11.03.05; Wed, 12 Jun 2019 11:03:20 -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; 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 S1732471AbfFLOfe (ORCPT + 99 others); Wed, 12 Jun 2019 10:35:34 -0400 Received: from foss.arm.com ([217.140.110.172]:54684 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732022AbfFLOfe (ORCPT ); Wed, 12 Jun 2019 10:35:34 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 2A2822B; Wed, 12 Jun 2019 07:35:33 -0700 (PDT) Received: from [10.1.196.72] (e119884-lin.cambridge.arm.com [10.1.196.72]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 1FAE33F557; Wed, 12 Jun 2019 07:35:27 -0700 (PDT) Subject: Re: [PATCH v17 07/15] fs, arm64: untag user pointers in copy_mount_options To: Andrey Konovalov , 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 Cc: Catalin Marinas , Will Deacon , Mark Rutland , Andrew Morton , Greg Kroah-Hartman , Kees Cook , Yishai Hadas , Felix Kuehling , Alexander Deucher , Christian Koenig , Mauro Carvalho Chehab , Jens Wiklander , Alex Williamson , Leon Romanovsky , Luc Van Oostenryck , Dave Martin , Khalid Aziz , enh , Jason Gunthorpe , Christoph Hellwig , Dmitry Vyukov , Kostya Serebryany , Evgeniy Stepanov , Lee Smith , Ramana Radhakrishnan , Jacob Bramley , Ruben Ayrapetyan , Robin Murphy , Kevin Brodsky , Szabolcs Nagy References: <4ed871e14cc265a519c6ba8660a1827844371791.1560339705.git.andreyknvl@google.com> From: Vincenzo Frascino Message-ID: <4a70a119-e40d-3fa3-8426-ba946e1af76a@arm.com> Date: Wed, 12 Jun 2019 15:35:27 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1 MIME-Version: 1.0 In-Reply-To: <4ed871e14cc265a519c6ba8660a1827844371791.1560339705.git.andreyknvl@google.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 12/06/2019 12:43, Andrey Konovalov wrote: > 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. > > Reviewed-by: Kees Cook > Reviewed-by: Catalin Marinas > Signed-off-by: Andrey Konovalov Reviewed-by: Vincenzo Frascino > --- > fs/namespace.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/fs/namespace.c b/fs/namespace.c > index b26778bdc236..2e85712a19ed 100644 > --- a/fs/namespace.c > +++ b/fs/namespace.c > @@ -2993,7 +2993,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; > > -- Regards, Vincenzo