linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Catalin Marinas <catalin.marinas@arm.com>
To: Leon Romanovsky <leon@kernel.org>
Cc: Andrey Konovalov <andreyknvl@google.com>,
	Will Deacon <will.deacon@arm.com>,
	Robin Murphy <robin.murphy@arm.com>,
	Kees Cook <keescook@chromium.org>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	Vincenzo Frascino <vincenzo.frascino@arm.com>,
	Eric Dumazet <edumazet@google.com>,
	"David S. Miller" <davem@davemloft.net>,
	Yishai Hadas <yishaih@mellanox.com>,
	linux-arm-kernel@lists.infradead.org, linux-mm@kvack.org,
	linux-arch@vger.kernel.org, netdev@vger.kernel.org,
	linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org,
	Dmitry Vyukov <dvyukov@google.com>,
	Kostya Serebryany <kcc@google.com>,
	Evgeniy Stepanov <eugenis@google.com>,
	Ramana Radhakrishnan <Ramana.Radhakrishnan@arm.com>,
	Ruben Ayrapetyan <Ruben.Ayrapetyan@arm.com>,
	Luc Van Oostenryck <luc.vanoostenryck@gmail.com>,
	Dave Martin <Dave.Martin@arm.com>,
	Kevin Brodsky <kevin.brodsky@arm.com>,
	Szabolcs Nagy <Szabolcs.Nagy@arm.com>
Subject: Re: [PATCH v13 16/20] IB/mlx4, arm64: untag user pointers in mlx4_get_umem_mr
Date: Tue, 30 Apr 2019 12:16:25 +0100	[thread overview]
Message-ID: <20190430111625.GD29799@arrakis.emea.arm.com> (raw)
In-Reply-To: <20190429180915.GZ6705@mtr-leonro.mtl.com>

(trimmed down the cc list slightly as the message bounces)

On Mon, Apr 29, 2019 at 09:09:15PM +0300, Leon Romanovsky wrote:
> On Wed, Mar 20, 2019 at 03:51:30PM +0100, 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.
> >
> > mlx4_get_umem_mr() uses provided user pointers for vma lookups, which can
> > only by done with untagged pointers.
> >
> > Untag user pointers in this function.
> >
> > Signed-off-by: Andrey Konovalov <andreyknvl@google.com>
> > ---
> >  drivers/infiniband/hw/mlx4/mr.c | 7 ++++---
> >  1 file changed, 4 insertions(+), 3 deletions(-)
> >
> > diff --git a/drivers/infiniband/hw/mlx4/mr.c b/drivers/infiniband/hw/mlx4/mr.c
> > index 395379a480cb..9a35ed2c6a6f 100644
> > --- a/drivers/infiniband/hw/mlx4/mr.c
> > +++ b/drivers/infiniband/hw/mlx4/mr.c
> > @@ -378,6 +378,7 @@ static struct ib_umem *mlx4_get_umem_mr(struct ib_udata *udata, u64 start,
> >  	 * again
> >  	 */
> >  	if (!ib_access_writable(access_flags)) {
> > +		unsigned long untagged_start = untagged_addr(start);
> >  		struct vm_area_struct *vma;
> >
> >  		down_read(&current->mm->mmap_sem);
> > @@ -386,9 +387,9 @@ static struct ib_umem *mlx4_get_umem_mr(struct ib_udata *udata, u64 start,
> >  		 * cover the memory, but for now it requires a single vma to
> >  		 * entirely cover the MR to support RO mappings.
> >  		 */
> > -		vma = find_vma(current->mm, start);
> > -		if (vma && vma->vm_end >= start + length &&
> > -		    vma->vm_start <= start) {
> > +		vma = find_vma(current->mm, untagged_start);
> > +		if (vma && vma->vm_end >= untagged_start + length &&
> > +		    vma->vm_start <= untagged_start) {
> >  			if (vma->vm_flags & VM_WRITE)
> >  				access_flags |= IB_ACCESS_LOCAL_WRITE;
> >  		} else {
> > --
> 
> Thanks,
> Reviewed-by: Leon Romanovsky <leonro@mellanox.com>

Thanks for the review.

> Interesting, the followup question is why mlx4 is only one driver in IB which
> needs such code in umem_mr. I'll take a look on it.

I don't know. Just using the light heuristics of find_vma() shows some
other places. For example, ib_umem_odp_get() gets the umem->address via
ib_umem_start(). This was previously set in ib_umem_get() as called from
mlx4_get_umem_mr(). Should the above patch have just untagged "start" on
entry?

BTW, what's the provenience of such "start" address here? Is it
something that the user would have malloc()'ed? We try to impose some
restrictions one what is allowed to be tagged in user so that we don't
have to untag the addresses in the kernel. For example, if it was the
result of an mmap() on the device file, we don't allow tagging.

Thanks.

-- 
Catalin


  reply	other threads:[~2019-04-30 11:16 UTC|newest]

Thread overview: 62+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-20 14:51 [PATCH v13 00/20] arm64: untag user pointers passed to the kernel Andrey Konovalov
2019-03-20 14:51 ` [PATCH v13 01/20] uaccess: add untagged_addr definition for other arches Andrey Konovalov
2019-03-20 14:51 ` [PATCH v13 02/20] arm64: untag user pointers in access_ok and __uaccess_mask_ptr Andrey Konovalov
2019-03-20 14:51 ` [PATCH v13 03/20] lib, arm64: untag user pointers in strn*_user Andrey Konovalov
2019-03-20 14:51 ` [PATCH v13 04/20] mm, arm64: untag user pointers passed to memory syscalls Andrey Konovalov
2019-03-22 11:43   ` Catalin Marinas
2019-03-28 18:10     ` Andrey Konovalov
2019-03-28 18:19       ` Steven Rostedt
2019-03-29 10:30         ` Catalin Marinas
2019-04-02 12:47           ` Andrey Konovalov
2019-04-11 16:40             ` Andrey Konovalov
2019-04-26 14:17             ` Catalin Marinas
2019-04-29 14:22               ` Andrey Konovalov
2019-03-20 14:51 ` [PATCH v13 05/20] mm, arm64: untag user pointers in mm/gup.c Andrey Konovalov
2019-03-20 14:51 ` [PATCH v13 06/20] mm, arm64: untag user pointers in get_vaddr_frames Andrey Konovalov
2019-03-20 14:51 ` [PATCH v13 07/20] fs, arm64: untag user pointers in copy_mount_options Andrey Konovalov
2019-03-20 14:51 ` [PATCH v13 08/20] fs, arm64: untag user pointers in fs/userfaultfd.c Andrey Konovalov
2019-03-20 14:51 ` [PATCH v13 09/20] net, arm64: untag user pointers in tcp_zerocopy_receive Andrey Konovalov
2019-03-22 12:04   ` Catalin Marinas
2019-03-25 13:54     ` Kevin Brodsky
2019-04-01 16:04       ` Andrey Konovalov
2019-03-20 14:51 ` [PATCH v13 10/20] kernel, arm64: untag user pointers in prctl_set_mm* Andrey Konovalov
2019-03-21 17:52   ` Kevin Brodsky
2019-03-22 15:41   ` Catalin Marinas
2019-04-01 16:44     ` Andrey Konovalov
2019-04-11 16:40       ` Andrey Konovalov
2019-04-26 14:50       ` Catalin Marinas
2019-04-29 14:23         ` Andrey Konovalov
2019-05-01 14:43           ` Vincenzo Frascino
2019-03-20 14:51 ` [PATCH v13 11/20] tracing, arm64: untag user pointers in seq_print_user_ip Andrey Konovalov
2019-03-22 15:45   ` Catalin Marinas
2019-04-01 15:38     ` Andrey Konovalov
2019-03-20 14:51 ` [PATCH v13 12/20] uprobes, arm64: untag user pointers in find_active_uprobe Andrey Konovalov
2019-03-22 15:46   ` Catalin Marinas
2019-03-20 14:51 ` [PATCH v13 13/20] bpf, arm64: untag user pointers in stack_map_get_build_id_offset Andrey Konovalov
2019-03-22 15:52   ` Catalin Marinas
2019-04-01 16:00     ` Andrey Konovalov
2019-03-20 14:51 ` [PATCH v13 14/20] drm/amdgpu, arm64: untag user pointers in amdgpu_ttm_tt_get_user_pages Andrey Konovalov
2019-03-22 15:59   ` Catalin Marinas
2019-03-25 14:02     ` Kevin Brodsky
2019-03-25 22:21   ` Kuehling, Felix
2019-04-02 14:37     ` Andrey Konovalov
2019-04-02 17:52       ` Kuehling, Felix
2019-03-20 14:51 ` [PATCH v13 15/20] drm/radeon, arm64: untag user pointers in radeon_ttm_tt_pin_userptr Andrey Konovalov
2019-03-22 16:00   ` Catalin Marinas
2019-04-02 14:17     ` Andrey Konovalov
2019-03-20 14:51 ` [PATCH v13 16/20] IB/mlx4, arm64: untag user pointers in mlx4_get_umem_mr Andrey Konovalov
2019-04-29 18:09   ` Leon Romanovsky
2019-04-30 11:16     ` Catalin Marinas [this message]
2019-04-30 12:03       ` Leon Romanovsky
2019-05-02 18:44       ` Jason Gunthorpe
2019-05-03 16:28         ` Catalin Marinas
2019-05-03 23:52           ` Jason Gunthorpe
2019-03-20 14:51 ` [PATCH v13 17/20] media/v4l2-core, arm64: untag user pointers in videobuf_dma_contig_user_get Andrey Konovalov
2019-03-22 16:07   ` Catalin Marinas
2019-03-25 14:08     ` Kevin Brodsky
2019-04-01 16:13       ` Andrey Konovalov
2019-03-20 14:51 ` [PATCH v13 18/20] tee/optee, arm64: untag user pointers in check_mem_type Andrey Konovalov
2019-03-22 16:22   ` Catalin Marinas
2019-04-01 16:31     ` Andrey Konovalov
2019-03-20 14:51 ` [PATCH v13 19/20] vfio/type1, arm64: untag user pointers in vaddr_get_pfn Andrey Konovalov
2019-03-20 14:51 ` [PATCH v13 20/20] selftests, arm64: add a selftest for passing tagged pointers to kernel Andrey Konovalov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190430111625.GD29799@arrakis.emea.arm.com \
    --to=catalin.marinas@arm.com \
    --cc=Dave.Martin@arm.com \
    --cc=Ramana.Radhakrishnan@arm.com \
    --cc=Ruben.Ayrapetyan@arm.com \
    --cc=Szabolcs.Nagy@arm.com \
    --cc=akpm@linux-foundation.org \
    --cc=andreyknvl@google.com \
    --cc=davem@davemloft.net \
    --cc=dvyukov@google.com \
    --cc=edumazet@google.com \
    --cc=eugenis@google.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=kcc@google.com \
    --cc=keescook@chromium.org \
    --cc=kevin.brodsky@arm.com \
    --cc=leon@kernel.org \
    --cc=linux-arch@vger.kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=linux-rdma@vger.kernel.org \
    --cc=luc.vanoostenryck@gmail.com \
    --cc=netdev@vger.kernel.org \
    --cc=robin.murphy@arm.com \
    --cc=vincenzo.frascino@arm.com \
    --cc=will.deacon@arm.com \
    --cc=yishaih@mellanox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).