Re: [RFC 2/4] lib/strncpy_from_user: Remove redundant user space pointer range check

2020-01-15 Thread Andrey Konovalov
On Tue, Jan 14, 2020 at 9:08 PM Vineet Gupta wrote: > > This came up when switching ARC to word-at-a-time interface and using > generic/optimized strncpy_from_user > > It seems the existing code checks for user buffer/string range multiple > times and one of tem cn be avoided. > > There's an open-

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 >>

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

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

2018-03-09 Thread Andrey Konovalov
m.org/docs/HardwareAssistedAddressSanitizerDesign.html Andrey Konovalov (6): arm64: add type casts to untagged_addr macro arm64: untag user addresses in copy_from_user and others mm, arm64: untag user addresses in memory syscalls mm, arm64: untag user addresses in mm/gup.c lib, arm64: untag addrs passed to strncpy_fro

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

2018-03-09 Thread Andrey Konovalov
architectures besides arm64. Signed-off-by: Andrey Konovalov --- arch/alpha/include/asm/uaccess.h | 2 ++ arch/arc/include/asm/uaccess.h| 1 + arch/arm/include/asm/uaccess.h| 2 ++ arch/blackfin/include/asm/uaccess.h | 2 ++ arch/c6x/include/asm/uaccess.h| 2

[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 3/6] mm, arm64: untag user addresses in memory syscalls

2018-03-09 Thread Andrey Konovalov
unmap, remap_file_pages, mprotect, pkey_mprotect, mremap and msync. Signed-off-by: Andrey Konovalov --- mm/madvise.c | 2 ++ mm/mempolicy.c | 6 ++ mm/mincore.c | 2 ++ mm/mlock.c | 5 + mm/mmap.c | 9 + mm/mprotect.c | 2 ++ mm/mremap.c| 2 ++ mm/msync.c | 3 +++ 8 files ch

[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

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

2018-03-09 Thread Andrey Konovalov
in access_ok and in __uaccess_mask_ptr. Signed-off-by: Andrey Konovalov --- arch/arm64/include/asm/uaccess.h | 6 +- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/arch/arm64/include/asm/uaccess.h b/arch/arm64/include/asm/uaccess.h index 2d6451cbaa86..24a221678fe3 100644 --- a

[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