kisskb: OK linus/axs101_defconfig/arcompact Thu Jan 16, 15:33

2020-01-15 Thread noreply
OK linus/axs101_defconfig/arcompact Thu Jan 16, 15:33

http://kisskb.ellerman.id.au/kisskb/buildresult/14097372/

Commit:   Merge tag 'platform-drivers-x86-v5.5-3' of 
git://git.infradead.org/linux-platform-drivers-x86
  51d69817519f5f00041a1a039277f0367d76c82c
Compiler: arc-buildroot-linux-uclibc-gcc (Buildroot 2015.08.1) 4.8.4 / GNU ld 
(GNU Binutils) 2.23.2

No errors found in log

Possible warnings (2)
--

:1511:2: warning: #warning syscall clone3 not implemented [-Wcpp]
net/ipv4/tcp_input.c:4389:49: warning: array subscript is above array bounds 
[-Warray-bounds]


___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


kisskb: OK linus/axs103_smp_defconfig/arcv2 Thu Jan 16, 15:33

2020-01-15 Thread noreply
OK linus/axs103_smp_defconfig/arcv2 Thu Jan 16, 15:33

http://kisskb.ellerman.id.au/kisskb/buildresult/14097371/

Commit:   Merge tag 'platform-drivers-x86-v5.5-3' of 
git://git.infradead.org/linux-platform-drivers-x86
  51d69817519f5f00041a1a039277f0367d76c82c
Compiler: arc-linux-gcc.br_real (Buildroot 2016.11-git-00613-ge98b4dd) 6.2.1 
20160824 / GNU ld (GNU Binutils) 2.27.51.20160928

Possible errors
---

 #define KERN_ERR KERN_SOH "3" /* error conditions */
 #define KERN_ERR KERN_SOH "3" /* error conditions */
 #define KERN_ERR KERN_SOH "3" /* error conditions */
 #define KERN_ERR KERN_SOH "3" /* error conditions */

Possible warnings (89)
--

:1511:2: warning: #warning syscall clone3 not implemented [-Wcpp]
kernel/dma/direct.c:32:4: warning: format '%zu' expects argument of type 
'size_t', but argument 4 has type 'unsigned int' [-Wformat=]
init/main.c:381:35: warning: format '%zu' expects argument of type 'size_t', 
but argument 3 has type 'unsigned int' [-Wformat=]
init/main.c:385:35: warning: format '%zu' expects argument of type 'size_t', 
but argument 3 has type 'unsigned int' [-Wformat=]
init/main.c:389:35: warning: format '%zu' expects argument of type 'size_t', 
but argument 3 has type 'unsigned int' [-Wformat=]
init/main.c:825:37: warning: format '%zu' expects argument of type 'size_t', 
but argument 3 has type '__kernel_size_t {aka unsigned int}' [-Wformat=]
include/linux/kern_levels.h:5:18: warning: format '%zu' expects argument of 
type 'size_t', but argument 2 has type 'unsigned int' [-Wformat=]
include/linux/kern_levels.h:5:18: warning: format '%zu' expects argument of 
type 'size_t', but argument 2 has type 'unsigned int' [-Wformat=]
include/linux/kernel.h:835:29: warning: comparison of distinct pointer types 
lacks a cast
include/linux/kernel.h:835:29: warning: comparison of distinct pointer types 
lacks a cast
include/linux/kernel.h:835:29: warning: comparison of distinct pointer types 
lacks a cast
include/linux/kernel.h:835:29: warning: comparison of distinct pointer types 
lacks a cast
include/linux/kernel.h:835:29: warning: comparison of distinct pointer types 
lacks a cast
include/linux/kernel.h:835:29: warning: comparison of distinct pointer types 
lacks a cast
include/linux/kernel.h:835:29: warning: comparison of distinct pointer types 
lacks a cast
fs/ext4/xattr.c:482:8: warning: format '%zu' expects argument of type 'size_t', 
but argument 6 has type 'unsigned int' [-Wformat=]
include/linux/kernel.h:835:29: warning: comparison of distinct pointer types 
lacks a cast
drivers/base/regmap/regmap.c:1526:22: warning: format '%zu' expects argument of 
type 'size_t', but argument 5 has type 'unsigned int' [-Wformat=]
drivers/base/component.c:196:24: warning: format '%zu' expects argument of type 
'size_t', but argument 4 has type 'unsigned int' [-Wformat=]
include/linux/kern_levels.h:5:18: warning: format '%zd' expects argument of 
type 'signed size_t', but argument 3 has type 'size_t {aka unsigned int}' 
[-Wformat=]
include/linux/kernel.h:835:29: warning: comparison of distinct pointer types 
lacks a cast
drivers/base/regmap/regcache.c:715:20: warning: format '%zu' expects argument 
of type 'size_t', but argument 4 has type 'unsigned int' [-Wformat=]
include/linux/kernel.h:835:29: warning: comparison of distinct pointer types 
lacks a cast
drivers/dma-buf/dma-buf.c:402:26: warning: format '%zu' expects argument of 
type 'size_t', but argument 3 has type 'unsigned int' [-Wformat=]
fs/buffer.c:237:10: warning: format '%zu' expects argument of type 'size_t', 
but argument 5 has type 'unsigned int' [-Wformat=]
include/linux/kern_levels.h:5:18: warning: format '%zd' expects argument of 
type 'signed size_t', but argument 3 has type 'size_t {aka const unsigned int}' 
[-Wformat=]
include/linux/kernel.h:835:29: warning: comparison of distinct pointer types 
lacks a cast
include/linux/kernel.h:835:29: warning: comparison of distinct pointer types 
lacks a cast
include/linux/kernel.h:835:29: warning: comparison of distinct pointer types 
lacks a cast
include/linux/kernel.h:835:29: warning: comparison of distinct pointer types 
lacks a cast
include/linux/kernel.h:835:29: warning: comparison of distinct pointer types 
lacks a cast
include/linux/kernel.h:835:29: warning: comparison of distinct pointer types 
lacks a cast
include/linux/kernel.h:835:29: warning: comparison of distinct pointer types 
lacks a cast
include/linux/kernel.h:835:29: warning: comparison of distinct pointer types 
lacks a cast
include/linux/kernel.h:835:29: warning: comparison of distinct pointer types 
lacks a cast
include/linux/kernel.h:835:29: warning: comparison of distinct pointer types 
lacks a cast
include/linux/kernel.h:835:29: warning: comparison of distinct pointer types 
lacks a cast
include/linux/overflow.h:59:15: warning: comparison of distinct pointer types 
lacks a cast
include/linux/overflow.h:60:15: warning: comparison of distinct pointer types 
lacks a cast

[PATCH v2 2/2] ARC: uaccess: use optimized generic __strnlen_user/__strncpy_from_user

2020-01-15 Thread Vineet Gupta
The existing ARC variants have 2 issues
 - Use ZOL which may not be present in forthcoming architecture
 - Byte loop based vs. generic version which is word loop based

Signed-off-by: Vineet Gupta 
---
 arch/arc/Kconfig   |  2 +
 arch/arc/include/asm/uaccess.h | 85 ++
 arch/arc/mm/extable.c  | 23 -
 3 files changed, 6 insertions(+), 104 deletions(-)

diff --git a/arch/arc/Kconfig b/arch/arc/Kconfig
index 26108ea785c2..3b074c4d31fb 100644
--- a/arch/arc/Kconfig
+++ b/arch/arc/Kconfig
@@ -26,6 +26,8 @@ config ARC
select GENERIC_PENDING_IRQ if SMP
select GENERIC_SCHED_CLOCK
select GENERIC_SMP_IDLE_THREAD
+   select GENERIC_STRNCPY_FROM_USER if MMU
+   select GENERIC_STRNLEN_USER if MMU
select HAVE_ARCH_KGDB
select HAVE_ARCH_TRACEHOOK
select HAVE_DEBUG_STACKOVERFLOW
diff --git a/arch/arc/include/asm/uaccess.h b/arch/arc/include/asm/uaccess.h
index ea40ec7f6cae..a3c943993b7b 100644
--- a/arch/arc/include/asm/uaccess.h
+++ b/arch/arc/include/asm/uaccess.h
@@ -52,6 +52,8 @@
 #define __access_ok(addr, sz)  (unlikely(__kernel_ok) || \
 likely(__user_ok((addr), (sz
 
+#define user_addr_max()(uaccess_kernel() ? ~0UL : get_fs())
+
 /*** Single byte/hword/word copies **/
 
 #define __get_user_fn(sz, u, k)\
@@ -613,7 +615,7 @@ raw_copy_to_user(void __user *to, const void *from, 
unsigned long n)
return res;
 }
 
-static inline unsigned long __arc_clear_user(void __user *to, unsigned long n)
+static inline unsigned long __clear_user(void __user *to, unsigned long n)
 {
long res = n;
unsigned char *d_char = to;
@@ -655,89 +657,10 @@ static inline unsigned long __arc_clear_user(void __user 
*to, unsigned long n)
return res;
 }
 
-static inline long
-__arc_strncpy_from_user(char *dst, const char __user *src, long count)
-{
-   long res = 0;
-   char val;
-
-   if (count == 0)
-   return 0;
-
-   __asm__ __volatile__(
-   "   mov lp_count, %5\n"
-   "   lp  3f  \n"
-   "1: ldb.ab  %3, [%2, 1] \n"
-   "   breq.d  %3, 0, 3f   \n"
-   "   stb.ab  %3, [%1, 1] \n"
-   "   add %0, %0, 1   # Num of NON NULL bytes copied  \n"
-   "3: \n"
-   "   .section .fixup, \"ax\" \n"
-   "   .align 4\n"
-   "4: mov %0, %4  # sets @res as -EFAULT  \n"
-   "   j   3b  \n"
-   "   .previous   \n"
-   "   .section __ex_table, \"a\"  \n"
-   "   .align 4\n"
-   "   .word   1b, 4b  \n"
-   "   .previous   \n"
-   : "+r"(res), "+r"(dst), "+r"(src), "=r"(val)
-   : "g"(-EFAULT), "r"(count)
-   : "lp_count", "memory");
-
-   return res;
-}
-
-static inline long __arc_strnlen_user(const char __user *s, long n)
-{
-   long res, tmp1, cnt;
-   char val;
-
-   __asm__ __volatile__(
-   "   mov %2, %1  \n"
-   "1: ldb.ab  %3, [%0, 1] \n"
-   "   breq.d  %3, 0, 2f   \n"
-   "   sub.f   %2, %2, 1   \n"
-   "   bnz 1b  \n"
-   "   sub %2, %2, 1   \n"
-   "2: sub %0, %1, %2  \n"
-   "3: ;nop\n"
-   "   .section .fixup, \"ax\" \n"
-   "   .align 4\n"
-   "4: mov %0, 0   \n"
-   "   j   3b  \n"
-   "   .previous   \n"
-   "   .section __ex_table, \"a\"  \n"
-   "   .align 4\n"
-   "   .word 1b, 4b\n"
-   "   .previous   \n"
-   : "=r"(res), "=r"(tmp1), "=r"(cnt), "=r"(val)
-   : "0"(s), "1"(n)
-   : "memory");
-
-   return res;
-}
-
-#ifndef CONFIG_CC_OPTIMIZE_FOR_SIZE
-
 #define INLINE_COPY_TO_USER
 #define INLINE_COPY_FROM_USER
 
-#define __clear_user(d, n) __arc_clear_user(d, n)
-#define __strncpy_from_user(d, s, n)   __arc_strncpy_from_user(d, s, n)
-#define __strnlen_user(s, n)   __arc_strnlen_user(s, n)
-#else
-extern unsigned long arc_clear_user_noinline(void __user *to,
-   unsigned long n);
-extern long arc_strncpy_from_user_noinline (char *dst, const char __user *src,
-   long count);
-extern long arc_strnlen_user_noinline(const char __user *src, long n);
-
-#define __clear_user(d, n) arc_clear_user_noinline(d, n)
-#define 

[PATCH v2 0/2] Switching ARC to optimized generic strncpy_from_user

2020-01-15 Thread Vineet Gupta
Hi,

This series switches ARC to generic word-at-a-time interface.

I understand that going fwd, we may drop the inline versions altogether but this
helps ARC code in the interim.

v2 <- v1
 - Moved __strnlen_user/__strncpy_from_user to under ifdef gaurd [Arnd]
 - Dropped the broken optimization patch [Linus]
 - Folded 2 ARC patches into 1

Thx,
-Vineet

Vineet Gupta (2):
  asm-generic/uaccess: don't define inline functions if noinline lib/*
in use
  ARC: uaccess: use optimized generic __strnlen_user/__strncpy_from_user

 arch/arc/Kconfig   |  2 +
 arch/arc/include/asm/uaccess.h | 85 ++
 arch/arc/mm/extable.c  | 23 -
 include/asm-generic/uaccess.h  |  8 
 4 files changed, 14 insertions(+), 104 deletions(-)

-- 
2.20.1


___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


[PATCH] ARC: wireup clone3 syscall

2020-01-15 Thread Vineet Gupta
Signed-off-by: Vineet Gupta 
---
 arch/arc/Kconfig   |  1 +
 arch/arc/include/asm/syscalls.h|  1 +
 arch/arc/include/uapi/asm/unistd.h |  1 +
 arch/arc/kernel/entry.S| 12 
 arch/arc/kernel/process.c  |  7 +++
 arch/arc/kernel/sys.c  |  1 +
 6 files changed, 19 insertions(+), 4 deletions(-)

diff --git a/arch/arc/Kconfig b/arch/arc/Kconfig
index 26108ea785c2..c4409eab07a9 100644
--- a/arch/arc/Kconfig
+++ b/arch/arc/Kconfig
@@ -28,6 +28,7 @@ config ARC
select GENERIC_SMP_IDLE_THREAD
select HAVE_ARCH_KGDB
select HAVE_ARCH_TRACEHOOK
+   select HAVE_COPY_THREAD_TLS
select HAVE_DEBUG_STACKOVERFLOW
select HAVE_DEBUG_KMEMLEAK
select HAVE_FUTEX_CMPXCHG if FUTEX
diff --git a/arch/arc/include/asm/syscalls.h b/arch/arc/include/asm/syscalls.h
index 7ddba13e9b59..c3f4714a4f5c 100644
--- a/arch/arc/include/asm/syscalls.h
+++ b/arch/arc/include/asm/syscalls.h
@@ -11,6 +11,7 @@
 #include 
 
 int sys_clone_wrapper(int, int, int, int, int);
+int sys_clone3_wrapper(void *, size_t);
 int sys_cacheflush(uint32_t, uint32_t uint32_t);
 int sys_arc_settls(void *);
 int sys_arc_gettls(void);
diff --git a/arch/arc/include/uapi/asm/unistd.h 
b/arch/arc/include/uapi/asm/unistd.h
index 5eafa1115162..fa2713ae6bea 100644
--- a/arch/arc/include/uapi/asm/unistd.h
+++ b/arch/arc/include/uapi/asm/unistd.h
@@ -21,6 +21,7 @@
 #define __ARCH_WANT_SET_GET_RLIMIT
 #define __ARCH_WANT_SYS_EXECVE
 #define __ARCH_WANT_SYS_CLONE
+#define __ARCH_WANT_SYS_CLONE3
 #define __ARCH_WANT_SYS_VFORK
 #define __ARCH_WANT_SYS_FORK
 #define __ARCH_WANT_TIME32_SYSCALLS
diff --git a/arch/arc/kernel/entry.S b/arch/arc/kernel/entry.S
index 72be01270e24..7e5109dab4e8 100644
--- a/arch/arc/kernel/entry.S
+++ b/arch/arc/kernel/entry.S
@@ -35,6 +35,18 @@ ENTRY(sys_clone_wrapper)
b .Lret_from_system_call
 END(sys_clone_wrapper)
 
+ENTRY(sys_clone3_wrapper)
+   SAVE_CALLEE_SAVED_USER
+   bl  @sys_clone3
+   DISCARD_CALLEE_SAVED_USER
+
+   GET_CURR_THR_INFO_FLAGS   r10
+   btst r10, TIF_SYSCALL_TRACE
+   bnz  tracesys_exit
+
+   b .Lret_from_system_call
+END(sys_clone3_wrapper)
+
 ENTRY(ret_from_fork)
; when the forked child comes here from the __switch_to function
; r0 has the last task pointer.
diff --git a/arch/arc/kernel/process.c b/arch/arc/kernel/process.c
index e1889ce3faf9..bfd4cbe74aa3 100644
--- a/arch/arc/kernel/process.c
+++ b/arch/arc/kernel/process.c
@@ -171,9 +171,8 @@ asmlinkage void ret_from_fork(void);
  * |user_r25|
  * --  <= END of PAGE
  */
-int copy_thread(unsigned long clone_flags,
-   unsigned long usp, unsigned long kthread_arg,
-   struct task_struct *p)
+int copy_thread_tls(unsigned long clone_flags, unsigned long usp,
+   unsigned long kthread_arg, struct task_struct *p, unsigned long tls)
 {
struct pt_regs *c_regs;/* child's pt_regs */
unsigned long *childksp;   /* to unwind out of __switch_to() */
@@ -231,7 +230,7 @@ int copy_thread(unsigned long clone_flags,
 * set task's userland tls data ptr from 4th arg
 * clone C-lib call is difft from clone sys-call
 */
-   task_thread_info(p)->thr_ptr = regs->r3;
+   task_thread_info(p)->thr_ptr = tls;
} else {
/* Normal fork case: set parent's TLS ptr in child */
task_thread_info(p)->thr_ptr =
diff --git a/arch/arc/kernel/sys.c b/arch/arc/kernel/sys.c
index fddecc76efb7..1069446bdc58 100644
--- a/arch/arc/kernel/sys.c
+++ b/arch/arc/kernel/sys.c
@@ -7,6 +7,7 @@
 #include 
 
 #define sys_clone  sys_clone_wrapper
+#define sys_clone3 sys_clone3_wrapper
 
 #undef __SYSCALL
 #define __SYSCALL(nr, call) [nr] = (call),
-- 
2.20.1


___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


Re: [RFC 1/4] asm-generic/uaccess: don't define inline functions if noinline lib/* in use

2020-01-15 Thread Vineet Gupta
On 1/14/20 12:57 PM, Arnd Bergmann wrote:
> On Tue, Jan 14, 2020 at 9:08 PM Vineet Gupta  
> wrote:
>> There are 2 generic varaints of strncpy_from_user() / strnlen_user()
>>  (1). inline version in asm-generic/uaccess.h
>>  (2). optimized word-at-a-time version in lib/*
>>
>> This patch disables #1 if #2 selected. This allows arches to continue
>> reusing asm-generic/uaccess.h for rest of code
>>
>> This came up when switching ARC to generic word-at-a-time interface
>>
>> Signed-off-by: Vineet Gupta 
> This looks like a useful change, but I think we can do even better: It
> seems that
> there are no  callers of __strnlen_user or __strncpy_from_user  in the
> kernel today, so these should not be defined either when the Kconfig symbols
> are set. Also, I would suggest moving the 'extern' declaration for the two
> functions into the #else branch of the conditional so it does not need to be
> duplicated.

Given where things seem to be heading, do u still want an updated patch for this
or do u plan to ditch the inline version in short term anyways.

-Vineet

___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


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

2020-01-15 Thread Vineet Gupta
On 1/15/20 6:42 AM, Andrey Konovalov wrote:
>> -   max_addr = user_addr_max();
>> -   src_addr = (unsigned long)untagged_addr(src);
>
> If you end up changing this code, you need to keep the untagged_addr()
> logic, otherwise this breaks arm64 tagged address ABI [1].

It is moot point now, but fwiw untagged_addr() would not have been needed 
anymore
as it was only needed to compute the pointer difference which my patch got rid 
of.

> 
> [1] https://www.kernel.org/doc/html/latest/arm64/tagged-address-abi.html
> 
>> -   if (likely(src_addr < max_addr)) {
>> -   unsigned long max = max_addr - src_addr;
>> +   kasan_check_write(dst, count);
>> +   check_object_size(dst, count, false);
>> +   if (user_access_begin(src, count)) {

___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


clone3 on ARC (was Re: [PATCH v3 2/2] arch: wire-up clone3() syscall)

2020-01-15 Thread Vineet Gupta
On 6/4/19 2:29 PM, Christian Brauner wrote:
> On Tue, Jun 04, 2019 at 08:40:01PM +0200, Arnd Bergmann wrote:
>> On Tue, Jun 4, 2019 at 6:09 PM Christian Brauner  
>> wrote:
>>>
>>> Wire up the clone3() call on all arches that don't require hand-rolled
>>> assembly.
>>>
>>> Some of the arches look like they need special assembly massaging and it is
>>> probably smarter if the appropriate arch maintainers would do the actual
>>> wiring. Arches that are wired-up are:
>>> - x86{_32,64}
>>> - arm{64}
>>> - xtensa
>>
>> The ones you did look good to me. I would hope that we can do all other
>> architectures the same way, even if they have special assembly wrappers
>> for the old clone(). The most interesting cases appear to be ia64, alpha,
>> m68k and sparc, so it would be good if their maintainers could take a
>> look.
> 
> Yes, agreed. They can sort this out even after this lands.
> 
>>
>> What do you use for testing? Would it be possible to override the
>> internal clone() function in glibc with an LD_PRELOAD library
>> to quickly test one of the other architectures for regressions?
> 
> I have a test program that is rather horrendously ugly and I compiled
> kernels for x86 and the arms and tested in qemu. The program basically
> looks like [1].

I just got around to fixing this for ARC (patch to follow after we sort out the
testing) and was trying to use the test case below for a qucik and dirty smoke
test (so existing toolchain lacking with headers lacking NR_clone3 or struct
clone_args etc). I did hack those up, but then spotted below

uapi/linux/sched.h

|struct clone_args {
|   __aligned_u64 flags;
|   __aligned_u64 pidfd;
|   __aligned_u64 child_tid;
|   __aligned_u64 parent_tid;
..
..

Are all clone3 arg fields supposed to be 64-bit wide, even things like 
@child_tid,
@tls  which are traditionally ARCH word wide ?


> 
> Christian
> 
> [1]:
> #define _GNU_SOURCE
> #include 
> #include 
> #include 
> #include 
> #include 
> #include 
> #include 
> #include 
> #include 
> #include 
> #include 
> #include 
> #include 
> #include 
> #include 
> #include 
> #include 
> #include 
> #include 
> 
> static pid_t raw_clone(struct clone_args *args)
> {
>   return syscall(__NR_clone3, args, sizeof(struct clone_args));
> }
> 
> static pid_t raw_clone_legacy(int *pidfd, unsigned int flags)
> {
>   return syscall(__NR_clone, flags, 0, pidfd, 0, 0);
> }
> 
> static int wait_for_pid(pid_t pid)
> {
>   int status, ret;
> 
> again:
>   ret = waitpid(pid, , 0);
>   if (ret == -1) {
>   if (errno == EINTR)
>   goto again;
> 
>   return -1;
>   }
> 
>   if (ret != pid)
>   goto again;
> 
>   if (!WIFEXITED(status) || WEXITSTATUS(status) != 0)
>   return -1;
> 
>   return 0;
> }
> 
> #define ptr_to_u64(ptr) ((__u64)((uintptr_t)(ptr)))
> #define u64_to_ptr(n) ((uintptr_t)((__u64)(n)))
> 
> int main(int argc, char *argv[])
> {
>   int pidfd = -1;
>   pid_t parent_tid = -1, pid = -1;
>   struct clone_args args = {0};
>   args.parent_tid = ptr_to_u64(_tid);
>   args.pidfd = ptr_to_u64();
>   args.flags = CLONE_PIDFD | CLONE_PARENT_SETTID;
>   args.exit_signal = SIGCHLD;
> 
>   pid = raw_clone();
>   if (pid < 0) {
>   fprintf(stderr, "%s - Failed to create new process\n",
>   strerror(errno));
>   exit(EXIT_FAILURE);
>   }
> 
>   if (pid == 0) {
>   printf("I am the child with pid %d\n", getpid());
>   exit(EXIT_SUCCESS);
>   }
> 
>   printf("raw_clone: I am the parent. My child's pid is   %d\n", pid);
>   printf("raw_clone: I am the parent. My child's pidfd is %d\n",
>  *(int *)args.pidfd);
>   printf("raw_clone: I am the parent. My child's paren_tid value is %d\n",
>  *(pid_t *)args.parent_tid);
> 
>   if (wait_for_pid(pid))
>   exit(EXIT_FAILURE);
> 
>   if (pid != *(pid_t *)args.parent_tid)
>   exit(EXIT_FAILURE);
> 
>   close(pidfd);
> 
>   printf("\n\n");
>   pidfd = -1;
>   pid = raw_clone_legacy(, CLONE_PIDFD | SIGCHLD);
>   if (pid < 0) {
>   fprintf(stderr, "%s - Failed to create new process\n",
>   strerror(errno));
>   exit(EXIT_FAILURE);
>   }
> 
>   if (pid == 0) {
>   printf("I am the child with pid %d\n", getpid());
>   exit(EXIT_SUCCESS);
>   }
> 
>   printf("raw_clone_legacy: I am the parent. My child's pid is   %d\n",
>  pid);
>   printf("raw_clone_legacy: I am the parent. My child's pidfd is %d\n",
>  pidfd);
> 
>   if (wait_for_pid(pid))
>   exit(EXIT_FAILURE);
> 
>   if (pid != *(pid_t *)args.parent_tid)
>   exit(EXIT_FAILURE);
> 
>   return 0;
> }
> 

___
linux-snps-arc mailing list

Re: [PATCH net 0/4] net: stmmac: Fix selftests in Synopsys AXS101 board

2020-01-15 Thread David Miller
From: Jose Abreu 
Date: Tue, 14 Jan 2020 17:09:20 +0100

> Set of fixes for sefltests so that they work in Synopsys AXS101 board.
 ...

Applied patches 1-3, it looks like patch 4 went into another tree.

___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


strace breaks with to be released glibc 2.31

2020-01-15 Thread Vineet Gupta
Hi,

I've been testing an in-works glibc port for ARC and with 2.31 there's a glibc
change which seems to break strace.

Commit d1e411e5c786ce3 "Add PTRACE_GET_SYSCALL_INFO from Linux 5.3 to 
sys/ptrace.h."

This now defines PTRACE_GET_SYSCALL_INFO but defines struct 
__ptrace_syscall_info
(not the non underscored ver) causing strace to trip.

I'm not sure how to fix strace: do we need to switch over to glibc provided
__ptrace_syscall_info (with some #ifdef GLIBC and MINOR etc) or is there a 
better
way to do this ?

Thx,
-Vineet
___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


Re: [RFC 1/4] asm-generic/uaccess: don't define inline functions if noinline lib/* in use

2020-01-15 Thread Arnd Bergmann
On Wed, Jan 15, 2020 at 3:12 PM Al Viro  wrote:
>
> On Wed, Jan 15, 2020 at 10:08:31AM +0100, Arnd Bergmann wrote:
>
> > > I would suggest that anybody who uses asm-generic/uaccess.h needs to
> > > simply use the generic library version.
> >
> > Or possibly just everybody altogether: the remaining architectures that
> > have a custom implementation don't seem to be doing any better either.
>
> No go for s390.  There you really want to access userland memory in
> larger chunks - it's oriented for block transfers.  IIRC, the insn
> they are using has a costly setup phase, independent of the amount
> to copy, followed by reasonably fast transfer more or less linear
> by the size.

Right, I missed that one while looking through the remaining
implementations.

 Arnd

___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


Re: [RFC 1/4] asm-generic/uaccess: don't define inline functions if noinline lib/* in use

2020-01-15 Thread Al Viro
On Wed, Jan 15, 2020 at 10:08:31AM +0100, Arnd Bergmann wrote:

> > I would suggest that anybody who uses asm-generic/uaccess.h needs to
> > simply use the generic library version.
> 
> Or possibly just everybody altogether: the remaining architectures that
> have a custom implementation don't seem to be doing any better either.

No go for s390.  There you really want to access userland memory in
larger chunks - it's oriented for block transfers.  IIRC, the insn
they are using has a costly setup phase, independent of the amount
to copy, followed by reasonably fast transfer more or less linear
by the size.

___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


Re: [RFC 1/4] asm-generic/uaccess: don't define inline functions if noinline lib/* in use

2020-01-15 Thread Arnd Bergmann
On Tue, Jan 14, 2020 at 10:33 PM Linus Torvalds
 wrote:
>
> On Tue, Jan 14, 2020 at 12:09 PM Vineet Gupta
>  wrote:
> >
> > There are 2 generic varaints of strncpy_from_user() / strnlen_user()
> >  (1). inline version in asm-generic/uaccess.h
>
> I think we should get rid of this entirely. It's just a buggy garbage
> implementation that nobody should ever actually use.
>
> It does just about everything wrong that you *can* do, wrong,
> including doing the NUL-filling termination of standard strncpy() that
> "strncpy_from_user()" doesn't actually do.
>
> So:
>
>  - the asm-generic/uaccess.h __strncpy_from_user() function is just
> horribly wrong

I checked who is actually using it, and the only ones I found
are c6x and rv32-nommu. It shouldn't be hard to move them over
to the generic version.

>  - the generic/uaccess.h version of strncpy_from_user() shouldn't be
> an inline function either, since the only thing it can do inline is
> the bogus one-byte access check that _barely_ makes security work (you
> also need to have a guard page to _actually_ make it work, and I'm not
> atr all convinced that people do).

That would be arc, hexagon, unicore32, and um. Hexagon already has
the same bug in strncpy_from_user and should be converted to the
generic version as you say. For unicore32 the existing asm imlpementation
may be fine, but it's clearly easier to use the generic code than moving
the range check in there.

I don't know what the arch/um implementation needs, but since it's in C,
moving the access_ok() in there is easy enough.

> I would suggest that anybody who uses asm-generic/uaccess.h needs to
> simply use the generic library version.

Or possibly just everybody altogether: the remaining architectures that
have a custom implementation don't seem to be doing any better either.

 Arnd

___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc