linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Oleg Nesterov <oleg@redhat.com>
To: Elvira Khabirova <lineprinter@altlinux.org>
Cc: rostedt@goodmis.org, mingo@redhat.com,
	linux-kernel@vger.kernel.org, ldv@altlinux.org, esyr@redhat.com,
	luto@kernel.org, strace-devel@lists.strace.io,
	linux-api@vger.kernel.org
Subject: Re: [RFC PATCH RESEND v3 3/3] ptrace: add PTRACE_EVENT_SECCOMP support to PTRACE_GET_SYSCALL_INFO
Date: Mon, 26 Nov 2018 15:35:24 +0100	[thread overview]
Message-ID: <20181126143524.GB1660@redhat.com> (raw)
In-Reply-To: <20181125022340.5703400f@akathisia>

On 11/25, Elvira Khabirova wrote:
>
> Extend PTRACE_GET_SYSCALL_INFO to support PTRACE_EVENT_SECCOMP stops.
> The information returned is the same as for syscall-enter-stops.

Oh, this is not nice ;) there must be a better option, I hope... Plus


Can't ptrace_get_syscall() check

	child->exit_code == (PTRACE_EVENT_SECCOMP << 8) | SIGTRAP;

to detect the PTRACE_EVENT_SECCOMP case?

Oleg.

> Signed-off-by: Elvira Khabirova <lineprinter@altlinux.org>
> Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
> ---
>  include/linux/ptrace.h    | 1 +
>  include/linux/sched.h     | 1 +
>  include/linux/tracehook.h | 1 +
>  kernel/ptrace.c           | 7 +++++--
>  4 files changed, 8 insertions(+), 2 deletions(-)
> 
> diff --git a/include/linux/ptrace.h b/include/linux/ptrace.h
> index 6c2ffed907f5..a993d0fde865 100644
> --- a/include/linux/ptrace.h
> +++ b/include/linux/ptrace.h
> @@ -166,6 +166,7 @@ static inline void ptrace_event(int event, unsigned long message)
>  {
>  	if (unlikely(ptrace_event_enabled(current, event))) {
>  		current->ptrace_message = message;
> +		current->ptrace_event = event;
>  		ptrace_notify((event << 8) | SIGTRAP);
>  	} else if (event == PTRACE_EVENT_EXEC) {
>  		/* legacy EXEC report via SIGTRAP */
> diff --git a/include/linux/sched.h b/include/linux/sched.h
> index a51c13c2b1a0..86215fb654d6 100644
> --- a/include/linux/sched.h
> +++ b/include/linux/sched.h
> @@ -964,6 +964,7 @@ struct task_struct {
>  
>  	/* Ptrace state: */
>  	unsigned long			ptrace_message;
> +	int				ptrace_event;
>  	kernel_siginfo_t		*last_siginfo;
>  
>  	struct task_io_accounting	ioac;
> diff --git a/include/linux/tracehook.h b/include/linux/tracehook.h
> index 633a83fe7051..5d2e5aa07a5c 100644
> --- a/include/linux/tracehook.h
> +++ b/include/linux/tracehook.h
> @@ -66,6 +66,7 @@ static inline int ptrace_report_syscall(struct pt_regs *regs,
>  		return 0;
>  
>  	current->ptrace_message = message;
> +	current->ptrace_event = 0;
>  	ptrace_notify(SIGTRAP | ((ptrace & PT_TRACESYSGOOD) ? 0x80 : 0));
>  
>  	/*
> diff --git a/kernel/ptrace.c b/kernel/ptrace.c
> index 92c47cd5ad84..74a37e74c7f1 100644
> --- a/kernel/ptrace.c
> +++ b/kernel/ptrace.c
> @@ -904,7 +904,9 @@ static int ptrace_get_syscall(struct task_struct *child,
>  	unsigned long actual_size;
>  	unsigned long write_size;
>  
> -	if (child->ptrace_message == PTRACE_EVENTMSG_SYSCALL_ENTRY) {
> +	if ((child->ptrace_event == 0 &&
> +	     child->ptrace_message == PTRACE_EVENTMSG_SYSCALL_ENTRY) ||
> +	    child->ptrace_event == PTRACE_EVENT_SECCOMP) {
>  		int i;
>  
>  		info.op = PTRACE_SYSCALL_INFO_ENTRY;
> @@ -917,7 +919,8 @@ static int ptrace_get_syscall(struct task_struct *child,
>  		for (i = 0; i < ARRAY_SIZE(args); i++)
>  			info.entry.args[i] = args[i];
>  		actual_size = offsetofend(struct ptrace_syscall_info, entry);
> -	} else if (child->ptrace_message == PTRACE_EVENTMSG_SYSCALL_EXIT) {
> +	} else if (child->ptrace_event == 0 &&
> +		   child->ptrace_message == PTRACE_EVENTMSG_SYSCALL_EXIT) {
>  		info.op = PTRACE_SYSCALL_INFO_EXIT;
>  		info.arch = syscall_get_arch(child);
>  		info.exit.rval = syscall_get_error(child, regs);
> -- 
> 2.19.1
> 


  reply	other threads:[~2018-11-26 14:35 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-25  1:21 [PATCH RESEND v3 0/3] ptrace: add PTRACE_GET_SYSCALL_INFO request Elvira Khabirova
2018-11-25  1:22 ` [PATCH RESEND v3 1/3] ptrace: pass type of a syscall-stop in ptrace_message Elvira Khabirova
2018-11-25  1:54   ` Joey Pabalinas
2018-11-25  2:10     ` Dmitry V. Levin
2018-11-25  6:17       ` Joey Pabalinas
2018-11-26 14:56   ` Oleg Nesterov
2018-11-27  2:53     ` Elvira Khabirova
2018-11-27  3:48       ` Dmitry V. Levin
2018-11-25  1:23 ` [PATCH RESEND v3 2/3] ptrace: add PTRACE_GET_SYSCALL_INFO request Elvira Khabirova
2018-11-25  1:23 ` [RFC PATCH RESEND v3 3/3] ptrace: add PTRACE_EVENT_SECCOMP support to PTRACE_GET_SYSCALL_INFO Elvira Khabirova
2018-11-26 14:35   ` Oleg Nesterov [this message]
2018-11-27  3:07     ` Elvira Khabirova
2018-11-27  3:21       ` Dmitry V. Levin
2018-11-27 12:31       ` Oleg Nesterov
2018-11-27 23:27         ` Dmitry V. Levin
2018-11-28 12:35           ` Oleg Nesterov
2018-11-28 12:44             ` Dmitry V. Levin
2018-11-28 13:13               ` Oleg Nesterov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20181126143524.GB1660@redhat.com \
    --to=oleg@redhat.com \
    --cc=esyr@redhat.com \
    --cc=ldv@altlinux.org \
    --cc=lineprinter@altlinux.org \
    --cc=linux-api@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luto@kernel.org \
    --cc=mingo@redhat.com \
    --cc=rostedt@goodmis.org \
    --cc=strace-devel@lists.strace.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).