[RFC PATCH 4/6] mm, arm64: untag user addresses in mm/gup.c

2018-03-09 Thread Andrey Konovalov
mm/gup.c provides a kernel interface that accepts user addresses and manipulates user pages directly (for example get_user_pages, that is used by the futex syscall). Here we also need to handle the case of tagged user pointers. Untag addresses passed to this interface. Signed-off-by: Andrey Konov

[RFC PATCH 1/6] arm64: add type casts to untagged_addr macro

2018-03-09 Thread Andrey Konovalov
This patch makes the untagged_addr macro accept all kinds of address types (void *, unsigned long, etc.) and allows not to specify type casts in each place where it is used. This is done by using __typeof__. Signed-off-by: Andrey Konovalov --- arch/arm64/include/asm/uaccess.h | 3 ++- 1 file cha

[RFC PATCH 2/6] arm64: untag user addresses in copy_from_user and others

2018-03-09 Thread Andrey Konovalov
copy_from_user (and a few other similar functions) are used to copy data from user memory into the kernel memory or vice versa. Since a user can provided a tagged pointer to one of the syscalls that use copy_from_user, we need to correctly handle such pointers. Do this by untagging user pointers i

[RFC PATCH 3/6] mm, arm64: untag user addresses in memory syscalls

2018-03-09 Thread Andrey Konovalov
Memory subsystem syscalls accept user addresses as arguments, but don't use copy_from_user and other similar functions, so we need to handle this case separately. Untag user pointers passed to madvise, mbind, get_mempolicy, mincore, mlock, mlock2, brk, mmap_pgoff, old_mmap, munmap, remap_file_page

[RFC PATCH 5/6] lib, arm64: untag addrs passed to strncpy_from_user and strnlen_user

2018-03-09 Thread Andrey Konovalov
strncpy_from_user and strnlen_user accept user addresses as arguments, and do not go through the same path as copy_from_user and others, so here we need to separately handle the case of tagged user addresses as well. Untag user pointers passed to these functions. Signed-off-by: Andrey Konovalov

[RFC PATCH 6/6] arch: add untagged_addr definition for other arches

2018-03-09 Thread Andrey Konovalov
To allow arm64 syscalls accept tagged pointers from userspace, we must untag them when they are passed to the kernel. Since untagging is done in generic parts of the kernel (like the mm subsystem), the untagged_addr macro should be defined for all architectures. Define it as a noop for all other a

[RFC PATCH 0/6] arm64: untag user pointers passed to the kernel

2018-03-09 Thread Andrey Konovalov
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 this feature and pass tagged user pointers to the kernel through syscalls or other interfaces. This patch mak

Re: [RFC PATCH 6/6] arch: add untagged_addr definition for other arches

2018-03-09 Thread Arnd Bergmann
On Fri, Mar 9, 2018 at 3:02 PM, Andrey Konovalov wrote: > To allow arm64 syscalls accept tagged pointers from userspace, we must > untag them when they are passed to the kernel. Since untagging is done in > generic parts of the kernel (like the mm subsystem), the untagged_addr > macro should be de

Re: [RFC PATCH 0/6] arm64: untag user pointers passed to the kernel

2018-03-09 Thread Robin Murphy
Hi Andrey, On 09/03/18 14:01, Andrey Konovalov wrote: 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 this feature and pass tagged user pointers to the ker

Re: [RFC PATCH 6/6] arch: add untagged_addr definition for other arches

2018-03-09 Thread Robin Murphy
On 09/03/18 14:02, Andrey Konovalov wrote: To allow arm64 syscalls accept tagged pointers from userspace, we must untag them when they are passed to the kernel. Since untagging is done in generic parts of the kernel (like the mm subsystem), the untagged_addr macro should be defined for all archit

Re: [RFC PATCH 6/6] arch: add untagged_addr definition for other arches

2018-03-09 Thread Andrey Konovalov
On Fri, Mar 9, 2018 at 3:16 PM, Robin Murphy wrote: > On 09/03/18 14:02, Andrey Konovalov wrote: >> >> To allow arm64 syscalls accept tagged pointers from userspace, we must >> untag them when they are passed to the kernel. Since untagging is done in >> generic parts of the kernel (like the mm sub

Re: [RFC PATCH 0/6] arm64: untag user pointers passed to the kernel

2018-03-09 Thread Andrey Konovalov
On Fri, Mar 9, 2018 at 3:15 PM, Robin Murphy wrote: > Hi Andrey, > > On 09/03/18 14:01, Andrey Konovalov wrote: >> >> 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