Re: [PATCH v5 02/13] x86/um: nommu: elf loader for fdpic

2024-12-13 Thread Eric W. Biederman
Hajime Tazaki writes: > On Sat, 14 Dec 2024 05:01:58 +0900, > Eric W. Biederman wrote: > >> >> Last time I looked the regular binfmt_elf works just fine >> >> without an mmu. I looked again and at a quick skim the >> >> regular elf loader still

Re: [PATCH v5 02/13] x86/um: nommu: elf loader for fdpic

2024-12-13 Thread Eric W. Biederman
Hajime Tazaki writes: > Hello Eric, > > thanks for the feedback. > > On Thu, 12 Dec 2024 23:22:47 +0900, > Eric W. Biederman wrote: >> >> Hajime Tazaki writes: >> >> > As UML supports CONFIG_MMU=n case, it has to use an alternate ELF >> &g

Re: [PATCH v5 02/13] x86/um: nommu: elf loader for fdpic

2024-12-12 Thread Eric W. Biederman
Hajime Tazaki writes: > As UML supports CONFIG_MMU=n case, it has to use an alternate ELF > loader, FDPIC ELF loader. In this commit, we added necessary > definitions in the arch, as UML has not been used so far. It also > updates Kconfig file to use BINFMT_ELF_FDPIC under !MMU environment. Wh

Re: [PATCH v4 12/12] sched,signal,ptrace: Rework TASK_TRACED, TASK_STOPPED state

2022-06-28 Thread Eric W. Biederman
Steven Rostedt writes: > On Tue, 28 Jun 2022 17:42:22 -0500 > "Eric W. Biederman" wrote: > >> diff --git a/kernel/ptrace.c b/kernel/ptrace.c >> index 156a99283b11..cb85bcf84640 100644 >> --- a/kernel/ptrace.c >> +++ b/kernel/ptrace.c >> @@

Re: [PATCH v4 12/12] sched,signal,ptrace: Rework TASK_TRACED, TASK_STOPPED state

2022-06-28 Thread Eric W. Biederman
Alexander Gordeev writes: > On Sat, Jun 25, 2022 at 11:34:46AM -0500, Eric W. Biederman wrote: >> I haven't gotten as far as reproducing this but I have started giving >> this issue some thought. >> >> This entire thing smells like a memory barrier is missing som

Re: [PATCH v4 12/12] sched,signal,ptrace: Rework TASK_TRACED, TASK_STOPPED state

2022-06-25 Thread Eric W. Biederman
Alexander Gordeev writes: > On Tue, Jun 21, 2022 at 09:02:05AM -0500, Eric W. Biederman wrote: >> Alexander Gordeev writes: >> >> > On Thu, May 05, 2022 at 01:26:45PM -0500, Eric W. Biederman wrote: >> >> From: Peter Zijlstra >> >> >> >

Re: [PATCH v4 12/12] sched,signal,ptrace: Rework TASK_TRACED, TASK_STOPPED state

2022-06-21 Thread Eric W. Biederman
Alexander Gordeev writes: > On Tue, Jun 21, 2022 at 09:02:05AM -0500, Eric W. Biederman wrote: >> Alexander Gordeev writes: >> >> > On Thu, May 05, 2022 at 01:26:45PM -0500, Eric W. Biederman wrote: >> >> From: Peter Zijlstra >> >> >> >

Re: [PATCH v4 12/12] sched,signal,ptrace: Rework TASK_TRACED, TASK_STOPPED state

2022-06-21 Thread Eric W. Biederman
Alexander Gordeev writes: > On Thu, May 05, 2022 at 01:26:45PM -0500, Eric W. Biederman wrote: >> From: Peter Zijlstra >> >> Currently ptrace_stop() / do_signal_stop() rely on the special states >> TASK_TRACED and TASK_STOPPED resp. to keep unique state. That is, t

Re: [PATCH 00/16] ptrace: cleanups and calling do_cldstop with only siglock

2022-06-08 Thread Eric W. Biederman
Kyle Huey writes: > On Thu, May 19, 2022 at 11:05 AM Eric W. Biederman > wrote: >> >> Sebastian Andrzej Siewior writes: >> >> > On 2022-05-18 20:26:05 [-0700], Kyle Huey wrote: >> >> Is there a git branch somewhere I can pull to test this?

Re: [PATCH 08/16] ptrace: Only populate last_siginfo from ptrace

2022-06-06 Thread Eric W. Biederman
Oleg Nesterov writes: > On 05/18, Eric W. Biederman wrote: >> >> The code in ptrace_signal to populate siginfo if the signal number >> changed is buggy. If the tracer contined the tracee using >> ptrace_detach it is guaranteed to use the real_parent (or possibly a &g

Re: [PATCH 07/16] signal: Wake up the designated parent

2022-06-06 Thread Eric W. Biederman
Oleg Nesterov writes: > On 05/24, Oleg Nesterov wrote: >> >> On 05/24, Oleg Nesterov wrote: >> > >> > I fail to understand this patch... >> > >> > On 05/18, Eric W. Biederman wrote: >> > > >> > > Today if a process is

Re: [PATCH 05/16] ptrace: Remove dead code from __ptrace_detach

2022-06-06 Thread Eric W. Biederman
Oleg Nesterov writes: > On 05/24, Oleg Nesterov wrote: >> >> Sorry for delay. >> >> On 05/18, Eric W. Biederman wrote: >> > >> > Ever since commit 28d838cc4dfe ("Fix ptrace self-attach rule") it has >> > been impossible to attach an

Re: [PATCH 24/30] panic: Refactor the panic path

2022-05-24 Thread Eric W. Biederman
"Guilherme G. Piccoli" writes: > The panic() function is somewhat convoluted - a lot of changes were > made over the years, adding comments that might be misleading/outdated > now, it has a code structure that is a bit complex to follow, with > lots of conditionals, for example. The panic notifie

Re: [PATCH 00/16] ptrace: cleanups and calling do_cldstop with only siglock

2022-05-20 Thread Eric W. Biederman
Sebastian Andrzej Siewior writes: > On 2022-05-18 17:49:50 [-0500], Eric W. Biederman wrote: >> >> For ptrace_stop to work on PREEMT_RT no spinlocks can be taken once >> ptrace_freeze_traced has completed successfully. Which fundamentally >> means the lock da

Re: [PATCH 03/16] kdb: Use real_parent when displaying a list of processes

2022-05-19 Thread Eric W. Biederman
Doug Anderson writes: > Hi, > > On Wed, May 18, 2022 at 3:54 PM Eric W. Biederman > wrote: >> >> kdb has a bug that when using the ps command to display a list of >> processes, if a process is being debugged the debugger as the parent >> process. >&g

Re: [PATCH 03/16] kdb: Use real_parent when displaying a list of processes

2022-05-19 Thread Eric W. Biederman
Peter Zijlstra writes: > On Wed, May 18, 2022 at 05:53:42PM -0500, Eric W. Biederman wrote: >> kdb has a bug that when using the ps command to display a list of >> processes, if a process is being debugged the debugger as the parent >> process. >> >> This is s

Re: [PATCH 00/16] ptrace: cleanups and calling do_cldstop with only siglock

2022-05-19 Thread Eric W. Biederman
Sebastian Andrzej Siewior writes: > On 2022-05-18 20:26:05 [-0700], Kyle Huey wrote: >> Is there a git branch somewhere I can pull to test this? It doesn't apply >> cleanly to Linus's tip. > > https://kernel.googlesource.com/pub/scm/linux/kernel/git/ebiederm/user-namespace.git > ptrace_stop-clea

[PATCH 16/16] signal: Always call do_notify_parent_cldstop with siglock held

2022-05-18 Thread Eric W. Biederman
to TASK_TRACED. Which on PREEMPT_RT means the code can sleep and change __state. Not only that but it means that wait_task_inactive could potentially detect the code scheduling away at that point and fail, causing ptrace_check_attach to fail. Signed-off-by: "Eric W. Biederman" --

[PATCH 15/16] ptrace: Use siglock instead of tasklist_lock in ptrace_check_attach

2022-05-18 Thread Eric W. Biederman
Now that siglock protects tsk->parent and tsk->ptrace there is no need to grab tasklist_lock in ptrace_check_attach. The siglock can handle all of the locking needs of ptrace_check_attach. Signed-off-by: "Eric W. Biederman" --- kernel/ptrace.c | 23 +-- 1

[PATCH 14/16] signal: Protect parent child relationships by childs siglock

2022-05-18 Thread Eric W. Biederman
entry is reused as the dead task list. The field tsk->sibling is not protected by siglock when children are reparented because their original parent dies. The field tsk->ptrace is protected by siglock except for the options which may change without siglock being held. Signed-off-by: "

[PATCH 13/16] ptrace: Document why ptrace_setoptions does not need a lock

2022-05-18 Thread Eric W. Biederman
ce. When ptrace_setoptions is called the tracee has been frozen with ptrace_freeze_traced, and most be explicitly unfrozen by the tracer before it can do anything. As ptrace_setoption is run in the tracer there can be no contention by the simple fact that the tracee can't run. Signed-off-by: &quo

[PATCH 12/16] ptrace: Stop protecting ptrace_set_signr with tasklist_lock

2022-05-18 Thread Eric W. Biederman
ty of a race and ptrace_freeze_traced is all of the protection ptrace_set_signr needs to operate without contention move ptrace_set_signr outside of tasklist_lock and remove the documentation about the race that is no more. Signed-off-by: "Eric W. Biederman" --- kernel/ptrace.c | 19 +

[PATCH 11/16] ptrace: Use si_sino as the signal number to resume with

2022-05-18 Thread Eric W. Biederman
resume with remove the comment and the return code from ptrace_stop. Signed-off-by: "Eric W. Biederman" --- kernel/ptrace.c | 1 - kernel/signal.c | 13 - 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/kernel/ptrace.c b/kernel/ptrace.c index a0a07d140751..e0e

[PATCH 10/16] ptrace: In ptrace_signal look at what the debugger did with siginfo

2022-05-18 Thread Eric W. Biederman
Now that siginfo is only modified by the tracer and that siginfo is cleared with the signal is canceled have ptrace_signal directly examine siginfo. This makes the code a little simpler and handles the case when the tracer exits without calling ptrace_detach. Signed-off-by: "Eric W. Bied

[PATCH 08/16] ptrace: Only populate last_siginfo from ptrace

2022-05-18 Thread Eric W. Biederman
IGINFO and PTRACE_SETSIGINFO") when last_siginfo was introduced and the tracer could change siginfo. Fixes: v2.1.68 History-Tree: https://git.kernel.org/pub/scm/linux/kernel/git/tglx/history.git Signed-off-by: "Eric W. Biederman" --- kernel/ptrace.c | 31

[PATCH 09/16] ptrace: In ptrace_setsiginfo deal with invalid si_signo

2022-05-18 Thread Eric W. Biederman
checks later by immediately clearing siginfo if si_signo is not valid. Signed-off-by: "Eric W. Biederman" --- kernel/ptrace.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/kernel/ptrace.c b/kernel/ptrace.c index a24eed725cec..a0a07d140751 100644 --- a/kerne

[PATCH 07/16] signal: Wake up the designated parent

2022-05-18 Thread Eric W. Biederman
ce to do_notify_parent_cldstop()") Signed-off-by: "Eric W. Biederman" --- kernel/exit.c | 19 ++- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/kernel/exit.c b/kernel/exit.c index f072959fcab7..0e26f73c49ac 100644 --- a/kernel/exit.c +++ b/kernel/exit.c

[PATCH 06/16] ptrace: Remove unnecessary locking in ptrace_(get|set)siginfo

2022-05-18 Thread Eric W. Biederman
f the code need to take the unnecessary lock as well. So remove the unnecessary lock to make the code more efficient, simpler, and less confusing. Signed-off-by: "Eric W. Biederman" --- kernel/ptrace.c | 30 -- 1 file changed, 8 insertions(+), 22 deletions(-)

[PATCH 04/16] powerpc/xmon: Use real_parent when displaying a list of processes

2022-05-18 Thread Eric W. Biederman
display a debugger as the parent of a process. Cc: Douglas Miller Cc: Michael Ellerman Cc: Benjamin Herrenschmidt Cc: Paul Mackerras Fixes: 6dfb54049f9a ("powerpc/xmon: Add xmon command to dump process/task similar to ps(1)") Signed-off-by: "Eric W. Biederman" --- arch/pow

[PATCH 05/16] ptrace: Remove dead code from __ptrace_detach

2022-05-18 Thread Eric W. Biederman
e sense of what it is trying to do. Signed-off-by: "Eric W. Biederman" --- kernel/ptrace.c | 24 +++- 1 file changed, 3 insertions(+), 21 deletions(-) diff --git a/kernel/ptrace.c b/kernel/ptrace.c index 328a34a99124..ca0e47691229 100644 --- a/kernel/ptrace.c +

[PATCH 02/16] signal/ia64: Remove unused definition of IA64_TASK_REAL_PARENT_OFFSET

2022-05-18 Thread Eric W. Biederman
Rather than update the unused definition of IA64_TASK_REAL_PARENT_OFFSENT when I move tsk->real_parent into signal_struct remove it now. Cc: linux-i...@vger.kernel.org Signed-off-by: "Eric W. Biederman" --- arch/ia64/kernel/asm-offsets.c | 1 - 1 file changed, 1 deletion(-) diff

[PATCH 03/16] kdb: Use real_parent when displaying a list of processes

2022-05-18 Thread Eric W. Biederman
real_parent so that it is clear kdb does not want to display a debugger as the parent of a process. Cc: Jason Wessel Cc: Daniel Thompson Cc: Douglas Anderson Fixes: 5d5314d6795f ("kdb: core for kgdb back end (1 of 2)" Signed-off-by: "Eric W. Biederman" --- kernel/debug/kdb/

[PATCH 01/16] signal/alpha: Remove unused definition of TASK_REAL_PARENT

2022-05-18 Thread Eric W. Biederman
Rather than update this defition when I move tsk->real_parent into signal_struct remove it now. Cc: Richard Henderson Cc: Ivan Kokshaysky Cc: Matt Turner Cc: linux-al...@vger.kernel.org Signed-off-by: "Eric W. Biederman" --- arch/alpha/kernel/asm-offsets.c | 1 - 1 file change

[PATCH 00/16] ptrace: cleanups and calling do_cldstop with only siglock

2022-05-18 Thread Eric W. Biederman
block for PREEMPT_RT in the ptrace_stop path. Eric W. Biederman (16): signal/alpha: Remove unused definition of TASK_REAL_PARENT signal/ia64: Remove unused definition of IA64_TASK_REAL_PARENT_OFFSET kdb: Use real_parent when displaying a list of processes powerpc/xmon: Use r

Re: [PATCH v4 0/12] ptrace: cleaning up ptrace_stop

2022-05-11 Thread Eric W. Biederman
"Eric W. Biederman" writes: > Oleg Nesterov writes: > >> On 05/05, Eric W. Biederman wrote: >>> >>> Eric W. Biederman (11): >>> signal: Rename send_signal send_signal_locked >>> signal: Replace __group_send_sig_info with send

Re: [PATCH v4 0/12] ptrace: cleaning up ptrace_stop

2022-05-10 Thread Eric W. Biederman
Sebastian Andrzej Siewior writes: > On 2022-05-10 09:26:36 [-0500], Eric W. Biederman wrote: >> Does anyone else have any comments on this patchset? >> >> If not I am going to apply this to a branch and get it into linux-next. > > Looks good I guess. > Be aware t

Re: [PATCH v4 10/12] ptrace: Don't change __state

2022-05-10 Thread Eric W. Biederman
Oleg Nesterov writes: > On 05/05, Eric W. Biederman wrote: >> >> static void ptrace_unfreeze_traced(struct task_struct *task) >> { >> -if (READ_ONCE(task->__state) != __TASK_TRACED) >> -return; >> - >> -WARN_ON(!task->p

Re: [PATCH v4 0/12] ptrace: cleaning up ptrace_stop

2022-05-10 Thread Eric W. Biederman
Oleg Nesterov writes: > On 05/05, Eric W. Biederman wrote: >> >> Eric W. Biederman (11): >> signal: Rename send_signal send_signal_locked >> signal: Replace __group_send_sig_info with send_signal_locked >> ptrace/um: Replace PT_DTRACE with TIF_

Re: [PATCH v4 0/12] ptrace: cleaning up ptrace_stop

2022-05-06 Thread Eric W. Biederman
Kees Cook writes: > On Thu, May 05, 2022 at 01:25:57PM -0500, Eric W. Biederman wrote: >> The states TASK_STOPPED and TASK_TRACE are special in they can not >> handle spurious wake-ups. This plus actively depending upon and >> changing the value of tsk->__state causes

Re: [PATCH v4 10/12] ptrace: Don't change __state

2022-05-06 Thread Eric W. Biederman
Oleg Nesterov writes: > On 05/05, Eric W. Biederman wrote: >> >> --- a/include/linux/sched.h >> +++ b/include/linux/sched.h >> @@ -103,7 +103,7 @@ struct task_group; >> /* Convenience macros for the sake of set_current_state: */ >> #define TASK_KILLAB

Re: [PATCH v4 0/12] ptrace: cleaning up ptrace_stop

2022-05-06 Thread Eric W. Biederman
Oleg Nesterov writes: > On 05/05, Eric W. Biederman wrote: >> >> Eric W. Biederman (11): signal: Rename send_signal send_signal_locked >> signal: Replace __group_send_sig_info with send_signal_locked >> ptrace/um: Replace PT_DTRACE with TIF_SINGLESTEP ptrace/xtensa: &g

[PATCH v4 12/12] sched, signal, ptrace: Rework TASK_TRACED, TASK_STOPPED state

2022-05-05 Thread Eric W. Biederman
in signal_wake_up_state. This prevents the clearing of TASK_STOPPED and TASK_TRACED from getting lost. * Added warnings if JOBCTL_STOPPED or JOBCTL_TRACED are not cleared Signed-off-by: Peter Zijlstra (Intel) Link: https://lkml.kernel.org/r/20220421150654.757693...@infradead.org Signed-off-by: E

[PATCH v4 11/12] ptrace: Always take siglock in ptrace_resume

2022-05-05 Thread Eric W. Biederman
Make code analysis simpler and future changes easier by always taking siglock in ptrace_resume. Signed-off-by: "Eric W. Biederman" --- kernel/ptrace.c | 13 ++--- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/kernel/ptrace.c b/kernel/ptrace.c index 83

[PATCH v4 10/12] ptrace: Don't change __state

2022-05-05 Thread Eric W. Biederman
hen woken up ptrace_stop now clears JOBCTL_PTRACE_FROZEN and when left sleeping ptrace_unfreezed_traced clears JOBCTL_PTRACE_FROZEN. Signed-off-by: "Eric W. Biederman" --- include/linux/sched.h| 2 +- include/linux/sched/jobctl.h | 2 ++ include/linux/sched/signal.h | 5 +++-- ke

[PATCH v4 09/12] ptrace: Admit ptrace_stop can generate spuriuos SIGTRAPs

2022-05-05 Thread Eric W. Biederman
er has set a signal to continue with would need to be implemented. [1] 66519f549ae5 ("[PATCH] fix ptracer death race yielding bogus BUG_ON") History-Tree: https://git.kernel.org/pub/scm/linux/kernel/git/tglx/history.git Signed-off-by: "Eric W.

[PATCH v4 08/12] ptrace: Document that wait_task_inactive can't fail

2022-05-05 Thread Eric W. Biederman
one of the issues. Failing and warning when the assumptions of the code are broken is good. Signed-off-by: "Eric W. Biederman" --- kernel/ptrace.c | 14 +++--- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/kernel/ptrace.c b/kernel/ptrace.c index 7105821595bc

[PATCH v4 07/12] ptrace: Reimplement PTRACE_KILL by always sending SIGKILL

2022-05-05 Thread Eric W. Biederman
user space behavior only in that PTRACE_KILL on a process not stopped in ptrace_stop will also kill it. As that has always been the intent of the code this seems like a reasonable change. Cc: sta...@vger.kernel.org Reported-by: Al Viro Suggested-by: Al Viro Signed-off-by: "Eric W. Biederman&q

[PATCH v4 06/12] signal: Use lockdep_assert_held instead of assert_spin_locked

2022-05-05 Thread Eric W. Biederman
...@hirez.programming.kicks-ass.net Signed-off-by: "Eric W. Biederman" --- kernel/signal.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kernel/signal.c b/kernel/signal.c index 72d96614effc..3fd2ce133387 100644 --- a/kernel/signal.c +++ b/kernel/signal.c @@ -88

[PATCH v4 05/12] ptrace: Remove arch_ptrace_attach

2022-05-05 Thread Eric W. Biederman
e up the thread and enter ptrace_stop normally even when the thread starts out stopped. This makes ptrace_attach_sync_user_rbs completely unnecessary. So just remove it. Cc: linux-i...@vger.kernel.org Signed-off-by: "Eric W. Biederman" --- arch/ia64/include/asm/ptrace.h | 4 ---

[PATCH v4 04/12] ptrace/xtensa: Replace PT_SINGLESTEP with TIF_SINGLESTEP

2022-05-05 Thread Eric W. Biederman
ed but unused. Remove the definitions of PT_SINGLESTEP and PT_BLOCKSTEP as they have no more users. Cc: sta...@vger.kernel.org Acked-by: Max Filippov Signed-off-by: "Eric W. Biederman" --- arch/xtensa/kernel/ptrace.c | 4 ++-- arch/xtensa/kernel/signal.c | 4 ++-- include/linux/p

[PATCH v4 03/12] ptrace/um: Replace PT_DTRACE with TIF_SINGLESTEP

2022-05-05 Thread Eric W. Biederman
ve the definition PT_DTRACE as uml is the last user. Cc: sta...@vger.kernel.org Acked-by: Johannes Berg Signed-off-by: "Eric W. Biederman" --- arch/um/include/asm/thread_info.h | 2 ++ arch/um/kernel/exec.c | 2 +- arch/um/kernel/process.c | 2 +- arch/um

[PATCH v4 01/12] signal: Rename send_signal send_signal_locked

2022-05-05 Thread Eric W. Biederman
Rename send_signal and __send_signal to send_signal_locked and __send_signal_locked to make send_signal usable outside of signal.c. Signed-off-by: "Eric W. Biederman" --- include/linux/signal.h | 2 ++ kernel/signal.c| 24 2 files changed, 14 inserti

[PATCH v4 02/12] signal: Replace __group_send_sig_info with send_signal_locked

2022-05-05 Thread Eric W. Biederman
The function __group_send_sig_info is just a light wrapper around send_signal_locked with one parameter fixed to a constant value. As the wrapper adds no real value update the code to directly call the wrapped function. Signed-off-by: "Eric W. Biederman" --- drivers/tty/tty_jobctrl.

[PATCH v4 0/12] ptrace: cleaning up ptrace_stop

2022-05-05 Thread Eric W. Biederman
ttach I don't think there are any races or issues to be concerned about from the ptrace side. More work is needed to support PREEMPT_RT, but these changes get things closer. This set of changes continues to look like it will provide a firm foundation for solving the PREEMPT_RT and free

Re: [PATCH v3 08/11] ptrace: Admit ptrace_stop can generate spuriuos SIGTRAPs

2022-05-05 Thread Eric W. Biederman
Oleg Nesterov writes: > On 05/04, Eric W. Biederman wrote: >> >> -static int ptrace_stop(int exit_code, int why, int clear_code, >> -unsigned long message, kernel_siginfo_t *info) >> +static int ptrace_stop(int exit_code, int

Re: [PATCH v3 08/11] ptrace: Admit ptrace_stop can generate spuriuos SIGTRAPs

2022-05-05 Thread Eric W. Biederman
Oleg Nesterov writes: > On 05/04, Eric W. Biederman wrote: >> >> With the removal of the incomplete detection of the tracer going away >> in ptrace_stop, ptrace_stop always sleeps in schedule after >> ptrace_freeze_traced succeeds. Modify ptrace_check_attach to &g

Re: [PATCH v3 08/11] ptrace: Admit ptrace_stop can generate spuriuos SIGTRAPs

2022-05-05 Thread Eric W. Biederman
Oleg Nesterov writes: > On 05/04, Eric W. Biederman wrote: >> >> -static int ptrace_stop(int exit_code, int why, int clear_code, >> -unsigned long message, kernel_siginfo_t *info) >> +static int ptrace_stop(int exit_code, int

Re: [PATCH v3 09/11] ptrace: Don't change __state

2022-05-05 Thread Eric W. Biederman
Sebastian Andrzej Siewior writes: > On 2022-05-04 17:40:56 [-0500], Eric W. Biederman wrote: >> Stop playing with tsk->__state to remove TASK_WAKEKILL while a ptrace >> command is executing. >> >> Instead remove TASK_WAKEKILL from the definition of TASK_TRACED, an

[PATCH v3 11/11] sched, signal, ptrace: Rework TASK_TRACED, TASK_STOPPED state

2022-05-04 Thread Eric W. Biederman
in signal_wake_up_state. This prevents the clearing of TASK_STOPPED and TASK_TRACED from getting lost. * Added warnings if JOBCTL_STOPPED or JOBCTL_TRACED are not cleared Signed-off-by: Peter Zijlstra (Intel) Link: https://lkml.kernel.org/r/20220421150654.757693...@infradead.org Signed-off-by: E

[PATCH v3 10/11] ptrace: Always take siglock in ptrace_resume

2022-05-04 Thread Eric W. Biederman
Make code analysis simpler and future changes easier by always taking siglock in ptrace_resume. Signed-off-by: "Eric W. Biederman" --- kernel/ptrace.c | 13 ++--- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/kernel/ptrace.c b/kernel/ptrace.c index 83

[PATCH v3 09/11] ptrace: Don't change __state

2022-05-04 Thread Eric W. Biederman
hen woken up ptrace_stop now clears JOBCTL_PTRACE_FROZEN and when left sleeping ptrace_unfreezed_traced clears JOBCTL_PTRACE_FROZEN. Signed-off-by: "Eric W. Biederman" --- include/linux/sched.h| 2 +- include/linux/sched/jobctl.h | 2 ++ include/linux/sched/signal.h | 5

[PATCH v3 08/11] ptrace: Admit ptrace_stop can generate spuriuos SIGTRAPs

2022-05-04 Thread Eric W. Biederman
9f549ae5 ("[PATCH] fix ptracer death race yielding bogus BUG_ON") History-Tree: https://git.kernel.org/pub/scm/linux/kernel/git/tglx/history.git Signed-off-by: "Eric W. Biederman" --- kernel/ptrace.c | 14 ++--- kernel/signal.c | 81 ++-

[PATCH v3 07/11] ptrace: Reimplement PTRACE_KILL by always sending SIGKILL

2022-05-04 Thread Eric W. Biederman
user space behavior only in that PTRACE_KILL on a process not stopped in ptrace_stop will also kill it. As that has always been the intent of the code this seems like a reasonable change. Cc: sta...@vger.kernel.org Reported-by: Al Viro Suggested-by: Al Viro Signed-off-by: "Eric W. Biederman&q

[PATCH v3 05/11] ptrace: Remove arch_ptrace_attach

2022-05-04 Thread Eric W. Biederman
e up the thread and enter ptrace_stop normally even when the thread starts out stopped. This makes ptrace_attach_sync_user_rbs completely unnecessary. So just remove it. Cc: linux-i...@vger.kernel.org Signed-off-by: "Eric W. Biederman" --- arch/ia64/include/asm/ptrace.h | 4 ---

[PATCH v3 06/11] signal: Use lockdep_assert_held instead of assert_spin_locked

2022-05-04 Thread Eric W. Biederman
...@hirez.programming.kicks-ass.net Signed-off-by: "Eric W. Biederman" --- kernel/signal.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kernel/signal.c b/kernel/signal.c index 72d96614effc..3fd2ce133387 100644 --- a/kernel/signal.c +++ b/kernel/signal.c @@ -88

[PATCH v3 04/11] ptrace/xtensa: Replace PT_SINGLESTEP with TIF_SINGLESTEP

2022-05-04 Thread Eric W. Biederman
ed but unused. Remove the definitions of PT_SINGLESTEP and PT_BLOCKSTEP as they have no more users. Cc: sta...@vger.kernel.org Acked-by: Max Filippov Signed-off-by: "Eric W. Biederman" --- arch/xtensa/kernel/ptrace.c | 4 ++-- arch/xtensa/kernel/signal.c | 4 ++-- include/linux/p

[PATCH v3 03/11] ptrace/um: Replace PT_DTRACE with TIF_SINGLESTEP

2022-05-04 Thread Eric W. Biederman
ve the definition PT_DTRACE as uml is the last user. Cc: sta...@vger.kernel.org Acked-by: Johannes Berg Signed-off-by: "Eric W. Biederman" --- arch/um/include/asm/thread_info.h | 2 ++ arch/um/kernel/exec.c | 2 +- arch/um/kernel/process.c | 2 +- arch/um

[PATCH v3 02/11] signal: Replace __group_send_sig_info with send_signal_locked

2022-05-04 Thread Eric W. Biederman
The function __group_send_sig_info is just a light wrapper around send_signal_locked with one parameter fixed to a constant value. As the wrapper adds no real value update the code to directly call the wrapped function. Signed-off-by: "Eric W. Biederman" --- drivers/tty/tty_jobctrl.

[PATCH v3 01/11] signal: Rename send_signal send_signal_locked

2022-05-04 Thread Eric W. Biederman
Rename send_signal and __send_signal to send_signal_locked and __send_signal_locked to make send_signal usable outside of signal.c. Signed-off-by: "Eric W. Biederman" --- include/linux/signal.h | 2 ++ kernel/signal.c| 24 2 files changed, 14 inserti

[PATCH v3 0/11] ptrace: cleaning up ptrace_stop

2022-05-04 Thread Eric W. Biederman
ved this set of changes looks like it is moving in a good direction. Eric W. Biederman (10): signal: Rename send_signal send_signal_locked signal: Replace __group_send_sig_info with send_signal_locked ptrace/um: Replace PT_DTRACE with TIF_SINGLESTEP ptrace/xtensa: Rep

Re: [PATCH v2 07/12] ptrace: Don't change __state

2022-05-04 Thread Eric W. Biederman
"Eric W. Biederman" writes: > Oleg Nesterov writes: > >> On 05/03, Eric W. Biederman wrote: >>> >>> Oleg Nesterov writes: >>> >>> > But why is it bad if the tracee doesn't sleep in schedule ? If it races >>> > wi

Re: [PATCH v2 07/12] ptrace: Don't change __state

2022-05-04 Thread Eric W. Biederman
Oleg Nesterov writes: > On 05/03, Eric W. Biederman wrote: >> >> Oleg Nesterov writes: >> >> > But why is it bad if the tracee doesn't sleep in schedule ? If it races >> > with SIGKILL. I still can't understand this. >> > >

Re: [PATCH v2 07/12] ptrace: Don't change __state

2022-05-03 Thread Eric W. Biederman
Oleg Nesterov writes: > On 05/02, Eric W. Biederman wrote: >> >> Oleg Nesterov writes: >> >> >> #define TASK_KILLABLE(TASK_WAKEKILL | >> >> TASK_UNINTERRUPTIBLE) >> >> #define TASK_STOPPED (T

Re: [PATCH v2 06/12] ptrace: Reimplement PTRACE_KILL by always sending SIGKILL

2022-05-03 Thread Eric W. Biederman
Oleg Nesterov writes: > On 04/29, Eric W. Biederman wrote: >> >> Call send_sig_info in PTRACE_KILL instead of ptrace_resume. Calling >> ptrace_resume is not safe to call if the task has not been stopped >> with ptrace_freeze_traced. > > Oh, I was never, never

Re: [PATCH v2 07/12] ptrace: Don't change __state

2022-05-02 Thread Eric W. Biederman
Oleg Nesterov writes: > On 04/29, Eric W. Biederman wrote: >> >> Stop playing with tsk->__state to remove TASK_WAKEKILL while a ptrace >> command is executing. > > Eric, I'll read this patch and the rest of this series tomorrow. > Somehow I failed to fo

[PATCH v2 12/12] sched, signal, ptrace: Rework TASK_TRACED, TASK_STOPPED state

2022-04-29 Thread Eric W. Biederman
s prevents the clearing of TASK_STOPPED and TASK_TRACED from getting lost. * Added warnings if JOBCTL_STOPPED or JOBCTL_TRACED are not cleared Signed-off-by: Peter Zijlstra (Intel) Link: https://lkml.kernel.org/r/20220421150654.757693...@infradead.org Signed-off-by: Eric W. Biederm

[PATCH v2 11/12] ptrace: Always call schedule in ptrace_stop

2022-04-29 Thread Eric W. Biederman
cceeds modify ptrace_check_attach to warn if wait_task_inactive fails. Signed-off-by: "Eric W. Biederman" --- kernel/ptrace.c | 14 +++--- kernel/signal.c | 68 ++--- 2 files changed, 28 insertions(+), 54 deletions(-) diff --git a/kernel/p

[PATCH v2 10/12] ptrace: Only return signr from ptrace_stop if it was provided

2022-04-29 Thread Eric W. Biederman
new flag to decided how to set return signal. Signed-off-by: "Eric W. Biederman" --- include/linux/sched/jobctl.h | 2 ++ kernel/ptrace.c | 5 + kernel/signal.c | 12 ++-- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/include/l

[PATCH v2 09/12] ptrace: Always take siglock in ptrace_resume

2022-04-29 Thread Eric W. Biederman
Make code analysis simpler and future changes easier by always taking siglock in ptrace_resume. Signed-off-by: "Eric W. Biederman" --- kernel/ptrace.c | 13 ++--- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/kernel/ptrace.c b/kernel/ptrace.c index 22

[PATCH v2 08/12] ptrace: Remove arch_ptrace_attach

2022-04-29 Thread Eric W. Biederman
e up the thread and enter ptrace_stop normally even when the thread starts out stopped. This makes ptrace_attach_sync_user_rbs completely unnecessary. So just remove it. Cc: linux-i...@vger.kernel.org Signed-off-by: "Eric W. Biederman" --- arch/ia64/include/asm/ptrace.h | 4 ---

[PATCH v2 07/12] ptrace: Don't change __state

2022-04-29 Thread Eric W. Biederman
w clears JOBCTL_PTRACE_FROZEN and when left sleeping ptrace_unfreezed_traced clears JOBCTL_PTRACE_FROZEN. Signed-off-by: "Eric W. Biederman" --- include/linux/sched.h| 2 +- include/linux/sched/jobctl.h | 2 ++ include/linux/sched/signal.h | 8 +++- kernel/ptrace.c

[PATCH v2 06/12] ptrace: Reimplement PTRACE_KILL by always sending SIGKILL

2022-04-29 Thread Eric W. Biederman
Call send_sig_info in PTRACE_KILL instead of ptrace_resume. Calling ptrace_resume is not safe to call if the task has not been stopped with ptrace_freeze_traced. Cc: sta...@vger.kernel.org Reported-by: Al Viro Suggested-by: Al Viro Signed-off-by: "Eric W. Biederman" --- kernel/pt

[PATCH v2 05/12] signal: Use lockdep_assert_held instead of assert_spin_locked

2022-04-29 Thread Eric W. Biederman
...@hirez.programming.kicks-ass.net Signed-off-by: "Eric W. Biederman" --- kernel/signal.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kernel/signal.c b/kernel/signal.c index 72d96614effc..3fd2ce133387 100644 --- a/kernel/signal.c +++ b/kernel/signal.c @@ -88

[PATCH v2 04/12] ptrace/xtensa: Replace PT_SINGLESTEP with TIF_SINGLESTEP

2022-04-29 Thread Eric W. Biederman
ed but unused. Remove the definitions of PT_SINGLESTEP and PT_BLOCKSTEP as they have no more users. Cc: sta...@vger.kernel.org Acked-by: Max Filippov Signed-off-by: "Eric W. Biederman" --- arch/xtensa/kernel/ptrace.c | 4 ++-- arch/xtensa/kernel/signal.c | 4 ++-- include/linux/p

[PATCH v2 03/12] ptrace/um: Replace PT_DTRACE with TIF_SINGLESTEP

2022-04-29 Thread Eric W. Biederman
ve the definition PT_DTRACE as uml is the last user. Cc: sta...@vger.kernel.org Acked-by: Johannes Berg Signed-off-by: "Eric W. Biederman" --- arch/um/include/asm/thread_info.h | 2 ++ arch/um/kernel/exec.c | 2 +- arch/um/kernel/process.c | 2 +- arch/um

[PATCH v2 02/12] signal: Replace __group_send_sig_info with send_signal_locked

2022-04-29 Thread Eric W. Biederman
The function send_signal_locked does more than __group_send_sig_info so replace it. Signed-off-by: "Eric W. Biederman" --- drivers/tty/tty_jobctrl.c | 4 ++-- include/linux/signal.h | 1 - kernel/signal.c| 8 +--- kernel/time/posix-cpu-timers.c | 6

[PATCH v2 01/12] signal: Rename send_signal send_signal_locked

2022-04-29 Thread Eric W. Biederman
Rename send_signal send_signal_locked and make to make it usable outside of signal.c. Signed-off-by: "Eric W. Biederman" --- include/linux/signal.h | 2 ++ kernel/signal.c| 24 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/inc

[PATCH 0/12] ptrace: cleaning up ptrace_stop

2022-04-29 Thread Eric W. Biederman
nges and then have a firm foundation for the rest of the challenges. There are cleanups to the ptrace support for xtensa, um, and ia64. I have sucked in the first patch of Peter's freezer change as with minor modifications I believe it is ready to go. Eric W. Biederman (12): signal:

Re: [PATCH 6/9] signal: Always call do_notify_parent_cldstop with siglock held

2022-04-28 Thread Eric W. Biederman
"Eric W. Biederman" writes: > Peter Zijlstra writes: > >> On Wed, Apr 27, 2022 at 09:47:10AM -0500, Eric W. Biederman wrote: >> >>> Hmm. If we have the following process tree. >>> >>> A >>> \ >>> B &g

Re: [PATCH 6/9] signal: Always call do_notify_parent_cldstop with siglock held

2022-04-28 Thread Eric W. Biederman
Peter Zijlstra writes: > On Wed, Apr 27, 2022 at 09:47:10AM -0500, Eric W. Biederman wrote: > >> Hmm. If we have the following process tree. >> >> A >> \ >> B >>\ >> C >> >> Process A, B, and C are al

Re: [PATCH 9/9] ptrace: Don't change __state

2022-04-28 Thread Eric W. Biederman
Oleg Nesterov writes: > On 04/27, Eric W. Biederman wrote: >> >> "Eric W. Biederman" writes: >> >> > diff --git a/include/linux/sched/signal.h b/include/linux/sched/signal.h >> > index 3c8b34876744..1947c85aa9d9 100644 >> > --- a/i

Re: [PATCH 9/9] ptrace: Don't change __state

2022-04-27 Thread Eric W. Biederman
"Eric W. Biederman" writes: > diff --git a/include/linux/sched/signal.h b/include/linux/sched/signal.h > index 3c8b34876744..1947c85aa9d9 100644 > --- a/include/linux/sched/signal.h > +++ b/include/linux/sched/signal.h > @@ -437,7 +437,8 @@ extern void signal_wake_up_st

Re: [PATCH 9/9] ptrace: Don't change __state

2022-04-27 Thread Eric W. Biederman
Oleg Nesterov writes: 2> On 04/26, Eric W. Biederman wrote: >> >> static void ptrace_unfreeze_traced(struct task_struct *task) >> { >> -if (READ_ONCE(task->__state) != __TASK_TRACED) >> +if (!(READ_ONCE(task->jobctl) & JOBCTL_DELAY_WAKEKILL))

Re: [PATCH 6/9] signal: Always call do_notify_parent_cldstop with siglock held

2022-04-27 Thread Eric W. Biederman
Oleg Nesterov writes: > On 04/27, Oleg Nesterov wrote: >> >> On 04/26, Eric W. Biederman wrote: >> > >> > @@ -2209,6 +2213,34 @@ static int ptrace_stop(int exit_code, int why, int >> > clear_code, >> >spin_lock_irq(¤t->sigh

Re: [PATCH 9/9] ptrace: Don't change __state

2022-04-27 Thread Eric W. Biederman
Oleg Nesterov writes: > On 04/27, Oleg Nesterov wrote: >> >> On 04/27, Eric W. Biederman wrote: >> > >> > Oleg Nesterov writes: >> > >> > > On 04/26, Eric W. Biederman wrote: >> > >> >> > >> @@ -253,7 +252,7 @@

Re: [PATCH 9/9] ptrace: Don't change __state

2022-04-27 Thread Eric W. Biederman
Oleg Nesterov writes: > On 04/26, Eric W. Biederman wrote: >> >> @@ -253,7 +252,7 @@ static int ptrace_check_attach(struct task_struct >> *child, bool ignore_state) >> */ >> if (lock_task_sighand(child, &flags)) { >> if

Re: [PATCH 6/9] signal: Always call do_notify_parent_cldstop with siglock held

2022-04-27 Thread Eric W. Biederman
"Eric W. Biederman" writes: > Oleg Nesterov writes: > >> On 04/26, Eric W. Biederman wrote: >>> >>> @@ -2164,7 +2166,9 @@ static void do_notify_parent_cldstop(struct >>> task_struct *tsk, >>> } >>> >>> s

Re: [PATCH 7/9] ptrace: Simplify the wait_task_inactive call in ptrace_check_attach

2022-04-27 Thread Eric W. Biederman
"Eric W. Biederman" writes: > "Eric W. Biederman" writes: > >> Asking wait_task_inactive to verify that tsk->__state == __TASK_TRACED >> was needed to detect the when ptrace_stop would decide not to stop >> after calling "set_special_state(TAS

Re: [PATCH 6/9] signal: Always call do_notify_parent_cldstop with siglock held

2022-04-27 Thread Eric W. Biederman
Oleg Nesterov writes: > On 04/26, Eric W. Biederman wrote: >> >> @@ -2164,7 +2166,9 @@ static void do_notify_parent_cldstop(struct >> task_struct *tsk, >> } >> >> sighand = parent->sighand; >> -spin_lock_irqsave(&sighand->

Re: [PATCH 3/9] ptrace/um: Replace PT_DTRACE with TIF_SINGLESTEP

2022-04-27 Thread Eric W. Biederman
Johannes Berg writes: > On Tue, 2022-04-26 at 17:52 -0500, Eric W. Biederman wrote: >> User mode linux is the last user of the PT_DTRACE flag. Using the flag to >> indicate >> single stepping is a little confusing and worse changing tsk->ptrace without >> lockin

  1   2   >