Re: [PATCH v18 15/15] selftests, arm64: add a selftest for passing tagged pointers to kernel

2019-09-04 Thread Andrey Konovalov
On Wed, Sep 4, 2019 at 6:22 PM Cristian Marussi wrote: > > Hi Andrey ! > > On 04/09/2019 15:52, Andrey Konovalov wrote: > > On Fri, Aug 23, 2019 at 7:49 PM Cristian Marussi > > wrote: > >> > >> > >> Hi > >> > >> On 23/08/2019

Re: [PATCH v18 15/15] selftests, arm64: add a selftest for passing tagged pointers to kernel

2019-09-04 Thread Andrey Konovalov
On Fri, Aug 23, 2019 at 7:49 PM Cristian Marussi wrote: > > > Hi > > On 23/08/2019 18:16, Andrey Konovalov wrote: > > On Fri, Aug 23, 2019 at 3:56 PM Cristian Marussi > > wrote: > >> > >> Hi Andrey > >> > >> On 24/06/2019 15:33,

Re: [PATCH v18 15/15] selftests, arm64: add a selftest for passing tagged pointers to kernel

2019-08-23 Thread Andrey Konovalov
On Fri, Aug 23, 2019 at 3:56 PM Cristian Marussi wrote: > > Hi Andrey > > On 24/06/2019 15:33, 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 t

Re: [PATCH ARM] selftests, arm64: fix uninitialized symbol in tags_test.c

2019-08-19 Thread Andrey Konovalov
On Mon, Aug 19, 2019 at 5:39 PM Will Deacon wrote: > > On Mon, Aug 19, 2019 at 05:16:37PM +0200, Andrey Konovalov wrote: > > On Mon, Aug 19, 2019 at 5:03 PM Will Deacon wrote: > > > > > > On Mon, Aug 19, 2019 at 03:14:42PM +0200, Andrey Konovalov wrote: &g

Re: [PATCH ARM] selftests, arm64: fix uninitialized symbol in tags_test.c

2019-08-19 Thread Andrey Konovalov
On Mon, Aug 19, 2019 at 5:03 PM Will Deacon wrote: > > On Mon, Aug 19, 2019 at 03:14:42PM +0200, Andrey Konovalov wrote: > > Fix tagged_ptr not being initialized when TBI is not enabled. > > > > Dan Carpenter > > Guessing this was Reported-by, or has Dan introduced

Re: [PATCH ARM] selftests, arm64: fix uninitialized symbol in tags_test.c

2019-08-19 Thread Andrey Konovalov
On Mon, Aug 19, 2019 at 3:14 PM Andrey Konovalov wrote: > > Fix tagged_ptr not being initialized when TBI is not enabled. > > Dan Carpenter > Signed-off-by: Andrey Konovalov > --- > tools/testing/selftests/arm64/tags_test.c | 8 +--- > 1 file changed, 5 in

[PATCH ARM] selftests, arm64: fix uninitialized symbol in tags_test.c

2019-08-19 Thread Andrey Konovalov
Fix tagged_ptr not being initialized when TBI is not enabled. Dan Carpenter Signed-off-by: Andrey Konovalov --- tools/testing/selftests/arm64/tags_test.c | 8 +--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/tools/testing/selftests/arm64/tags_test.c b/tools/testing

Re: [PATCH v19 00/15] arm64: untag user pointers passed to the kernel

2019-08-07 Thread Andrey Konovalov
On Tue, Aug 6, 2019 at 7:13 PM Will Deacon wrote: > > On Wed, Jul 24, 2019 at 03:20:59PM +0100, Will Deacon wrote: > > On Wed, Jul 24, 2019 at 04:16:49PM +0200, Andrey Konovalov wrote: > > > On Wed, Jul 24, 2019 at 4:02 PM Will Deacon wrote: > > > > On Tue,

Re: [PATCH v19 00/15] arm64: untag user pointers passed to the kernel

2019-08-01 Thread Andrey Konovalov
On Thu, Aug 1, 2019 at 2:11 PM Kevin Brodsky wrote: > > On 31/07/2019 17:50, Dave Hansen wrote: > > On 7/23/19 10:58 AM, Andrey Konovalov wrote: > >> The mmap and mremap (only new_addr) syscalls do not currently accept > >> tagged addresses. Architectures may int

Re: [PATCH v19 11/15] IB/mlx4: untag user pointers in mlx4_get_umem_mr

2019-07-25 Thread Andrey Konovalov
On Wed, Jul 24, 2019 at 9:25 PM Jason Gunthorpe wrote: > > On Tue, Jul 23, 2019 at 07:58:48PM +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 o

Re: [PATCH v19 00/15] arm64: untag user pointers passed to the kernel

2019-07-24 Thread Andrey Konovalov
On Wed, Jul 24, 2019 at 4:02 PM Will Deacon wrote: > > Hi Andrey, > > On Tue, Jul 23, 2019 at 08:03:29PM +0200, Andrey Konovalov wrote: > > On Tue, Jul 23, 2019 at 7:59 PM Andrey Konovalov > > wrote: > > > > > > === Overview > > > > > &

Re: [PATCH v19 00/15] arm64: untag user pointers passed to the kernel

2019-07-23 Thread Andrey Konovalov
On Tue, Jul 23, 2019 at 7:59 PM Andrey Konovalov wrote: > > === Overview > > arm64 has a feature called Top Byte Ignore, which allows to embed pointer > tags into the top byte of each pointer. Userspace programs (such as > HWASan, a memory debugging tool [1]) might use thi

[PATCH v19 02/15] arm64: Introduce prctl() options to control the tagged user addresses ABI

2019-07-23 Thread Andrey Konovalov
. The PR_SET_TAGGED_ADDR_CTRL will be expanded in the future to handle MTE-specific settings like imprecise vs precise exceptions. Reviewed-by: Kees Cook Signed-off-by: Catalin Marinas Signed-off-by: Andrey Konovalov --- arch/arm64/Kconfig | 9 arch/arm64/include/asm/processor.h | 8 +++ arch

[PATCH v19 05/15] mm: untag user pointers in mm/gup.c

2019-07-23 Thread Andrey Konovalov
Marinas Signed-off-by: Andrey Konovalov --- mm/gup.c | 4 1 file changed, 4 insertions(+) diff --git a/mm/gup.c b/mm/gup.c index 98f13ab37bac..1c1c97ec63df 100644 --- a/mm/gup.c +++ b/mm/gup.c @@ -799,6 +799,8 @@ static long __get_user_pages(struct task_struct *tsk, struct mm_struct *mm

[PATCH v19 06/15] mm: untag user pointers in get_vaddr_frames

2019-07-23 Thread Andrey Konovalov
of locating and changing all callers of this function, perform untagging in it. Reviewed-by: Khalid Aziz Reviewed-by: Vincenzo Frascino Acked-by: Catalin Marinas Reviewed-by: Kees Cook Signed-off-by: Andrey Konovalov --- mm/frame_vector.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mm

[PATCH v19 14/15] vfio/type1: untag user pointers in vaddr_get_pfn

2019-07-23 Thread Andrey Konovalov
pointers in this function. Reviewed-by: Eric Auger Reviewed-by: Vincenzo Frascino Reviewed-by: Catalin Marinas Reviewed-by: Kees Cook Signed-off-by: Andrey Konovalov --- drivers/vfio/vfio_iommu_type1.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/vfio/vfio_iommu_type1.c b

[PATCH v19 13/15] tee/shm: untag user pointers in tee_shm_register

2019-07-23 Thread Andrey Konovalov
s (via __check_mem_type()), which can only by done with untagged pointers. Untag user pointers in this function. Reviewed-by: Kees Cook Acked-by: Jens Wiklander Signed-off-by: Andrey Konovalov --- drivers/tee/tee_shm.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/tee/tee_shm.c b/drive

[PATCH v19 11/15] IB/mlx4: untag user pointers in mlx4_get_umem_mr

2019-07-23 Thread Andrey Konovalov
pointers in this function. Reviewed-by: Jason Gunthorpe Acked-by: Catalin Marinas Reviewed-by: Kees Cook Signed-off-by: Andrey Konovalov --- 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

[PATCH v19 04/15] mm: untag user pointers passed to memory syscalls

2019-07-23 Thread Andrey Konovalov
Marinas Reviewed-by: Kees Cook Signed-off-by: Andrey Konovalov --- mm/madvise.c | 2 ++ mm/mempolicy.c | 3 +++ mm/migrate.c | 2 +- mm/mincore.c | 2 ++ mm/mlock.c | 4 mm/mprotect.c | 2 ++ mm/mremap.c| 7 +++ mm/msync.c | 2 ++ 8 files changed, 23 insertions(+), 1

[PATCH v19 08/15] userfaultfd: untag user pointers

2019-07-23 Thread Andrey Konovalov
pointers in validate_range(). Reviewed-by: Mike Rapoport 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(-) diff --git a/fs

[PATCH v19 03/15] lib: untag user pointers in strn*_user

2019-07-23 Thread Andrey Konovalov
-by: Vincenzo Frascino Reviewed-by: Khalid Aziz Acked-by: Kees Cook Reviewed-by: Catalin Marinas Signed-off-by: Andrey Konovalov --- lib/strncpy_from_user.c | 3 ++- lib/strnlen_user.c | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/strncpy_from_user.c b/lib

[PATCH v19 10/15] drm/radeon: untag user pointers in radeon_gem_userptr_ioctl

2019-07-23 Thread Andrey Konovalov
in radeon_gem_userptr_ioctl(). Reviewed-by: Khalid Aziz Reviewed-by: Kees Cook Suggested-by: Felix Kuehling Acked-by: Felix Kuehling Signed-off-by: Andrey Konovalov --- drivers/gpu/drm/radeon/radeon_gem.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/gpu/drm/radeon/radeon_gem.c b/drivers/gpu

[PATCH v19 07/15] fs/namespace: untag user pointers in copy_mount_options

2019-07-23 Thread Andrey Konovalov
-by: Catalin Marinas Signed-off-by: Andrey Konovalov --- fs/namespace.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/namespace.c b/fs/namespace.c index 6464ea4acba9..b32eb26af8bf 100644 --- a/fs/namespace.c +++ b/fs/namespace.c @@ -2994,7 +2994,7 @@ void

[PATCH v19 12/15] media/v4l2-core: untag user pointers in videobuf_dma_contig_user_get

2019-07-23 Thread Andrey Konovalov
. Untag the pointers in this function. Reviewed-by: Khalid Aziz Reviewed-by: Kees Cook Acked-by: Mauro Carvalho Chehab Signed-off-by: Andrey Konovalov --- drivers/media/v4l2-core/videobuf-dma-contig.c | 9 + 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/drivers/media

[PATCH v19 15/15] selftests, arm64: add a selftest for passing tagged pointers to kernel

2019-07-23 Thread Andrey Konovalov
accepting tagged user pointers the test fails with EFAULT. Reviewed-by: Catalin Marinas Acked-by: Kees Cook Signed-off-by: Andrey Konovalov --- tools/testing/selftests/arm64/.gitignore | 1 + tools/testing/selftests/arm64/Makefile| 11 +++ .../testing/selftests/arm64

[PATCH v19 09/15] drm/amdgpu: untag user pointers

2019-07-23 Thread Andrey Konovalov
makes sure that an untagged pointer is passed to amdgpu_ttm_tt_get_user_pages(), which uses it for vma lookups. Reviewed-by: Kees Cook Suggested-by: Felix Kuehling Acked-by: Felix Kuehling Signed-off-by: Andrey Konovalov --- drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c | 2 +- drivers/gpu/drm

[PATCH v19 01/15] arm64: untag user pointers in access_ok and __uaccess_mask_ptr

2019-07-23 Thread Andrey Konovalov
untags the pointers to perform the checks, but then passes them as is into the kernel internals. Reviewed-by: Vincenzo Frascino Reviewed-by: Kees Cook Reviewed-by: Catalin Marinas Signed-off-by: Andrey Konovalov --- arch/arm64/include/asm/uaccess.h | 10 +++--- 1 file changed, 7 insertions

[PATCH v19 00/15] arm64: untag user pointers passed to the kernel

2019-07-23 Thread Andrey Konovalov
ved excessive untagging in gup.c. - Removed untagging pointers returned from __uaccess_mask_ptr. Changes in v1: - Rebased onto 4.17-rc1. Changes in RFC v2: - Added "#ifndef untagged_addr..." fallback in linux/uaccess.h instead of defining it for each arch individually. - Updated Docume

Re: [PATCH v18 11/15] IB/mlx4: untag user pointers in mlx4_get_umem_mr

2019-07-17 Thread Andrey Konovalov
On Wed, Jul 17, 2019 at 1:58 PM Jason Gunthorpe wrote: > > On Wed, Jul 17, 2019 at 01:44:07PM +0200, Andrey Konovalov wrote: > > On Tue, Jul 16, 2019 at 2:06 PM Jason Gunthorpe wrote: > > > > > > On Tue, Jul 16, 2019 at 12:42:07PM +0200, Andrey Konovalov wrote: >

Re: [PATCH v18 08/15] userfaultfd: untag user pointers

2019-07-17 Thread Andrey Konovalov
On Wed, Jul 17, 2019 at 1:09 PM Mike Rapoport wrote: > > 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 p

Re: [PATCH v18 11/15] IB/mlx4: untag user pointers in mlx4_get_umem_mr

2019-07-17 Thread Andrey Konovalov
On Tue, Jul 16, 2019 at 2:06 PM Jason Gunthorpe wrote: > > On Tue, Jul 16, 2019 at 12:42:07PM +0200, Andrey Konovalov wrote: > > On Mon, Jul 15, 2019 at 8:05 PM Jason Gunthorpe wrote: > > > > > > On Mon, Jul 15, 2019 at 06:01:29PM +0200, Andrey Konovalov wrote: >

Re: [PATCH v18 11/15] IB/mlx4: untag user pointers in mlx4_get_umem_mr

2019-07-17 Thread Andrey Konovalov
On Tue, Jul 16, 2019 at 2:06 PM Jason Gunthorpe wrote: > > On Tue, Jul 16, 2019 at 12:42:07PM +0200, Andrey Konovalov wrote: > > On Mon, Jul 15, 2019 at 8:05 PM Jason Gunthorpe wrote: > > > > > > On Mon, Jul 15, 2019 at 06:01:29PM +0200, Andrey Konovalov wrote: >

Re: [PATCH v18 11/15] IB/mlx4: untag user pointers in mlx4_get_umem_mr

2019-07-16 Thread Andrey Konovalov
On Mon, Jul 15, 2019 at 8:05 PM Jason Gunthorpe wrote: > > On Mon, Jul 15, 2019 at 06:01:29PM +0200, Andrey Konovalov wrote: > > On Mon, Jun 24, 2019 at 7:40 PM Catalin Marinas > > wrote: > > > > > > On Mon, Jun 24, 2019 at 04:32:56PM +0200, Andrey Konovalov

Re: [PATCH v18 11/15] IB/mlx4: untag user pointers in mlx4_get_umem_mr

2019-07-15 Thread Andrey Konovalov
On Mon, Jun 24, 2019 at 7:40 PM Catalin Marinas wrote: > > On Mon, Jun 24, 2019 at 04:32:56PM +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 o

Re: [PATCH v18 08/15] userfaultfd: untag user pointers

2019-07-15 Thread Andrey Konovalov
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 o

Re: [PATCH v18 07/15] fs/namespace: untag user pointers in copy_mount_options

2019-07-15 Thread Andrey Konovalov
On Mon, Jun 24, 2019 at 7:50 PM Catalin Marinas wrote: > > On Mon, Jun 24, 2019 at 04:32:52PM +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 o

[PATCH v18 03/15] lib: untag user pointers in strn*_user

2019-06-24 Thread Andrey Konovalov
-by: Vincenzo Frascino Reviewed-by: Khalid Aziz Acked-by: Kees Cook Reviewed-by: Catalin Marinas Signed-off-by: Andrey Konovalov --- lib/strncpy_from_user.c | 3 ++- lib/strnlen_user.c | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/strncpy_from_user.c b/lib

[PATCH v18 09/15] drm/amdgpu: untag user pointers

2019-06-24 Thread Andrey Konovalov
makes sure that an untagged pointer is passed to amdgpu_ttm_tt_get_user_pages(), which uses it for vma lookups. Suggested-by: Felix Kuehling Acked-by: Felix Kuehling Signed-off-by: Andrey Konovalov --- drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c | 2 +- drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c

[PATCH v18 10/15] drm/radeon: untag user pointers in radeon_gem_userptr_ioctl

2019-06-24 Thread Andrey Konovalov
in radeon_gem_userptr_ioctl(). Suggested-by: Felix Kuehling Acked-by: Felix Kuehling Signed-off-by: Andrey Konovalov --- drivers/gpu/drm/radeon/radeon_gem.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/gpu/drm/radeon/radeon_gem.c b/drivers/gpu/drm/radeon/radeon_gem.c index 44617dec8183

[PATCH v18 15/15] selftests, arm64: add a selftest for passing tagged pointers to kernel

2019-06-24 Thread Andrey Konovalov
accepting tagged user pointers the test fails with EFAULT. Signed-off-by: Andrey Konovalov --- tools/testing/selftests/arm64/.gitignore | 1 + tools/testing/selftests/arm64/Makefile| 11 +++ .../testing/selftests/arm64/run_tags_test.sh | 12 tools/testing/selftests

[PATCH v18 12/15] media/v4l2-core: untag user pointers in videobuf_dma_contig_user_get

2019-06-24 Thread Andrey Konovalov
. Untag the pointers in this function. Reviewed-by: Khalid Aziz Reviewed-by: Kees Cook Acked-by: Mauro Carvalho Chehab Signed-off-by: Andrey Konovalov --- drivers/media/v4l2-core/videobuf-dma-contig.c | 9 + 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/drivers/media

[PATCH v18 11/15] IB/mlx4: untag user pointers in mlx4_get_umem_mr

2019-06-24 Thread Andrey Konovalov
pointers in this function. Signed-off-by: Andrey Konovalov --- 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 355205a28544..13d9f917f249 100644 --- a/drivers

[PATCH v18 14/15] vfio/type1: untag user pointers in vaddr_get_pfn

2019-06-24 Thread Andrey Konovalov
pointers in this function. Reviewed-by: Eric Auger Reviewed-by: Vincenzo Frascino Reviewed-by: Catalin Marinas Reviewed-by: Kees Cook Signed-off-by: Andrey Konovalov --- drivers/vfio/vfio_iommu_type1.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/vfio/vfio_iommu_type1.c b

[PATCH v18 13/15] tee/shm: untag user pointers in tee_shm_register

2019-06-24 Thread Andrey Konovalov
s (via __check_mem_type()), which can only by done with untagged pointers. Untag user pointers in this function. Reviewed-by: Kees Cook Acked-by: Jens Wiklander Signed-off-by: Andrey Konovalov --- drivers/tee/tee_shm.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/tee/tee_shm.c b/drive

[PATCH v18 06/15] mm: untag user pointers in get_vaddr_frames

2019-06-24 Thread Andrey Konovalov
of locating and changing all callers of this function, perform untagging in it. Reviewed-by: Khalid Aziz Reviewed-by: Vincenzo Frascino Acked-by: Catalin Marinas Reviewed-by: Kees Cook Signed-off-by: Andrey Konovalov --- mm/frame_vector.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mm

[PATCH v18 08/15] userfaultfd: untag user pointers

2019-06-24 Thread Andrey Konovalov
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(-) diff --git a/fs/userfaultfd.c b/fs/userfaultfd.c

[PATCH v18 07/15] fs/namespace: untag user pointers in copy_mount_options

2019-06-24 Thread Andrey Konovalov
-by: Catalin Marinas Signed-off-by: Andrey Konovalov --- fs/namespace.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/namespace.c b/fs/namespace.c index 7660c2749c96..ec78f7223917 100644 --- a/fs/namespace.c +++ b/fs/namespace.c @@ -2994,7 +2994,7 @@ void

[PATCH v18 05/15] mm: untag user pointers in mm/gup.c

2019-06-24 Thread Andrey Konovalov
Marinas Signed-off-by: Andrey Konovalov --- mm/gup.c | 4 1 file changed, 4 insertions(+) diff --git a/mm/gup.c b/mm/gup.c index ddde097cf9e4..c37df3d455a2 100644 --- a/mm/gup.c +++ b/mm/gup.c @@ -802,6 +802,8 @@ static long __get_user_pages(struct task_struct *tsk, struct mm_struct *mm

[PATCH v18 02/15] arm64: Introduce prctl() options to control the tagged user addresses ABI

2019-06-24 Thread Andrey Konovalov
. The PR_SET_TAGGED_ADDR_CTRL will be expanded in the future to handle MTE-specific settings like imprecise vs precise exceptions. Signed-off-by: Catalin Marinas Signed-off-by: Andrey Konovalov --- arch/arm64/Kconfig | 9 arch/arm64/include/asm/processor.h | 8 arch/arm64/include/asm

[PATCH v18 01/15] arm64: untag user pointers in access_ok and __uaccess_mask_ptr

2019-06-24 Thread Andrey Konovalov
untags the pointers to perform the checks, but then passes them as is into the kernel internals. Reviewed-by: Vincenzo Frascino Reviewed-by: Kees Cook Reviewed-by: Catalin Marinas Signed-off-by: Andrey Konovalov --- arch/arm64/include/asm/uaccess.h | 10 +++--- 1 file changed, 7 insertions

[PATCH v18 00/15] arm64: untag user pointers passed to the kernel

2019-06-24 Thread Andrey Konovalov
ointers returned from __uaccess_mask_ptr. Changes in v1: - Rebased onto 4.17-rc1. Changes in RFC v2: - Added "#ifndef untagged_addr..." fallback in linux/uaccess.h instead of defining it for each arch individually. - Updated Documentation/arm64/tagged-pointers.txt. - Dropped &q

Re: [PATCH v17 04/15] mm, arm64: untag user pointers passed to memory syscalls

2019-06-24 Thread Andrey Konovalov
On Wed, Jun 19, 2019 at 6:46 PM Khalid Aziz wrote: > > On 6/19/19 9:55 AM, Khalid Aziz wrote: > > On 6/12/19 5:43 AM, 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

Re: [PATCH v17 15/15] selftests, arm64: add a selftest for passing tagged pointers to kernel

2019-06-20 Thread Andrey Konovalov
On Wed, Jun 12, 2019 at 5:01 PM Catalin Marinas wrote: > > On Wed, Jun 12, 2019 at 01:30:36PM +0100, Szabolcs Nagy wrote: > > On 12/06/2019 12:43, Andrey Konovalov wrote: > > > --- /dev/null > > > +++ b/tools/testing/selftests/arm64/tags_lib.c > > >

Re: [PATCH v17 03/15] arm64: Introduce prctl() options to control the tagged user addresses ABI

2019-06-19 Thread Andrey Konovalov
On Wed, Jun 12, 2019 at 1:43 PM Andrey Konovalov wrote: > > From: Catalin Marinas > > It is not desirable to relax the ABI to allow tagged user addresses into > the kernel indiscriminately. This patch introduces a prctl() interface > for enabling or disabling the tagged ABI wi

[PATCH v17 04/15] mm, arm64: untag user pointers passed to memory syscalls

2019-06-12 Thread Andrey Konovalov
, mincore, mlock, mlock2, mprotect, mremap, msync, munlock, move_pages. The mmap and mremap syscalls do not currently accept tagged addresses. Architectures may interpret the tag as a background colour for the corresponding vma. Reviewed-by: Catalin Marinas Reviewed-by: Kees Cook Signed-off-by: Andrey

[PATCH v17 07/15] fs, arm64: untag user pointers in copy_mount_options

2019-06-12 Thread Andrey Konovalov
, 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

[PATCH v17 09/15] drm/amdgpu, arm64: untag user pointers

2019-06-12 Thread Andrey Konovalov
. This also makes sure that an untagged pointer is passed to amdgpu_ttm_tt_get_user_pages(), which uses it for vma lookups. Suggested-by: Felix Kuehling Acked-by: Felix Kuehling Signed-off-by: Andrey Konovalov --- drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c | 2 +- drivers/gpu/drm/amd/amdgpu

[PATCH v17 15/15] selftests, arm64: add a selftest for passing tagged pointers to kernel

2019-06-12 Thread Andrey Konovalov
the kernel accepting tagged user pointers the test fails with EFAULT. Co-developed-by: Catalin Marinas Signed-off-by: Andrey Konovalov --- tools/testing/selftests/arm64/.gitignore | 2 + tools/testing/selftests/arm64/Makefile| 22 +++ .../testing/selftests/arm64/run_tags_test.sh

[PATCH v17 13/15] tee/shm, arm64: untag user pointers in tee_shm_register

2019-06-12 Thread Andrey Konovalov
s (via __check_mem_type()), which can only by done with untagged pointers. Untag user pointers in this function. Reviewed-by: Kees Cook Acked-by: Jens Wiklander Signed-off-by: Andrey Konovalov --- drivers/tee/tee_shm.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/tee/tee_shm.c b/drive

[PATCH v17 14/15] vfio/type1, arm64: untag user pointers in vaddr_get_pfn

2019-06-12 Thread Andrey Konovalov
user pointers in this function. Reviewed-by: Catalin Marinas Reviewed-by: Kees Cook Signed-off-by: Andrey Konovalov --- drivers/vfio/vfio_iommu_type1.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/vfio/vfio_iommu_type1.c b/drivers/vfio/vfio_iommu_type1.c index 3ddc375e7063

[PATCH v17 08/15] userfaultfd, arm64: untag user pointers

2019-06-12 Thread Andrey Konovalov
user pointers in validate_range(). Reviewed-by: Catalin Marinas Reviewed-by: Kees Cook Signed-off-by: Andrey Konovalov --- fs/userfaultfd.c | 22 -- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/fs/userfaultfd.c b/fs/userfaultfd.c index 3b30301c90ec

[PATCH v17 12/15] media/v4l2-core, arm64: untag user pointers in videobuf_dma_contig_user_get

2019-06-12 Thread Andrey Konovalov
pointers. Untag the pointers in this function. Reviewed-by: Kees Cook Acked-by: Mauro Carvalho Chehab Signed-off-by: Andrey Konovalov --- drivers/media/v4l2-core/videobuf-dma-contig.c | 9 + 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/drivers/media/v4l2-core/videobuf-dma

[PATCH v17 10/15] drm/radeon, arm64: untag user pointers in radeon_gem_userptr_ioctl

2019-06-12 Thread Andrey Konovalov
in radeon_gem_userptr_ioctl(). Suggested-by: Felix Kuehling Acked-by: Felix Kuehling Signed-off-by: Andrey Konovalov --- drivers/gpu/drm/radeon/radeon_gem.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/gpu/drm/radeon/radeon_gem.c b/drivers/gpu/drm/radeon/radeon_gem.c index 44617dec8183

[PATCH v17 11/15] IB/mlx4, arm64: untag user pointers in mlx4_get_umem_mr

2019-06-12 Thread Andrey Konovalov
. Untag user pointers in this function. Signed-off-by: Andrey Konovalov --- 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 355205a28544..13d9f917f249 100644 --- a/drivers

[PATCH v17 00/15] arm64: untag user pointers passed to the kernel

2019-06-12 Thread Andrey Konovalov
sed onto 81e97f013 (4.18-rc1+). Changes in v3: - Rebased onto e5c51f30 (4.17-rc6+). - Added linux-arch@ to the list of recipients. Changes in v2: - Rebased onto 2d618bdf (4.17-rc3+). - Removed excessive untagging in gup.c. - Removed untagging pointers returned from __uaccess_mask_ptr. Changes in v

[PATCH v17 03/15] arm64: Introduce prctl() options to control the tagged user addresses ABI

2019-06-12 Thread Andrey Konovalov
From: Catalin Marinas It is not desirable to relax the ABI to allow tagged user addresses into the kernel indiscriminately. This patch introduces a prctl() interface for enabling or disabling the tagged ABI with a global sysctl control for preventing applications from enabling the relaxed ABI

[PATCH v17 02/15] lib, arm64: untag user pointers in strn*_user

2019-06-12 Thread Andrey Konovalov
-by: Khalid Aziz Acked-by: Kees Cook Reviewed-by: Catalin Marinas Signed-off-by: Andrey Konovalov --- lib/strncpy_from_user.c | 3 ++- lib/strnlen_user.c | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/strncpy_from_user.c b/lib/strncpy_from_user.c index 023ba9f3b99f

[PATCH v17 06/15] mm, arm64: untag user pointers in get_vaddr_frames

2019-06-12 Thread Andrey Konovalov
of locating and changing all callers of this function, perform untagging in it. Acked-by: Catalin Marinas Reviewed-by: Kees Cook Signed-off-by: Andrey Konovalov --- mm/frame_vector.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mm/frame_vector.c b/mm/frame_vector.c index c64dca6e27c2

[PATCH v17 05/15] mm, arm64: untag user pointers in mm/gup.c

2019-06-12 Thread Andrey Konovalov
get_user_pages, that is used by the futex syscall). Since a user can provided tagged addresses, we need to handle this case. Add untagging to gup.c functions that use user addresses for vma lookups. Reviewed-by: Kees Cook Reviewed-by: Catalin Marinas Signed-off-by: Andrey Konovalov --- mm/gup.c

[PATCH v17 01/15] arm64: untag user pointers in access_ok and __uaccess_mask_ptr

2019-06-12 Thread Andrey Konovalov
temporarily untags the pointers to perform the checks, but then passes them as is into the kernel internals. Reviewed-by: Kees Cook Reviewed-by: Catalin Marinas Signed-off-by: Andrey Konovalov --- arch/arm64/include/asm/uaccess.h | 10 +++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff

Re: [PATCH v16 08/16] fs, arm64: untag user pointers in copy_mount_options

2019-06-12 Thread Andrey Konovalov
On Tue, Jun 11, 2019 at 4:38 PM Andrey Konovalov wrote: > > On Sat, Jun 8, 2019 at 6:02 AM Kees Cook wrote: > > > > On Mon, Jun 03, 2019 at 06:55:10PM +0200, Andrey Konovalov wrote: > > > This patch is a part of a series that extends arm64 kernel ABI to allow to >

Re: [PATCH v16 16/16] selftests, arm64: add a selftest for passing tagged pointers to kernel

2019-06-12 Thread Andrey Konovalov
On Tue, Jun 11, 2019 at 7:50 PM Catalin Marinas wrote: > > On Tue, Jun 11, 2019 at 07:18:04PM +0200, Andrey Konovalov wrote: > > On Tue, Jun 11, 2019 at 5:01 PM Catalin Marinas > > wrote: > > > static void *tag_ptr(void *ptr) > > > { > >

Re: [PATCH v16 05/16] arm64: untag user pointers passed to memory syscalls

2019-06-12 Thread Andrey Konovalov
On Tue, Jun 11, 2019 at 7:45 PM Catalin Marinas wrote: > > On Tue, Jun 11, 2019 at 05:35:31PM +0200, Andrey Konovalov wrote: > > On Mon, Jun 10, 2019 at 4:28 PM Catalin Marinas > > wrote: > > > On Mon, Jun 03, 2019 at 06:55:07PM +0200, Andrey Konovalov wrote: &

Re: [PATCH v16 04/16] mm: untag user pointers in do_pages_move

2019-06-12 Thread Andrey Konovalov
On Tue, Jun 11, 2019 at 10:18 PM Khalid Aziz wrote: > > On 6/3/19 10:55 AM, 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 0x

Re: [PATCH v16 02/16] arm64: untag user pointers in access_ok and __uaccess_mask_ptr

2019-06-12 Thread Andrey Konovalov
On Tue, Jun 11, 2019 at 7:39 PM Catalin Marinas wrote: > > On Tue, Jun 11, 2019 at 07:09:46PM +0200, Andrey Konovalov wrote: > > On Tue, Jun 11, 2019 at 4:57 PM Catalin Marinas > > wrote: > > > > > > On Mon, Jun 10, 2019 at 06:53:27PM +0100, Catalin Marinas

Re: [PATCH v16 16/16] selftests, arm64: add a selftest for passing tagged pointers to kernel

2019-06-11 Thread Andrey Konovalov
On Tue, Jun 11, 2019 at 5:01 PM Catalin Marinas wrote: > > On Mon, Jun 03, 2019 at 06:55:18PM +0200, 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 o

Re: [PATCH v16 02/16] arm64: untag user pointers in access_ok and __uaccess_mask_ptr

2019-06-11 Thread Andrey Konovalov
On Tue, Jun 11, 2019 at 4:57 PM Catalin Marinas wrote: > > On Mon, Jun 10, 2019 at 06:53:27PM +0100, Catalin Marinas wrote: > > On Mon, Jun 03, 2019 at 06:55:04PM +0200, Andrey Konovalov wrote: > > > diff --git a/arch/arm64/include/asm/uaccess.h > > > b/ar

Re: [PATCH v16 05/16] arm64: untag user pointers passed to memory syscalls

2019-06-11 Thread Andrey Konovalov
On Mon, Jun 10, 2019 at 4:28 PM Catalin Marinas wrote: > > On Mon, Jun 03, 2019 at 06:55:07PM +0200, 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 o

Re: [PATCH v16 08/16] fs, arm64: untag user pointers in copy_mount_options

2019-06-11 Thread Andrey Konovalov
On Sat, Jun 8, 2019 at 6:02 AM Kees Cook wrote: > > On Mon, Jun 03, 2019 at 06:55:10PM +0200, 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 o

Re: [PATCH v16 12/16] IB, arm64: untag user pointers in ib_uverbs_(re)reg_mr()

2019-06-04 Thread Andrey Konovalov
On Tue, Jun 4, 2019 at 3:02 PM Jason Gunthorpe wrote: > > On Tue, Jun 04, 2019 at 02:45:32PM +0200, Andrey Konovalov wrote: > > On Tue, Jun 4, 2019 at 2:27 PM Jason Gunthorpe wrote: > > > > > > On Tue, Jun 04, 2019 at 02:18:19PM +0200, Andrey Konovalov wrote: >

Re: [PATCH v16 12/16] IB, arm64: untag user pointers in ib_uverbs_(re)reg_mr()

2019-06-04 Thread Andrey Konovalov
On Tue, Jun 4, 2019 at 2:27 PM Jason Gunthorpe wrote: > > On Tue, Jun 04, 2019 at 02:18:19PM +0200, Andrey Konovalov wrote: > > On Mon, Jun 3, 2019 at 7:46 PM Jason Gunthorpe wrote: > > > > > > On Mon, Jun 03, 2019 at 06:55:14PM +0200, Andrey Konovalov wrote

Re: [PATCH v16 12/16] IB, arm64: untag user pointers in ib_uverbs_(re)reg_mr()

2019-06-04 Thread Andrey Konovalov
On Mon, Jun 3, 2019 at 7:46 PM Jason Gunthorpe wrote: > > On Mon, Jun 03, 2019 at 06:55:14PM +0200, 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 o

Re: [PATCH v16 01/16] uaccess: add untagged_addr definition for other arches

2019-06-04 Thread Andrey Konovalov
On Mon, Jun 3, 2019 at 8:17 PM Khalid Aziz wrote: > > On 6/3/19 11:29 AM, Christoph Hellwig wrote: > > On Mon, Jun 03, 2019 at 11:24:35AM -0600, Khalid Aziz wrote: > >> On 6/3/19 11:06 AM, Andrey Konovalov wrote: > >>> On Mon, Jun 3, 2019 at 7:04 PM

Re: [PATCH v16 01/16] uaccess: add untagged_addr definition for other arches

2019-06-03 Thread Andrey Konovalov
On Mon, Jun 3, 2019 at 7:04 PM Khalid Aziz wrote: > > On 6/3/19 10:55 AM, Andrey Konovalov wrote: > > To allow arm64 syscalls to accept tagged pointers from userspace, we must > > untag them when they are passed to the kernel. Since untagging is done in > > gen

[PATCH v16 05/16] arm64: untag user pointers passed to memory syscalls

2019-06-03 Thread Andrey Konovalov
, mincore, mlock, mlock2, mprotect, mremap, msync, munlock. Signed-off-by: Andrey Konovalov --- mm/madvise.c | 2 ++ mm/mempolicy.c | 3 +++ mm/mincore.c | 2 ++ mm/mlock.c | 4 mm/mprotect.c | 2 ++ mm/mremap.c| 2 ++ mm/msync.c | 2 ++ 7 files changed, 17 insertions(+) diff

[PATCH v16 15/16] vfio/type1, arm64: untag user pointers in vaddr_get_pfn

2019-06-03 Thread Andrey Konovalov
user pointers in this function. Signed-off-by: Andrey Konovalov --- drivers/vfio/vfio_iommu_type1.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/vfio/vfio_iommu_type1.c b/drivers/vfio/vfio_iommu_type1.c index 3ddc375e7063..528e39a1c2dd 100644 --- a/drivers/vfio/vfio_iommu_type1.c

[PATCH v16 10/16] drm/amdgpu, arm64: untag user pointers

2019-06-03 Thread Andrey Konovalov
. This also makes sure that an untagged pointer is passed to amdgpu_ttm_tt_get_user_pages(), which uses it for vma lookups. Suggested-by: Kuehling, Felix Acked-by: Felix Kuehling Signed-off-by: Andrey Konovalov --- drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c | 2 +- drivers/gpu/drm/amd/amdgpu

[PATCH v16 09/16] fs, arm64: untag user pointers in fs/userfaultfd.c

2019-06-03 Thread Andrey Konovalov
user pointers in validate_range(). Signed-off-by: Andrey Konovalov --- fs/userfaultfd.c | 22 -- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/fs/userfaultfd.c b/fs/userfaultfd.c index 3b30301c90ec..24d68c3b5ee2 100644 --- a/fs/userfaultfd.c +++ b/fs

[PATCH v16 08/16] fs, arm64: untag user pointers in copy_mount_options

2019-06-03 Thread Andrey Konovalov
, 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: Catalin Marinas Signed-off-by: Andrey Konovalov --- fs/namespace.c | 2

[PATCH v16 13/16] media/v4l2-core, arm64: untag user pointers in videobuf_dma_contig_user_get

2019-06-03 Thread Andrey Konovalov
pointers. Untag the pointers in this function. Acked-by: Mauro Carvalho Chehab Signed-off-by: Andrey Konovalov --- drivers/media/v4l2-core/videobuf-dma-contig.c | 9 + 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/drivers/media/v4l2-core/videobuf-dma-contig.c b/drivers

[PATCH v16 14/16] tee, arm64: untag user pointers in tee_shm_register

2019-06-03 Thread Andrey Konovalov
s (via __check_mem_type()), which can only by done with untagged pointers. Untag user pointers in this function. Signed-off-by: Andrey Konovalov --- drivers/tee/tee_shm.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/tee/tee_shm.c b/drivers/tee/tee_shm.c index 49fd7312e2aa..96945f4cefb8

[PATCH v16 11/16] drm/radeon, arm64: untag user pointers in radeon_gem_userptr_ioctl

2019-06-03 Thread Andrey Konovalov
in radeon_gem_userptr_ioctl(). Suggested-by: Kuehling, Felix Acked-by: Felix Kuehling Signed-off-by: Andrey Konovalov --- drivers/gpu/drm/radeon/radeon_gem.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/gpu/drm/radeon/radeon_gem.c b/drivers/gpu/drm/radeon/radeon_gem.c index 44617dec8183

[PATCH v16 12/16] IB, arm64: untag user pointers in ib_uverbs_(re)reg_mr()

2019-06-03 Thread Andrey Konovalov
by done with untagged pointers. Untag user pointers in these functions. Signed-off-by: Andrey Konovalov --- drivers/infiniband/core/uverbs_cmd.c | 4 1 file changed, 4 insertions(+) diff --git a/drivers/infiniband/core/uverbs_cmd.c b/drivers/infiniband/core/uverbs_cmd.c index 5a3a1780ceea

[PATCH v16 04/16] mm: untag user pointers in do_pages_move

2019-06-03 Thread Andrey Konovalov
. Reviewed-by: Catalin Marinas Signed-off-by: Andrey Konovalov --- mm/migrate.c | 1 + 1 file changed, 1 insertion(+) diff --git a/mm/migrate.c b/mm/migrate.c index f2ecc2855a12..3930bb6fa656 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -1617,6 +1617,7 @@ static int do_pages_move(struct mm_struct

[PATCH v16 06/16] mm, arm64: untag user pointers in mm/gup.c

2019-06-03 Thread Andrey Konovalov
get_user_pages, that is used by the futex syscall). Since a user can provided tagged addresses, we need to handle this case. Add untagging to gup.c functions that use user addresses for vma lookups. Reviewed-by: Catalin Marinas Signed-off-by: Andrey Konovalov --- mm/gup.c | 4 1 file changed

[PATCH v16 02/16] arm64: untag user pointers in access_ok and __uaccess_mask_ptr

2019-06-03 Thread Andrey Konovalov
temporarily untags the pointers to perform the checks, but then passes them as is into the kernel internals. Reviewed-by: Catalin Marinas Signed-off-by: Andrey Konovalov --- arch/arm64/include/asm/uaccess.h | 10 ++ 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/arch/arm64/include

[PATCH v16 00/16] arm64: untag user pointers passed to the kernel

2019-06-03 Thread Andrey Konovalov
ed untagging pointers returned from __uaccess_mask_ptr. Changes in v1: - Rebased onto 4.17-rc1. Changes in RFC v2: - Added "#ifndef untagged_addr..." fallback in linux/uaccess.h instead of defining it for each arch individually. - Updated Documentation/arm64/tagged-pointers.txt. - Drop

[PATCH v16 01/16] uaccess: add untagged_addr definition for other arches

2019-06-03 Thread Andrey Konovalov
arm64. Acked-by: Catalin Marinas Reviewed-by: Khalid Aziz Signed-off-by: Andrey Konovalov --- include/linux/mm.h | 4 1 file changed, 4 insertions(+) diff --git a/include/linux/mm.h b/include/linux/mm.h index 0e8834ac32b7..949d43e9c0b6 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h

Re: [PATCH v15 00/17] arm64: untag user pointers passed to the kernel

2019-05-31 Thread Andrey Konovalov
On Fri, May 31, 2019 at 6:20 PM Catalin Marinas wrote: > > On Fri, May 31, 2019 at 04:29:10PM +0200, Andrey Konovalov wrote: > > On Thu, May 30, 2019 at 7:15 PM Catalin Marinas > > wrote: > > > On Tue, May 28, 2019 at 04:14:45PM +0200, Andrey Konovalov wrot

Re: [PATCH v15 00/17] arm64: untag user pointers passed to the kernel

2019-05-31 Thread Andrey Konovalov
On Thu, May 30, 2019 at 7:15 PM Catalin Marinas wrote: > > On Tue, May 28, 2019 at 04:14:45PM +0200, Andrey Konovalov wrote: > > Thanks for a lot of valuable input! I've read through all the replies > > and got somewhat lost. What are the changes I need to do to this > > s

  1   2   >