Skip to content

RFC ptrace: introduce task_struct->ptrace_cxt

Oleg Nesterov lkml 2 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v3 RFC Latest12 patches 1 replyIn review
  2. v2 RFC12 patches 15 repliesSuperseded

Changes from the cover letter · 43 lines

	04/12:	move kfree() outside of task_lock() in alloc_ptrace_context().
		But I misread your sugesstion:

			>       task_lock(tsk);
			>       if (likely(!tsk->ptrace_ctx)) {
			>               tsk->ptrace_ctx = ptrace_ctx;
			>               task_unlock(tsk);
			>               return 0;
			>       }
			>
			>       task_unlock(tsk);
			>       kfree(ptrace_ctx);

		Just can't do that. I hate multiple unlocks very much. So it
		becomes:

			task_lock(tsk);
			if (likely(!tsk->ptrace_ctx)) {
				tsk->ptrace_ctx = ptrace_ctx;
				ptrace_ctx = NULL;
			}
			task_unlock(tsk);
			kfree(ptrace_ctx);

		kfree(NULL) is specially allowed.


	05/12:	Add the comment about tracehook_init_task to ptrace_init_task().

		I didn't change the original comment, but imho it is confusing.
		"immediately after adding @child to its parent's children list"
		does not matter. What does matter, is that it is called before
		this child is visible to the user-space and thus the unconditional
		ptrace_link() is safe: nobody could attach before us.


	08/12:	No changes, but I think it better to change format_mca_init_stack()
		right now. Imho it has nothing to do with tracehooks and it is the
		last user of ->parent (except perhaps there are some in arch/ code
		which should be tracehookfied).


	09/12:	Remove the stale "pt_" from the changelog.

Patches in v3 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/12ptrace: ptrace_signal: fix the usage of ->parentkernel/signal.c+13 -20 replies
2/12ptrace: tracehooks: do not use task->ptrace directlyinclude/linux/tracehook.h+9 -70 replies
3/12ptrace: avoid using task->ptrace when possible in ptrace.{c,h}include/linux/ptrace.h kernel/ptrace.c+31 -280 replies
4/12ptrace: introduce the empty "struct ptrace_context"include/linux/ptrace.h include/linux/sched.h include/linux/tracehook.h +2 more+80 -10 replies
5/12ptrace: kill the now unneeded args from tracehook_finish_clone() pathinclude/linux/ptrace.h include/linux/tracehook.h kernel/fork.c+7 -120 replies
6/12ptrace: mv task_struct->ptrace ptrace_ctx->flags, kill ptrace_link()include/linux/ptrace.h include/linux/sched.h kernel/ptrace.c+17 -240 replies
7/12ptrace: change __ptrace_link() to set ->flags, rename to ptrace_link()include/linux/ptrace.h kernel/ptrace.c+16 -200 replies
8/12ptrace: mv task->parent ptrace_ctx->tracerarch/ia64/kernel/mca.c include/linux/init_task.h include/linux/ptrace.h +5 more+32 -350 replies
9/12ptrace: introduce ptrace_tracer() helperinclude/linux/ptrace.h kernel/ptrace.c kernel/signal.c+22 -170 replies
10/12ptrace: mv task_struct->last_siginfo ptrace_ctx->infopinclude/linux/ptrace.h include/linux/sched.h kernel/ptrace.c +1 more+9 -90 replies
11/12ptrace: mv task_struct->ptrace_message ptrace_ctx->messageinclude/linux/ptrace.h include/linux/sched.h kernel/ptrace.c+6 -40 replies
12/12ptrace: mv task_struct->ptrace_entry ptrace_ctx->entryinclude/linux/init_task.h include/linux/ptrace.h include/linux/sched.h +2 more+19 -190 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v3 yet.

Read the v3 thread

Cover letter [RFC PATCH 00/12 v3] ptrace: introduce task_struct->ptrace_cxt

Changes:

	04/12:	move kfree() outside of task_lock() in alloc_ptrace_context().
		But I misread your sugesstion:

			>       task_lock(tsk);
			>       if (likely(!tsk->ptrace_ctx)) {
			>               tsk->ptrace_ctx = ptrace_ctx;
			>               task_unlock(tsk);
			>               return 0;
			>       }
			>
			>       task_unlock(tsk);
			>       kfree(ptrace_ctx);

		Just can't do that. I hate multiple unlocks very much. So it
		becomes:

			task_lock(tsk);
			if (likely(!tsk->ptrace_ctx)) {
				tsk->ptrace_ctx = ptrace_ctx;
				ptrace_ctx = NULL;
			}
			task_unlock(tsk);
			kfree(ptrace_ctx);

		kfree(NULL) is specially allowed.


	05/12:	Add the comment about tracehook_init_task to ptrace_init_task().

		I didn't change the original comment, but imho it is confusing.
		"immediately after adding @child to its parent's children list"
		does not matter. What does matter, is that it is called before
		this child is visible to the user-space and thus the unconditional
		ptrace_link() is safe: nobody could attach before us.


	08/12:	No changes, but I think it better to change format_mca_init_stack()
		right now. Imho it has nothing to do with tracehooks and it is the
		last user of ->parent (except perhaps there are some in arch/ code
		which should be tracehookfied).


	09/12:	Remove the stale "pt_" from the changelog.

Oleg.