* [PATCH 1/7] arm64: Move __ARCH_WANT_SYS_CLONE3 definition to uapi headers [not found] <20200102172413.654385-1-amanieu@gmail.com> @ 2020-01-02 17:24 ` Amanieu d'Antras 2020-01-02 17:50 ` Christian Brauner 2020-01-02 17:24 ` [PATCH 2/7] arm64: Implement copy_thread_tls Amanieu d'Antras 2020-01-02 17:24 ` [PATCH 3/7] arm: " Amanieu d'Antras 2 siblings, 1 reply; 16+ messages in thread From: Amanieu d'Antras @ 2020-01-02 17:24 UTC (permalink / raw) To: linux-kernel Cc: linux-arm-kernel, Amanieu d'Antras, stable, Christian Brauner Previously this was only defined in the internal headers which resulted in __NR_clone3 not being defined in the user headers. Signed-off-by: Amanieu d'Antras <amanieu@gmail.com> Cc: linux-arm-kernel@lists.infradead.org Cc: <stable@vger.kernel.org> # 5.3.x --- arch/arm64/include/asm/unistd.h | 1 - arch/arm64/include/uapi/asm/unistd.h | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/arm64/include/asm/unistd.h b/arch/arm64/include/asm/unistd.h index 2629a68b8724..5af82587909e 100644 --- a/arch/arm64/include/asm/unistd.h +++ b/arch/arm64/include/asm/unistd.h @@ -42,7 +42,6 @@ #endif #define __ARCH_WANT_SYS_CLONE -#define __ARCH_WANT_SYS_CLONE3 #ifndef __COMPAT_SYSCALL_NR #include <uapi/asm/unistd.h> diff --git a/arch/arm64/include/uapi/asm/unistd.h b/arch/arm64/include/uapi/asm/unistd.h index 4703d218663a..f83a70e07df8 100644 --- a/arch/arm64/include/uapi/asm/unistd.h +++ b/arch/arm64/include/uapi/asm/unistd.h @@ -19,5 +19,6 @@ #define __ARCH_WANT_NEW_STAT #define __ARCH_WANT_SET_GET_RLIMIT #define __ARCH_WANT_TIME32_SYSCALLS +#define __ARCH_WANT_SYS_CLONE3 #include <asm-generic/unistd.h> -- 2.24.1 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel ^ permalink raw reply related [flat|nested] 16+ messages in thread
* Re: [PATCH 1/7] arm64: Move __ARCH_WANT_SYS_CLONE3 definition to uapi headers 2020-01-02 17:24 ` [PATCH 1/7] arm64: Move __ARCH_WANT_SYS_CLONE3 definition to uapi headers Amanieu d'Antras @ 2020-01-02 17:50 ` Christian Brauner 2020-01-02 19:25 ` Arnd Bergmann 0 siblings, 1 reply; 16+ messages in thread From: Christian Brauner @ 2020-01-02 17:50 UTC (permalink / raw) To: Amanieu d'Antras, arnd Cc: linux-arm-kernel, stable, linux-kernel, Christian Brauner [Cc Arnd. I'd like his Ack on this] On Thu, Jan 02, 2020 at 06:24:07PM +0100, Amanieu d'Antras wrote: > Previously this was only defined in the internal headers which > resulted in __NR_clone3 not being defined in the user headers. > > Signed-off-by: Amanieu d'Antras <amanieu@gmail.com> > Cc: linux-arm-kernel@lists.infradead.org > Cc: <stable@vger.kernel.org> # 5.3.x > --- > arch/arm64/include/asm/unistd.h | 1 - > arch/arm64/include/uapi/asm/unistd.h | 1 + > 2 files changed, 1 insertion(+), 1 deletion(-) > > diff --git a/arch/arm64/include/asm/unistd.h b/arch/arm64/include/asm/unistd.h > index 2629a68b8724..5af82587909e 100644 > --- a/arch/arm64/include/asm/unistd.h > +++ b/arch/arm64/include/asm/unistd.h > @@ -42,7 +42,6 @@ > #endif > > #define __ARCH_WANT_SYS_CLONE > -#define __ARCH_WANT_SYS_CLONE3 > > #ifndef __COMPAT_SYSCALL_NR > #include <uapi/asm/unistd.h> > diff --git a/arch/arm64/include/uapi/asm/unistd.h b/arch/arm64/include/uapi/asm/unistd.h > index 4703d218663a..f83a70e07df8 100644 > --- a/arch/arm64/include/uapi/asm/unistd.h > +++ b/arch/arm64/include/uapi/asm/unistd.h > @@ -19,5 +19,6 @@ > #define __ARCH_WANT_NEW_STAT > #define __ARCH_WANT_SET_GET_RLIMIT > #define __ARCH_WANT_TIME32_SYSCALLS > +#define __ARCH_WANT_SYS_CLONE3 > > #include <asm-generic/unistd.h> > -- > 2.24.1 > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH 1/7] arm64: Move __ARCH_WANT_SYS_CLONE3 definition to uapi headers 2020-01-02 17:50 ` Christian Brauner @ 2020-01-02 19:25 ` Arnd Bergmann 2020-01-02 19:32 ` Amanieu d'Antras 0 siblings, 1 reply; 16+ messages in thread From: Arnd Bergmann @ 2020-01-02 19:25 UTC (permalink / raw) To: Christian Brauner Cc: Linux ARM, # 3.4.x, Amanieu d'Antras, linux-kernel@vger.kernel.org, Christian Brauner On Thu, Jan 2, 2020 at 6:50 PM Christian Brauner <christian.brauner@ubuntu.com> wrote: > On Thu, Jan 02, 2020 at 06:24:07PM +0100, Amanieu d'Antras wrote: > > Previously this was only defined in the internal headers which > > resulted in __NR_clone3 not being defined in the user headers. > > > > Signed-off-by: Amanieu d'Antras <amanieu@gmail.com> > > Cc: linux-arm-kernel@lists.infradead.org > > Cc: <stable@vger.kernel.org> # 5.3.x > > --- > > arch/arm64/include/asm/unistd.h | 1 - > > arch/arm64/include/uapi/asm/unistd.h | 1 + > > 2 files changed, 1 insertion(+), 1 deletion(-) Good catch, this is clearly needed, but please make the patch change every copy of asm/unistd.h that defines this, not just the arm64 one. Arnd _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH 1/7] arm64: Move __ARCH_WANT_SYS_CLONE3 definition to uapi headers 2020-01-02 19:25 ` Arnd Bergmann @ 2020-01-02 19:32 ` Amanieu d'Antras 2020-01-02 19:59 ` Arnd Bergmann 0 siblings, 1 reply; 16+ messages in thread From: Amanieu d'Antras @ 2020-01-02 19:32 UTC (permalink / raw) To: Arnd Bergmann Cc: Linux ARM, # 3.4.x, Christian Brauner, linux-kernel@vger.kernel.org, Christian Brauner On Thu, Jan 2, 2020 at 8:25 PM Arnd Bergmann <arnd@arndb.de> wrote: > On Thu, Jan 2, 2020 at 6:50 PM Christian Brauner > <christian.brauner@ubuntu.com> wrote: > > On Thu, Jan 02, 2020 at 06:24:07PM +0100, Amanieu d'Antras wrote: > > > Previously this was only defined in the internal headers which > > > resulted in __NR_clone3 not being defined in the user headers. > > > > > > Signed-off-by: Amanieu d'Antras <amanieu@gmail.com> > > > Cc: linux-arm-kernel@lists.infradead.org > > > Cc: <stable@vger.kernel.org> # 5.3.x > > > --- > > > arch/arm64/include/asm/unistd.h | 1 - > > > arch/arm64/include/uapi/asm/unistd.h | 1 + > > > 2 files changed, 1 insertion(+), 1 deletion(-) > > Good catch, this is clearly needed, but please make the patch change > every copy of asm/unistd.h that defines this, not just the arm64 one. Actually __ARCH_WANT_SYS_CLONE3 only needs to be in the uapi headers for architectures that use the asm-generic/unistd.h header, which uses it to guard the definition of __NR_clone3. Architectures not using the asm-generic header don't need this define to export __NR_clone3. The only other architecture with clone3 that uses the asm-generic header is riscv, which already defines __ARCH_WANT_SYS_CLONE3 in the uapi headers. _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH 1/7] arm64: Move __ARCH_WANT_SYS_CLONE3 definition to uapi headers 2020-01-02 19:32 ` Amanieu d'Antras @ 2020-01-02 19:59 ` Arnd Bergmann 0 siblings, 0 replies; 16+ messages in thread From: Arnd Bergmann @ 2020-01-02 19:59 UTC (permalink / raw) To: Amanieu d'Antras Cc: Linux ARM, # 3.4.x, Christian Brauner, linux-kernel@vger.kernel.org, Christian Brauner On Thu, Jan 2, 2020 at 8:33 PM Amanieu d'Antras <amanieu@gmail.com> wrote: > > On Thu, Jan 2, 2020 at 8:25 PM Arnd Bergmann <arnd@arndb.de> wrote: > > On Thu, Jan 2, 2020 at 6:50 PM Christian Brauner > > <christian.brauner@ubuntu.com> wrote: > > > On Thu, Jan 02, 2020 at 06:24:07PM +0100, Amanieu d'Antras wrote: > > > > Previously this was only defined in the internal headers which > > > > resulted in __NR_clone3 not being defined in the user headers. > > > > > > > > Signed-off-by: Amanieu d'Antras <amanieu@gmail.com> > > > > Cc: linux-arm-kernel@lists.infradead.org > > > > Cc: <stable@vger.kernel.org> # 5.3.x > > > > --- > > > > arch/arm64/include/asm/unistd.h | 1 - > > > > arch/arm64/include/uapi/asm/unistd.h | 1 + > > > > 2 files changed, 1 insertion(+), 1 deletion(-) > > > > Good catch, this is clearly needed, but please make the patch change > > every copy of asm/unistd.h that defines this, not just the arm64 one. > > Actually __ARCH_WANT_SYS_CLONE3 only needs to be in the uapi headers > for architectures that use the asm-generic/unistd.h header, which uses > it to guard the definition of __NR_clone3. Architectures not using the > asm-generic header don't need this define to export __NR_clone3. The > only other architecture with clone3 that uses the asm-generic header > is riscv, which already defines __ARCH_WANT_SYS_CLONE3 in the uapi > headers. Ah, of course. The patch looks fine to me then. Reviewed-by: Arnd Bergmann <arnd@arndb.de> _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel ^ permalink raw reply [flat|nested] 16+ messages in thread
* [PATCH 2/7] arm64: Implement copy_thread_tls [not found] <20200102172413.654385-1-amanieu@gmail.com> 2020-01-02 17:24 ` [PATCH 1/7] arm64: Move __ARCH_WANT_SYS_CLONE3 definition to uapi headers Amanieu d'Antras @ 2020-01-02 17:24 ` Amanieu d'Antras 2020-01-02 18:01 ` Christian Brauner 2020-01-02 17:24 ` [PATCH 3/7] arm: " Amanieu d'Antras 2 siblings, 1 reply; 16+ messages in thread From: Amanieu d'Antras @ 2020-01-02 17:24 UTC (permalink / raw) To: linux-kernel Cc: linux-arm-kernel, Amanieu d'Antras, stable, Christian Brauner This is required for clone3 which passes the TLS value through a struct rather than a register. Signed-off-by: Amanieu d'Antras <amanieu@gmail.com> Cc: linux-arm-kernel@lists.infradead.org Cc: <stable@vger.kernel.org> # 5.3.x --- arch/arm64/Kconfig | 1 + arch/arm64/kernel/process.c | 10 +++++----- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig index b1b4476ddb83..e688dfad0b72 100644 --- a/arch/arm64/Kconfig +++ b/arch/arm64/Kconfig @@ -138,6 +138,7 @@ config ARM64 select HAVE_CMPXCHG_DOUBLE select HAVE_CMPXCHG_LOCAL select HAVE_CONTEXT_TRACKING + select HAVE_COPY_THREAD_TLS select HAVE_DEBUG_BUGVERBOSE select HAVE_DEBUG_KMEMLEAK select HAVE_DMA_CONTIGUOUS diff --git a/arch/arm64/kernel/process.c b/arch/arm64/kernel/process.c index 71f788cd2b18..d54586d5b031 100644 --- a/arch/arm64/kernel/process.c +++ b/arch/arm64/kernel/process.c @@ -360,8 +360,8 @@ int arch_dup_task_struct(struct task_struct *dst, struct task_struct *src) asmlinkage void ret_from_fork(void) asm("ret_from_fork"); -int copy_thread(unsigned long clone_flags, unsigned long stack_start, - unsigned long stk_sz, struct task_struct *p) +int copy_thread_tls(unsigned long clone_flags, unsigned long stack_start, + unsigned long stk_sz, struct task_struct *p, unsigned long tls) { struct pt_regs *childregs = task_pt_regs(p); @@ -394,11 +394,11 @@ int copy_thread(unsigned long clone_flags, unsigned long stack_start, } /* - * If a TLS pointer was passed to clone (4th argument), use it - * for the new thread. + * If a TLS pointer was passed to clone, use it for the new + * thread. */ if (clone_flags & CLONE_SETTLS) - p->thread.uw.tp_value = childregs->regs[3]; + p->thread.uw.tp_value = tls; } else { memset(childregs, 0, sizeof(struct pt_regs)); childregs->pstate = PSR_MODE_EL1h; -- 2.24.1 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel ^ permalink raw reply related [flat|nested] 16+ messages in thread
* Re: [PATCH 2/7] arm64: Implement copy_thread_tls 2020-01-02 17:24 ` [PATCH 2/7] arm64: Implement copy_thread_tls Amanieu d'Antras @ 2020-01-02 18:01 ` Christian Brauner 2020-01-06 17:39 ` Will Deacon 0 siblings, 1 reply; 16+ messages in thread From: Christian Brauner @ 2020-01-02 18:01 UTC (permalink / raw) To: Amanieu d'Antras, will.deacon Cc: linux-arm-kernel, stable, linux-kernel, Christian Brauner On Thu, Jan 02, 2020 at 06:24:08PM +0100, Amanieu d'Antras wrote: > This is required for clone3 which passes the TLS value through a > struct rather than a register. > > Signed-off-by: Amanieu d'Antras <amanieu@gmail.com> > Cc: linux-arm-kernel@lists.infradead.org > Cc: <stable@vger.kernel.org> # 5.3.x This looks sane to me but I'd like an ack from someone who knows his arm from his arse before taking this. :) Acked-by: Christian Brauner <christian.brauner@ubuntu.com> > --- > arch/arm64/Kconfig | 1 + > arch/arm64/kernel/process.c | 10 +++++----- > 2 files changed, 6 insertions(+), 5 deletions(-) > > diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig > index b1b4476ddb83..e688dfad0b72 100644 > --- a/arch/arm64/Kconfig > +++ b/arch/arm64/Kconfig > @@ -138,6 +138,7 @@ config ARM64 > select HAVE_CMPXCHG_DOUBLE > select HAVE_CMPXCHG_LOCAL > select HAVE_CONTEXT_TRACKING > + select HAVE_COPY_THREAD_TLS > select HAVE_DEBUG_BUGVERBOSE > select HAVE_DEBUG_KMEMLEAK > select HAVE_DMA_CONTIGUOUS > diff --git a/arch/arm64/kernel/process.c b/arch/arm64/kernel/process.c > index 71f788cd2b18..d54586d5b031 100644 > --- a/arch/arm64/kernel/process.c > +++ b/arch/arm64/kernel/process.c > @@ -360,8 +360,8 @@ int arch_dup_task_struct(struct task_struct *dst, struct task_struct *src) > > asmlinkage void ret_from_fork(void) asm("ret_from_fork"); > > -int copy_thread(unsigned long clone_flags, unsigned long stack_start, > - unsigned long stk_sz, struct task_struct *p) > +int copy_thread_tls(unsigned long clone_flags, unsigned long stack_start, > + unsigned long stk_sz, struct task_struct *p, unsigned long tls) > { > struct pt_regs *childregs = task_pt_regs(p); > > @@ -394,11 +394,11 @@ int copy_thread(unsigned long clone_flags, unsigned long stack_start, > } > > /* > - * If a TLS pointer was passed to clone (4th argument), use it > - * for the new thread. > + * If a TLS pointer was passed to clone, use it for the new > + * thread. > */ > if (clone_flags & CLONE_SETTLS) > - p->thread.uw.tp_value = childregs->regs[3]; > + p->thread.uw.tp_value = tls; > } else { > memset(childregs, 0, sizeof(struct pt_regs)); > childregs->pstate = PSR_MODE_EL1h; > -- > 2.24.1 > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH 2/7] arm64: Implement copy_thread_tls 2020-01-02 18:01 ` Christian Brauner @ 2020-01-06 17:39 ` Will Deacon 2020-01-06 18:03 ` Amanieu d'Antras 0 siblings, 1 reply; 16+ messages in thread From: Will Deacon @ 2020-01-06 17:39 UTC (permalink / raw) To: Christian Brauner Cc: Amanieu d'Antras, will.deacon, linux-kernel, stable, Christian Brauner, linux-arm-kernel On Thu, Jan 02, 2020 at 07:01:33PM +0100, Christian Brauner wrote: > On Thu, Jan 02, 2020 at 06:24:08PM +0100, Amanieu d'Antras wrote: > > This is required for clone3 which passes the TLS value through a > > struct rather than a register. > > > > Signed-off-by: Amanieu d'Antras <amanieu@gmail.com> > > Cc: linux-arm-kernel@lists.infradead.org > > Cc: <stable@vger.kernel.org> # 5.3.x > > This looks sane to me but I'd like an ack from someone who knows his arm > from his arse before taking this. :) That's *ME*! Code looks fine: Acked-by: Will Deacon <will@kernel.org> I also ran the native and compat selftests but, unfortunately, they all pass even without this patch. Do you reckon it would be possible to update them to check the tls pointer? Will _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH 2/7] arm64: Implement copy_thread_tls 2020-01-06 17:39 ` Will Deacon @ 2020-01-06 18:03 ` Amanieu d'Antras 2020-01-07 9:02 ` Christian Brauner 0 siblings, 1 reply; 16+ messages in thread From: Amanieu d'Antras @ 2020-01-06 18:03 UTC (permalink / raw) To: Will Deacon Cc: Will Deacon, linux-kernel, # 3.4.x, Christian Brauner, Christian Brauner, Linux ARM On Mon, Jan 6, 2020 at 6:39 PM Will Deacon <will@kernel.org> wrote: > I also ran the native and compat selftests but, unfortunately, they all > pass even without this patch. Do you reckon it would be possible to update > them to check the tls pointer? Here's the program I used for testing on arm64. I considered adding it to the selftests but there is no portable way of reading the TLS register on all architectures. #include <sys/syscall.h> #include <unistd.h> #include <stdio.h> #include <stdint.h> #define __NR_clone3 435 struct clone_args { uint64_t flags; uint64_t pidfd; uint64_t child_tid; uint64_t parent_tid; uint64_t exit_signal; uint64_t stack; uint64_t stack_size; uint64_t tls; }; #define USE_CLONE3 int main() { printf("Before fork: tp = %p\n", __builtin_thread_pointer()); #ifdef USE_CLONE3 struct clone_args args = { .flags = CLONE_SETTLS, .tls = (uint64_t)__builtin_thread_pointer(), }; int ret = syscall(__NR_clone3, &args, sizeof(args)); #else int ret = syscall(__NR_clone, CLONE_SETTLS, 0, 0, __builtin_thread_pointer(), 0); #endif printf("Fork returned %d, tp = %p\n", ret, __builtin_thread_pointer()); } _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH 2/7] arm64: Implement copy_thread_tls 2020-01-06 18:03 ` Amanieu d'Antras @ 2020-01-07 9:02 ` Christian Brauner 2020-01-07 17:45 ` Will Deacon 0 siblings, 1 reply; 16+ messages in thread From: Christian Brauner @ 2020-01-07 9:02 UTC (permalink / raw) To: Amanieu d'Antras Cc: keescook, Will Deacon, linux-kernel, # 3.4.x, Christian Brauner, linux-kselftest, Will Deacon, Linux ARM [Cc Kees in case he knows something about where arch specific tests live or whether we have a framework for this] On Mon, Jan 06, 2020 at 07:03:32PM +0100, Amanieu d'Antras wrote: > On Mon, Jan 6, 2020 at 6:39 PM Will Deacon <will@kernel.org> wrote: > > I also ran the native and compat selftests but, unfortunately, they all > > pass even without this patch. Do you reckon it would be possible to update > > them to check the tls pointer? > > Here's the program I used for testing on arm64. I considered adding it > to the selftests but there is no portable way of reading the TLS > register on all architectures. I'm not saying you need to do this right now. It feels like we must've run into the "this is architecture specific"-and-we-want-to-test-this issue before... Do we have a place where architecture specific selftests live? > > #include <sys/syscall.h> > #include <unistd.h> > #include <stdio.h> > #include <stdint.h> > > #define __NR_clone3 435 > struct clone_args { > uint64_t flags; > uint64_t pidfd; > uint64_t child_tid; > uint64_t parent_tid; > uint64_t exit_signal; > uint64_t stack; > uint64_t stack_size; > uint64_t tls; > }; > > #define USE_CLONE3 > > int main() { > printf("Before fork: tp = %p\n", __builtin_thread_pointer()); > #ifdef USE_CLONE3 > struct clone_args args = { > .flags = CLONE_SETTLS, > .tls = (uint64_t)__builtin_thread_pointer(), > }; > int ret = syscall(__NR_clone3, &args, sizeof(args)); > #else > int ret = syscall(__NR_clone, CLONE_SETTLS, 0, 0, > __builtin_thread_pointer(), 0); > #endif > printf("Fork returned %d, tp = %p\n", ret, __builtin_thread_pointer()); > } _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH 2/7] arm64: Implement copy_thread_tls 2020-01-07 9:02 ` Christian Brauner @ 2020-01-07 17:45 ` Will Deacon 2020-01-07 18:12 ` Kees Cook 2020-01-07 19:30 ` Christian Brauner 0 siblings, 2 replies; 16+ messages in thread From: Will Deacon @ 2020-01-07 17:45 UTC (permalink / raw) To: Christian Brauner Cc: Amanieu d'Antras, keescook, Will Deacon, linux-kernel, # 3.4.x, Christian Brauner, linux-kselftest, Linux ARM On Tue, Jan 07, 2020 at 10:02:27AM +0100, Christian Brauner wrote: > [Cc Kees in case he knows something about where arch specific tests live > or whether we have a framework for this] > > On Mon, Jan 06, 2020 at 07:03:32PM +0100, Amanieu d'Antras wrote: > > On Mon, Jan 6, 2020 at 6:39 PM Will Deacon <will@kernel.org> wrote: > > > I also ran the native and compat selftests but, unfortunately, they all > > > pass even without this patch. Do you reckon it would be possible to update > > > them to check the tls pointer? > > > > Here's the program I used for testing on arm64. I considered adding it > > to the selftests but there is no portable way of reading the TLS > > register on all architectures. > > I'm not saying you need to do this right now. Agreed, these patches should be merged in their current state and my ack stands for that. > It feels like we must've run into the "this is architecture > specific"-and-we-want-to-test-this issue before... Do we have a place > where architecture specific selftests live? For arch-specific selftests there are tools/testing/selftests/$ARCH directories, although in this case maybe it's better to have an #ifdef in a header so that architectures with __builtin_thread_pointer can use that. Will _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH 2/7] arm64: Implement copy_thread_tls 2020-01-07 17:45 ` Will Deacon @ 2020-01-07 18:12 ` Kees Cook 2020-01-07 19:30 ` Christian Brauner 2020-01-07 19:30 ` Christian Brauner 1 sibling, 1 reply; 16+ messages in thread From: Kees Cook @ 2020-01-07 18:12 UTC (permalink / raw) To: Will Deacon Cc: Amanieu d'Antras, Will Deacon, linux-kernel, # 3.4.x, Linux ARM, linux-kselftest, Christian Brauner, Christian Brauner On Tue, Jan 07, 2020 at 05:45:09PM +0000, Will Deacon wrote: > On Tue, Jan 07, 2020 at 10:02:27AM +0100, Christian Brauner wrote: > > [Cc Kees in case he knows something about where arch specific tests live > > or whether we have a framework for this] > > [...] > > It feels like we must've run into the "this is architecture > > specific"-and-we-want-to-test-this issue before... Do we have a place > > where architecture specific selftests live? > > For arch-specific selftests there are tools/testing/selftests/$ARCH > directories, although in this case maybe it's better to have an #ifdef > in a header so that architectures with __builtin_thread_pointer can use > that. Yup, I agree: that's the current best-practice for arch-specific selftests. -- Kees Cook _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH 2/7] arm64: Implement copy_thread_tls 2020-01-07 18:12 ` Kees Cook @ 2020-01-07 19:30 ` Christian Brauner 0 siblings, 0 replies; 16+ messages in thread From: Christian Brauner @ 2020-01-07 19:30 UTC (permalink / raw) To: Kees Cook Cc: Amanieu d'Antras, Will Deacon, linux-kernel, # 3.4.x, Linux ARM, linux-kselftest, Will Deacon, Christian Brauner On Tue, Jan 07, 2020 at 10:12:39AM -0800, Kees Cook wrote: > On Tue, Jan 07, 2020 at 05:45:09PM +0000, Will Deacon wrote: > > On Tue, Jan 07, 2020 at 10:02:27AM +0100, Christian Brauner wrote: > > > [Cc Kees in case he knows something about where arch specific tests live > > > or whether we have a framework for this] > > > [...] > > > It feels like we must've run into the "this is architecture > > > specific"-and-we-want-to-test-this issue before... Do we have a place > > > where architecture specific selftests live? > > > > For arch-specific selftests there are tools/testing/selftests/$ARCH > > directories, although in this case maybe it's better to have an #ifdef > > in a header so that architectures with __builtin_thread_pointer can use > > that. > > Yup, I agree: that's the current best-practice for arch-specific > selftests. Thanks! I think using #ifdef in this case with __builtin_thread_pointer sounds good. So the tests can be moved into the clone3() test-suite for those architectures. Christian _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel ^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [PATCH 2/7] arm64: Implement copy_thread_tls 2020-01-07 17:45 ` Will Deacon 2020-01-07 18:12 ` Kees Cook @ 2020-01-07 19:30 ` Christian Brauner 1 sibling, 0 replies; 16+ messages in thread From: Christian Brauner @ 2020-01-07 19:30 UTC (permalink / raw) To: Will Deacon Cc: Amanieu d'Antras, keescook, Will Deacon, linux-kernel, # 3.4.x, Christian Brauner, linux-kselftest, Linux ARM On Tue, Jan 07, 2020 at 05:45:09PM +0000, Will Deacon wrote: > On Tue, Jan 07, 2020 at 10:02:27AM +0100, Christian Brauner wrote: > > [Cc Kees in case he knows something about where arch specific tests live > > or whether we have a framework for this] > > > > On Mon, Jan 06, 2020 at 07:03:32PM +0100, Amanieu d'Antras wrote: > > > On Mon, Jan 6, 2020 at 6:39 PM Will Deacon <will@kernel.org> wrote: > > > > I also ran the native and compat selftests but, unfortunately, they all > > > > pass even without this patch. Do you reckon it would be possible to update > > > > them to check the tls pointer? > > > > > > Here's the program I used for testing on arm64. I considered adding it > > > to the selftests but there is no portable way of reading the TLS > > > register on all architectures. > > > > I'm not saying you need to do this right now. > > Agreed, these patches should be merged in their current state and my ack > stands for that. Oh yeah, that's how I took your Ack. Thanks! :) > > > It feels like we must've run into the "this is architecture > > specific"-and-we-want-to-test-this issue before... Do we have a place > > where architecture specific selftests live? > > For arch-specific selftests there are tools/testing/selftests/$ARCH > directories, although in this case maybe it's better to have an #ifdef > in a header so that architectures with __builtin_thread_pointer can use > that. Yeah, I think the #ifdef approach might make the most sense. Christian _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel ^ permalink raw reply [flat|nested] 16+ messages in thread
* [PATCH 3/7] arm: Implement copy_thread_tls [not found] <20200102172413.654385-1-amanieu@gmail.com> 2020-01-02 17:24 ` [PATCH 1/7] arm64: Move __ARCH_WANT_SYS_CLONE3 definition to uapi headers Amanieu d'Antras 2020-01-02 17:24 ` [PATCH 2/7] arm64: Implement copy_thread_tls Amanieu d'Antras @ 2020-01-02 17:24 ` Amanieu d'Antras 2020-01-02 18:02 ` Christian Brauner 2 siblings, 1 reply; 16+ messages in thread From: Amanieu d'Antras @ 2020-01-02 17:24 UTC (permalink / raw) To: linux-kernel Cc: linux-arm-kernel, Amanieu d'Antras, stable, Christian Brauner This is required for clone3 which passes the TLS value through a struct rather than a register. Signed-off-by: Amanieu d'Antras <amanieu@gmail.com> Cc: linux-arm-kernel@lists.infradead.org Cc: <stable@vger.kernel.org> # 5.3.x --- arch/arm/Kconfig | 1 + arch/arm/kernel/process.c | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig index ba75e3661a41..96dab76da3b3 100644 --- a/arch/arm/Kconfig +++ b/arch/arm/Kconfig @@ -72,6 +72,7 @@ config ARM select HAVE_ARM_SMCCC if CPU_V7 select HAVE_EBPF_JIT if !CPU_ENDIAN_BE32 select HAVE_CONTEXT_TRACKING + select HAVE_COPY_THREAD_TLS select HAVE_C_RECORDMCOUNT select HAVE_DEBUG_KMEMLEAK select HAVE_DMA_CONTIGUOUS if MMU diff --git a/arch/arm/kernel/process.c b/arch/arm/kernel/process.c index cea1c27c29cb..46e478fb5ea2 100644 --- a/arch/arm/kernel/process.c +++ b/arch/arm/kernel/process.c @@ -226,8 +226,8 @@ void release_thread(struct task_struct *dead_task) asmlinkage void ret_from_fork(void) __asm__("ret_from_fork"); int -copy_thread(unsigned long clone_flags, unsigned long stack_start, - unsigned long stk_sz, struct task_struct *p) +copy_thread_tls(unsigned long clone_flags, unsigned long stack_start, + unsigned long stk_sz, struct task_struct *p, unsigned long tls) { struct thread_info *thread = task_thread_info(p); struct pt_regs *childregs = task_pt_regs(p); @@ -261,7 +261,7 @@ copy_thread(unsigned long clone_flags, unsigned long stack_start, clear_ptrace_hw_breakpoint(p); if (clone_flags & CLONE_SETTLS) - thread->tp_value[0] = childregs->ARM_r3; + thread->tp_value[0] = tls; thread->tp_value[1] = get_tpuser(); thread_notify(THREAD_NOTIFY_COPY, thread); -- 2.24.1 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel ^ permalink raw reply related [flat|nested] 16+ messages in thread
* Re: [PATCH 3/7] arm: Implement copy_thread_tls 2020-01-02 17:24 ` [PATCH 3/7] arm: " Amanieu d'Antras @ 2020-01-02 18:02 ` Christian Brauner 0 siblings, 0 replies; 16+ messages in thread From: Christian Brauner @ 2020-01-02 18:02 UTC (permalink / raw) To: Amanieu d'Antras, will.deacon Cc: linux-arm-kernel, stable, linux-kernel, Christian Brauner On Thu, Jan 02, 2020 at 06:24:09PM +0100, Amanieu d'Antras wrote: > This is required for clone3 which passes the TLS value through a > struct rather than a register. > > Signed-off-by: Amanieu d'Antras <amanieu@gmail.com> > Cc: linux-arm-kernel@lists.infradead.org > Cc: <stable@vger.kernel.org> # 5.3.x Again, looks good to me but I'd like an ack from someone closer to the architecture itself. Acked-by: Christian Brauner <christian.brauner@ubuntu.com> > --- > arch/arm/Kconfig | 1 + > arch/arm/kernel/process.c | 6 +++--- > 2 files changed, 4 insertions(+), 3 deletions(-) > > diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig > index ba75e3661a41..96dab76da3b3 100644 > --- a/arch/arm/Kconfig > +++ b/arch/arm/Kconfig > @@ -72,6 +72,7 @@ config ARM > select HAVE_ARM_SMCCC if CPU_V7 > select HAVE_EBPF_JIT if !CPU_ENDIAN_BE32 > select HAVE_CONTEXT_TRACKING > + select HAVE_COPY_THREAD_TLS > select HAVE_C_RECORDMCOUNT > select HAVE_DEBUG_KMEMLEAK > select HAVE_DMA_CONTIGUOUS if MMU > diff --git a/arch/arm/kernel/process.c b/arch/arm/kernel/process.c > index cea1c27c29cb..46e478fb5ea2 100644 > --- a/arch/arm/kernel/process.c > +++ b/arch/arm/kernel/process.c > @@ -226,8 +226,8 @@ void release_thread(struct task_struct *dead_task) > asmlinkage void ret_from_fork(void) __asm__("ret_from_fork"); > > int > -copy_thread(unsigned long clone_flags, unsigned long stack_start, > - unsigned long stk_sz, struct task_struct *p) > +copy_thread_tls(unsigned long clone_flags, unsigned long stack_start, > + unsigned long stk_sz, struct task_struct *p, unsigned long tls) > { > struct thread_info *thread = task_thread_info(p); > struct pt_regs *childregs = task_pt_regs(p); > @@ -261,7 +261,7 @@ copy_thread(unsigned long clone_flags, unsigned long stack_start, > clear_ptrace_hw_breakpoint(p); > > if (clone_flags & CLONE_SETTLS) > - thread->tp_value[0] = childregs->ARM_r3; > + thread->tp_value[0] = tls; > thread->tp_value[1] = get_tpuser(); > > thread_notify(THREAD_NOTIFY_COPY, thread); > -- > 2.24.1 > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel ^ permalink raw reply [flat|nested] 16+ messages in thread
end of thread, other threads:[~2020-01-07 19:31 UTC | newest]
Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <20200102172413.654385-1-amanieu@gmail.com>
2020-01-02 17:24 ` [PATCH 1/7] arm64: Move __ARCH_WANT_SYS_CLONE3 definition to uapi headers Amanieu d'Antras
2020-01-02 17:50 ` Christian Brauner
2020-01-02 19:25 ` Arnd Bergmann
2020-01-02 19:32 ` Amanieu d'Antras
2020-01-02 19:59 ` Arnd Bergmann
2020-01-02 17:24 ` [PATCH 2/7] arm64: Implement copy_thread_tls Amanieu d'Antras
2020-01-02 18:01 ` Christian Brauner
2020-01-06 17:39 ` Will Deacon
2020-01-06 18:03 ` Amanieu d'Antras
2020-01-07 9:02 ` Christian Brauner
2020-01-07 17:45 ` Will Deacon
2020-01-07 18:12 ` Kees Cook
2020-01-07 19:30 ` Christian Brauner
2020-01-07 19:30 ` Christian Brauner
2020-01-02 17:24 ` [PATCH 3/7] arm: " Amanieu d'Antras
2020-01-02 18:02 ` Christian Brauner
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).