[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20190717110910.GA12017@rapoport-lnx>
Date: Wed, 17 Jul 2019 14:09:13 +0300
From: Mike Rapoport <rppt@...ux.ibm.com>
To: Catalin Marinas <catalin.marinas@....com>
Cc: Andrey Konovalov <andreyknvl@...gle.com>,
linux-arm-kernel@...ts.infradead.org, linux-mm@...ck.org,
linux-kernel@...r.kernel.org, amd-gfx@...ts.freedesktop.org,
dri-devel@...ts.freedesktop.org, linux-rdma@...r.kernel.org,
linux-media@...r.kernel.org, kvm@...r.kernel.org,
linux-kselftest@...r.kernel.org,
Vincenzo Frascino <vincenzo.frascino@....com>,
Will Deacon <will.deacon@....com>,
Mark Rutland <mark.rutland@....com>,
Andrew Morton <akpm@...ux-foundation.org>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Kees Cook <keescook@...omium.org>,
Yishai Hadas <yishaih@...lanox.com>,
Felix Kuehling <Felix.Kuehling@....com>,
Alexander Deucher <Alexander.Deucher@....com>,
Christian Koenig <Christian.Koenig@....com>,
Mauro Carvalho Chehab <mchehab@...nel.org>,
Jens Wiklander <jens.wiklander@...aro.org>,
Alex Williamson <alex.williamson@...hat.com>,
Leon Romanovsky <leon@...nel.org>,
Luc Van Oostenryck <luc.vanoostenryck@...il.com>,
Dave Martin <Dave.Martin@....com>,
Khalid Aziz <khalid.aziz@...cle.com>, enh <enh@...gle.com>,
Jason Gunthorpe <jgg@...pe.ca>,
Christoph Hellwig <hch@...radead.org>,
Dmitry Vyukov <dvyukov@...gle.com>,
Kostya Serebryany <kcc@...gle.com>,
Evgeniy Stepanov <eugenis@...gle.com>,
Lee Smith <Lee.Smith@....com>,
Ramana Radhakrishnan <Ramana.Radhakrishnan@....com>,
Jacob Bramley <Jacob.Bramley@....com>,
Ruben Ayrapetyan <Ruben.Ayrapetyan@....com>,
Robin Murphy <robin.murphy@....com>,
Kevin Brodsky <kevin.brodsky@....com>,
Szabolcs Nagy <Szabolcs.Nagy@....com>,
Al Viro <viro@...iv.linux.org.uk>
Subject: Re: [PATCH v18 08/15] userfaultfd: untag user pointers
On Mon, Jun 24, 2019 at 06:51:21PM +0100, 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 <vincenzo.frascino@....com>
> > Reviewed-by: Catalin Marinas <catalin.marinas@....com>
> > Reviewed-by: Kees Cook <keescook@...omium.org>
> > Signed-off-by: Andrey Konovalov <andreyknvl@...gle.com>
> > ---
> > fs/userfaultfd.c | 22 ++++++++++++----------
> > 1 file changed, 12 insertions(+), 10 deletions(-)
>
> Same here, it needs an ack from Al Viro.
The userfault patches usually go via -mm tree, not sure if Al looks at them :)
FWIW, you can add
Reviewed-by: Mike Rapoport <rppt@...ux.ibm.com>
> > 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
--
Sincerely yours,
Mike.
Powered by blists - more mailing lists