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=-6.8 required=3.0 tests=DKIMWL_WL_HIGH, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED 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 0F4ECC76191 for ; Mon, 15 Jul 2019 16:00:55 +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 DC121205ED for ; Mon, 15 Jul 2019 16:00:54 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="JkzF3+GZ"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=google.com header.i=@google.com header.b="awILUWqn" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org DC121205ED Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.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:To:Subject:Message-ID:Date:From: In-Reply-To:References:MIME-Version:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=sUriQehwiKjtqv4xYzGyA6eiuCNZgIZjNAMPkVD5owo=; b=JkzF3+GZcyLsv4 xFfZw1W3F0Z2UxklkSksUTHbK3aSNCJUMVczNhiIRH/npeg/HRK7wfcJPKJH+D2Xqe9q6/oKW0KRb AP0qNYxS1+Fx8E8xYXcs5hvVr99vblj1jjOlSdIU9zTO940EuuYdi5c6ksGMv9paFPpeX0efGwiEt YtDybUdbcuNTMwpHwHE0wizQyW7i6OAsQYR9nx39vxjwWAtImwHVGLfCRG7LC4nEojAODjVKSto9t CEXfcjdH8a00a3dexGqwGQFJQAiMMC+tYNa41Pxl+gYkCKxuvyX2Vuk3dYg/jJ6L+EcRibz5XFUAU A0kKwukVu2KsWA5qUrUg==; 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 1hn3PG-0000sp-O2; Mon, 15 Jul 2019 16:00:50 +0000 Received: from mail-pf1-x444.google.com ([2607:f8b0:4864:20::444]) by bombadil.infradead.org with esmtps (Exim 4.92 #3 (Red Hat Linux)) id 1hn3PD-0000sK-4P for linux-arm-kernel@lists.infradead.org; Mon, 15 Jul 2019 16:00:48 +0000 Received: by mail-pf1-x444.google.com with SMTP id i189so7617696pfg.10 for ; Mon, 15 Jul 2019 09:00:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=7Q0q/IfCRadymayHol/UUF72+yJ91bYAnFv+xLR30xQ=; b=awILUWqnOhL8QrLhWTtK3zyGeYzsbGaDmlapw+TJPtpLmDPRw1GP6vt2k8M63kLr39 ZOpRC9dNiFsjXCuRW9tvX+XJ4TMinqKEg4V9d0/Cohi7g+H0FLJqsymSlujZFTSwFgq+ HGvo45b5poteQElVP2ylrss//l0SvENb9w0NdEWBIgvpqnNLsaE/1Oq03NG9YiPmMbZi 8k5Fou1N/CEVlyaSlbvq+wKBgrOUzCIo1B2qg8bQ1mlF2+F/VYvQbx6QNpAS+GS8VYMS 4d6tYcKUYuIyyU24AI3+kh3w0LS9e+N+YdRnIzCnanxcL1YdF0dX0SOZIdMQqtDbfKe6 /xuQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=7Q0q/IfCRadymayHol/UUF72+yJ91bYAnFv+xLR30xQ=; b=WlIoqVgljNH1u5VBsji+g1N7A9FTFpIX/lxAnEq8tXhW4XaEWqjhnoOaNQ+wVrdhxu cTbIbakuTkGa+ZEqwsU3nFWrQWswipP5jaaC6bg4Um/BUjIxzFJ8Z8F9y7j53Z3zHw7f dsYghJwatH5Xix8/w1mjz4Q60oNYyinLKC5iizmMEK+M8vcVdpW8WYUmAACq22smPCJz KHoB6CvfJE/51/jdlXybS+kX/lpcJExkg0d7CrkErV5pTRzvKv8kzmAnATOb2O7SsNHM Tyik6qK0sh8AZVlBkFbBs0yaUVzIbFi2N4SYzxklHMm8y+GHsT7IBUXvkWWHhf7+eFu/ JZ3g== X-Gm-Message-State: APjAAAVsbaKJPHHLcx03qDYMY3/dkFNdigDhz3kAU4Mut93EHCizAqlm t7isglMRpgnzzE6+zKKI2PpjvW8gMgDfvKApugm6LQ== X-Google-Smtp-Source: APXvYqw+s/Xsm1Inj9c3bcQDg7/b3DVU+zlhxUxxhLhtcMSC55W2OaWJF9iNwAodQ+4dHaGR8RmRVxTzfqDyBCor0Ro= X-Received: by 2002:a17:90a:25c8:: with SMTP id k66mr30231713pje.129.1563206445986; Mon, 15 Jul 2019 09:00:45 -0700 (PDT) MIME-Version: 1.0 References: <20190624175120.GN29120@arrakis.emea.arm.com> In-Reply-To: <20190624175120.GN29120@arrakis.emea.arm.com> From: Andrey Konovalov Date: Mon, 15 Jul 2019 18:00:34 +0200 Message-ID: Subject: Re: [PATCH v18 08/15] userfaultfd: untag user pointers To: Catalin Marinas X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190715_090047_170301_1F994C0A X-CRM114-Status: GOOD ( 21.34 ) 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 Memory Management List , Khalid Aziz , "open list:KERNEL SELFTEST FRAMEWORK" , 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 , Kostya Serebryany , Greg Kroah-Hartman , Yishai Hadas , LKML , 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 7:51 PM Catalin Marinas wrote: > > 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. Hi Al, Could you take a look at this one as well and give your acked-by? Thanks! > > > 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