From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.2 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_MUTT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E552EC43613 for ; Mon, 24 Jun 2019 17:51:34 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id BB2CF20645 for ; Mon, 24 Jun 2019 17:51:34 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="oxmhfT5C" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org BB2CF20645 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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:In-Reply-To:MIME-Version:References: Message-ID:Subject:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=jEtOHqDqsETtlg6YghwdFv5pN6YufHD+qjFMG4Fq4Ps=; b=oxmhfT5ChXyYwR JuI7d9B9tiKaf61BI7B70PphC7Uqbb7ooqXlWJ+6JUFQodRb69DlU8XZOE1k47ezqtoULJl4mhJ8u BUJOIORYAS8aGYCrkiiL74LeOfcyR6aWuShb/atvUGjDyOC/wpi3cbIXOrFNCikA5MK75jyiVGvwf vf06CSnUg/JDWMBx17hgXuUXp1mzTML1iKkF5o0k5wgcizR+iijHpGSacnSdAfmL9gIn6rAqrwCGW p8Wecxh0RqOJNmfvlNzVJTZ/E9my29UAU6Dgy9+F3PFsbebigoL8RccO87VajdQO7TWUrdZPaWSpR lpFXSfdr2cYUbfdbSLTQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92 #3 (Red Hat Linux)) id 1hfT7s-0004bS-2S; Mon, 24 Jun 2019 17:51:32 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.92 #3 (Red Hat Linux)) id 1hfT7o-0004b2-Mj for linux-arm-kernel@lists.infradead.org; Mon, 24 Jun 2019 17:51:30 +0000 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 25DB8360; Mon, 24 Jun 2019 10:51:28 -0700 (PDT) Received: from arrakis.emea.arm.com (arrakis.cambridge.arm.com [10.1.196.78]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 606C33F718; Mon, 24 Jun 2019 10:51:23 -0700 (PDT) Date: Mon, 24 Jun 2019 18:51:21 +0100 From: Catalin Marinas To: Andrey Konovalov Subject: Re: [PATCH v18 08/15] userfaultfd: untag user pointers Message-ID: <20190624175120.GN29120@arrakis.emea.arm.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190624_105128_828744_F9B43D88 X-CRM114-Status: GOOD ( 19.67 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , kvm@vger.kernel.org, Szabolcs Nagy , Will Deacon , dri-devel@lists.freedesktop.org, linux-mm@kvack.org, Khalid Aziz , linux-kselftest@vger.kernel.org, Felix Kuehling , Vincenzo Frascino , Jacob Bramley , Leon Romanovsky , linux-rdma@vger.kernel.org, amd-gfx@lists.freedesktop.org, Christoph Hellwig , Jason Gunthorpe , Dmitry Vyukov , Dave Martin , Evgeniy Stepanov , linux-media@vger.kernel.org, Kevin Brodsky , Kees Cook , Ruben Ayrapetyan , Ramana Radhakrishnan , Alex Williamson , Al Viro , Mauro Carvalho Chehab , linux-arm-kernel@lists.infradead.org, Kostya Serebryany , Greg Kroah-Hartman , Yishai Hadas , linux-kernel@vger.kernel.org, Jens Wiklander , Lee Smith , Alexander Deucher , Andrew Morton , enh , Robin Murphy , Christian Koenig , Luc Van Oostenryck Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Mon, Jun 24, 2019 at 04:32:53PM +0200, Andrey Konovalov wrote: > This patch is a part of a series that extends kernel ABI to allow to pass > tagged user pointers (with the top byte set to something else other than > 0x00) as syscall arguments. > > userfaultfd code use provided user pointers for vma lookups, which can > only by done with untagged pointers. > > Untag user pointers in validate_range(). > > Reviewed-by: Vincenzo Frascino > Reviewed-by: Catalin Marinas > Reviewed-by: Kees Cook > Signed-off-by: Andrey Konovalov > --- > fs/userfaultfd.c | 22 ++++++++++++---------- > 1 file changed, 12 insertions(+), 10 deletions(-) Same here, it needs an ack from Al Viro. > diff --git a/fs/userfaultfd.c b/fs/userfaultfd.c > index ae0b8b5f69e6..c2be36a168ca 100644 > --- a/fs/userfaultfd.c > +++ b/fs/userfaultfd.c > @@ -1261,21 +1261,23 @@ static __always_inline void wake_userfault(struct userfaultfd_ctx *ctx, > } > > static __always_inline int validate_range(struct mm_struct *mm, > - __u64 start, __u64 len) > + __u64 *start, __u64 len) > { > __u64 task_size = mm->task_size; > > - if (start & ~PAGE_MASK) > + *start = untagged_addr(*start); > + > + if (*start & ~PAGE_MASK) > return -EINVAL; > if (len & ~PAGE_MASK) > return -EINVAL; > if (!len) > return -EINVAL; > - if (start < mmap_min_addr) > + if (*start < mmap_min_addr) > return -EINVAL; > - if (start >= task_size) > + if (*start >= task_size) > return -EINVAL; > - if (len > task_size - start) > + if (len > task_size - *start) > return -EINVAL; > return 0; > } > @@ -1325,7 +1327,7 @@ static int userfaultfd_register(struct userfaultfd_ctx *ctx, > goto out; > } > > - ret = validate_range(mm, uffdio_register.range.start, > + ret = validate_range(mm, &uffdio_register.range.start, > uffdio_register.range.len); > if (ret) > goto out; > @@ -1514,7 +1516,7 @@ static int userfaultfd_unregister(struct userfaultfd_ctx *ctx, > if (copy_from_user(&uffdio_unregister, buf, sizeof(uffdio_unregister))) > goto out; > > - ret = validate_range(mm, uffdio_unregister.start, > + ret = validate_range(mm, &uffdio_unregister.start, > uffdio_unregister.len); > if (ret) > goto out; > @@ -1665,7 +1667,7 @@ static int userfaultfd_wake(struct userfaultfd_ctx *ctx, > if (copy_from_user(&uffdio_wake, buf, sizeof(uffdio_wake))) > goto out; > > - ret = validate_range(ctx->mm, uffdio_wake.start, uffdio_wake.len); > + ret = validate_range(ctx->mm, &uffdio_wake.start, uffdio_wake.len); > if (ret) > goto out; > > @@ -1705,7 +1707,7 @@ static int userfaultfd_copy(struct userfaultfd_ctx *ctx, > sizeof(uffdio_copy)-sizeof(__s64))) > goto out; > > - ret = validate_range(ctx->mm, uffdio_copy.dst, uffdio_copy.len); > + ret = validate_range(ctx->mm, &uffdio_copy.dst, uffdio_copy.len); > if (ret) > goto out; > /* > @@ -1761,7 +1763,7 @@ static int userfaultfd_zeropage(struct userfaultfd_ctx *ctx, > sizeof(uffdio_zeropage)-sizeof(__s64))) > goto out; > > - ret = validate_range(ctx->mm, uffdio_zeropage.range.start, > + ret = validate_range(ctx->mm, &uffdio_zeropage.range.start, > uffdio_zeropage.range.len); > if (ret) > goto out; > -- > 2.22.0.410.gd8fdbe21b5-goog _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel