linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Oleg Nesterov <oleg@redhat.com>
To: Andy Lutomirski <luto@amacapital.net>
Cc: Elvira Khabirova <lineprinter@altlinux.org>,
	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
Subject: Re: [RFC PATCH] ptrace: add PTRACE_GET_SYSCALL_INFO request
Date: Wed, 7 Nov 2018 17:44:44 +0100	[thread overview]
Message-ID: <20181107164443.GA8726@redhat.com> (raw)
In-Reply-To: <3BDB914D-12F3-4703-A033-EBE02226EC45@amacapital.net>

On 11/07, Andy Lutomirski wrote:
>
>
> > On Nov 7, 2018, at 3:21 AM, Oleg Nesterov <oleg@redhat.com> wrote:
> >
> >> On 11/07, Elvira Khabirova wrote:
> >>
> >> In short, if a 64-bit task performs a syscall through int 0x80, its tracer
> >> has no reliable means to find out that the syscall was, in fact,
> >> a compat syscall, and misidentifies it.
> >> * Syscall-enter-stop and syscall-exit-stop look the same for the tracer.
> >
> > Yes, this was discussed many times...
> >
> > So perhaps it makes sense to encode compat/is_enter in ->ptrace_message,
> > debugger can use PTRACE_GETEVENTMSG to get this info.
>
> As I said before, I strongly object to the use of “compat” here.

Not sure I understand you... I do not like "compat" too, but this patch uses
is_compat/etc and I agree with any naming.

> >> Secondly, ptracers also have to support a lot of arch-specific code for
> >> obtaining information about the tracee. For some architectures, this
> >> requires a ptrace(PTRACE_PEEKUSER, ...) invocation for every syscall
> >> argument and return value.
> >
> > I am not sure about this change... I won't really argue, but imo this
> > needs a separate patch.
>
> Why?  Having a single struct that the tracer can read to get the full state is extremely helpful.

As I said, I won't argue, but why can't it come as a separate change?

More info in ->ptrace_message looks usable even without PTRACE_GET_SYSCALL_INFO,
while ptrace_syscall_info layout/API may need more discussion.

> Also, we really want it to work for seccomp events as well as PTRACE_SYSCALL, and the event info trick doesn’t make sense for seccomp events.

I too thought about PTRACE_EVENT_SECCOMP (or I misunderstoo you?), looks like
another reason to make a separate patch.

> >> +#define PT_IN_SYSCALL_STOP    0x00000004    /* task is in a syscall-stop */
> > ...
> >> -static inline int ptrace_report_syscall(struct pt_regs *regs)
> >> +static inline int ptrace_report_syscall(struct pt_regs *regs,
> >> +                    unsigned long message)
> >> {
> >>    int ptrace = current->ptrace;
> >>
> >>    if (!(ptrace & PT_PTRACED))
> >>        return 0;
> >> +    current->ptrace |= PT_IN_SYSCALL_STOP;
> >>
> >> +    current->ptrace_message = message;
> >>    ptrace_notify(SIGTRAP | ((ptrace & PT_TRACESYSGOOD) ? 0x80 : 0));
> >>
> >>    /*
> >> @@ -76,6 +79,7 @@ static inline int ptrace_report_syscall(struct pt_regs *regs)
> >>        current->exit_code = 0;
> >>    }
> >>
> >> +    current->ptrace &= ~PT_IN_SYSCALL_STOP;
> >>    return fatal_signal_pending(current);
> > ...
> >
> >> +    case PTRACE_GET_SYSCALL_INFO:
> >> +        if (child->ptrace & PT_IN_SYSCALL_STOP)
> >> +            ret = ptrace_get_syscall(child, datavp);
> >> +        break;
> >
> > Why? If debugger uses PTRACE_O_TRACESYSGOOD it can know if the tracee reported
> > syscall entry/exit or not. PTRACE_GET_SYSCALL_INFO is pointless if not, but
> > nothing bad can happen.
>
> I think it’s considerably nicer to the user to avoid reporting garbage if the user misused the API.  (And Elvira got this right in the patch — I just missed it.)

To me PT_IN_SYSCALL_STOP makes no real sense, but I won't argue.

At least I'd ask to not abuse task->ptrace. ptrace_report_syscall() can clear
->ptrace_message on exit if we really want PTRACE_GET_SYSCALL_INFO to fail after
that.

Oleg.


  reply	other threads:[~2018-11-07 16:44 UTC|newest]

Thread overview: 84+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-07  3:27 Elvira Khabirova
2018-11-07 11:21 ` Oleg Nesterov
2018-11-07 14:06   ` Andy Lutomirski
2018-11-07 16:44     ` Oleg Nesterov [this message]
2018-11-07 20:02       ` Elvira Khabirova
2018-11-08  9:16         ` Oleg Nesterov
2018-11-07 20:20       ` Andy Lutomirski
2018-11-08 14:33         ` Oleg Nesterov
2018-11-07 16:12   ` Dmitry V. Levin
2018-11-07 15:50 ` Dmitry V. Levin
2018-11-07 20:44 ` Andy Lutomirski
2018-11-09  3:13   ` [PATCH 00/13] Prepare for PTRACE_GET_SYSCALL_INFO Dmitry V. Levin
2018-11-09  3:15     ` [PATCH 01/13] Move EM_HEXAGON to uapi/linux/elf-em.h Dmitry V. Levin
2018-11-09  3:15     ` [PATCH 02/13] elf-em.h: add EM_ARC Dmitry V. Levin
2018-11-09 14:20       ` Alexey Brodkin
2018-11-09 16:41       ` Vineet Gupta
2018-11-09 21:44         ` Dmitry V. Levin
2018-11-09 23:33           ` [PATCH 02/13 v2] Move EM_ARCOMPACT and EM_ARCV2 to uapi/linux/elf-em.h Dmitry V. Levin
2018-11-09 23:42             ` Vineet Gupta
2018-11-09  3:15     ` [PATCH 03/13] elf-em.h: add EM_NDS32 Dmitry V. Levin
2018-11-09  3:15     ` [PATCH 04/13] elf-em.h: add EM_XTENSA Dmitry V. Levin
2018-11-09  6:45       ` Max Filippov
2018-11-09  3:15     ` [PATCH 05/13] m68k: define syscall_get_arch() Dmitry V. Levin
2018-11-09  3:16     ` [PATCH 06/13] arc: " Dmitry V. Levin
2018-11-09 14:22       ` Alexey Brodkin
2018-11-09 15:17         ` Andy Lutomirski
2018-11-09 15:27           ` Alexey Brodkin
2018-11-09 15:56             ` Andy Lutomirski
2018-11-09 16:11               ` Alexey Brodkin
2018-11-09 16:35                 ` Andy Lutomirski
2018-11-09 23:33                   ` [PATCH 06/13 v2] " Dmitry V. Levin
2018-11-09 23:39                     ` Vineet Gupta
2018-11-09 23:54                       ` [PATCH 06/13 v3] " Dmitry V. Levin
2018-11-10  0:06                         ` Vineet Gupta
2018-11-09 16:50       ` [PATCH 06/13] " Vineet Gupta
2018-11-09 19:03         ` Andy Lutomirski
2018-11-09 19:13           ` Vineet Gupta
2018-11-09  3:16     ` [PATCH 07/13] c6x: " Dmitry V. Levin
2018-11-10  2:01       ` [PATCH 07/13 v2] " Dmitry V. Levin
2018-11-09  3:16     ` [PATCH 08/13] h8300: " Dmitry V. Levin
2018-11-09  3:16     ` [PATCH 09/13] hexagon: " Dmitry V. Levin
2018-11-09  3:16     ` [PATCH 10/13] nds32: " Dmitry V. Levin
2018-11-10  2:01       ` [PATCH 10/13 v2] " Dmitry V. Levin
2018-11-09  3:17     ` [PATCH 11/13] nios2: " Dmitry V. Levin
2018-11-09  3:17     ` [PATCH 12/13] riscv: " Dmitry V. Levin
2018-11-09  6:59       ` David Abdurachmanov
2018-11-09 22:28         ` Dmitry V. Levin
2018-11-10  5:12           ` David Abdurachmanov
2018-11-10  9:27           ` Andreas Schwab
2018-11-09 18:45       ` Palmer Dabbelt
2018-11-09 21:31         ` Dmitry V. Levin
2018-11-09 22:48           ` [PATCH 12/13 v2] " Dmitry V. Levin
2018-11-11 21:21             ` Palmer Dabbelt
2018-11-09  3:17     ` [PATCH 13/13] xtensa: " Dmitry V. Levin
2018-11-09  6:48       ` Max Filippov
2018-11-09  6:06     ` [PATCH 00/13] Prepare for PTRACE_GET_SYSCALL_INFO Andy Lutomirski
2018-11-10 14:09     ` [PATCH 14/13] Move EM_UNICORE to uapi/linux/elf-em.h Dmitry V. Levin
2018-11-10 14:10     ` [PATCH 15/13] unicore32: define syscall_get_arch() Dmitry V. Levin
2018-11-13  3:38   ` [RFC PATCH] ptrace: add PTRACE_GET_SYSCALL_INFO request Dmitry V. Levin
2018-11-20  0:11   ` [PATCH v2 00/15] Prepare for PTRACE_GET_SYSCALL_INFO Dmitry V. Levin
2018-11-20  0:14     ` [PATCH v2 01/15] Move EM_HEXAGON to uapi/linux/elf-em.h Dmitry V. Levin
2018-11-20  0:14     ` [PATCH v2 02/15] Move EM_ARCOMPACT and EM_ARCV2 " Dmitry V. Levin
2018-11-20  0:14     ` [PATCH v2 03/15] Move EM_UNICORE " Dmitry V. Levin
2018-11-20  0:15     ` [PATCH v2 04/15] elf-em.h: add EM_NDS32 Dmitry V. Levin
2018-11-20  0:15     ` [PATCH v2 05/15] elf-em.h: add EM_XTENSA Dmitry V. Levin
2018-11-20  0:15     ` [PATCH v2 06/15] m68k: define syscall_get_arch() Dmitry V. Levin
2018-12-02 10:29       ` Geert Uytterhoeven
2018-12-03  0:24         ` Dmitry V. Levin
2018-12-03  7:36           ` Geert Uytterhoeven
2018-11-20  0:15     ` [PATCH v2 07/15] arc: " Dmitry V. Levin
2018-11-20  0:15     ` [PATCH v2 08/15] c6x: " Dmitry V. Levin
2018-11-20  0:16     ` [PATCH v2 09/15] h8300: " Dmitry V. Levin
2018-11-20  0:16     ` [PATCH v2 10/15] hexagon: " Dmitry V. Levin
2018-11-20  0:16     ` [PATCH v2 11/15] nds32: " Dmitry V. Levin
2018-11-20  0:16     ` [PATCH v2 12/15] nios2: " Dmitry V. Levin
2018-11-20  0:16     ` [PATCH v2 13/15] riscv: " Dmitry V. Levin
2018-11-20  0:16     ` [PATCH v2 14/15] unicore32: " Dmitry V. Levin
2018-11-20  0:17     ` [PATCH v2 15/15] xtensa: " Dmitry V. Levin
2018-11-20 20:26     ` [PATCH v2 00/15] Prepare for PTRACE_GET_SYSCALL_INFO Paul Moore
     [not found]     ` <20181121004422.GA29053@altlinux.org>
     [not found]       ` <20181121184004.jro532jopnbmru2m@pburton-laptop>
2018-11-21 19:00         ` [PATCH v2 16/15] syscall_get_arch: add "struct task_struct *" argument Dmitry V. Levin
2018-11-21 19:14           ` [PATCH] mips: fix mips_get_syscall_arg o32 check Dmitry V. Levin
2018-11-21 19:23             ` Paul Burton
2018-11-21 19:35           ` [PATCH v2 16/15 v2] syscall_get_arch: add "struct task_struct *" argument Dmitry V. Levin
2018-11-21 19:45             ` Paul Burton

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=20181107164443.GA8726@redhat.com \
    --to=oleg@redhat.com \
    --cc=esyr@redhat.com \
    --cc=ldv@altlinux.org \
    --cc=lineprinter@altlinux.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luto@amacapital.net \
    --cc=luto@kernel.org \
    --cc=mingo@redhat.com \
    --cc=rostedt@goodmis.org \
    --cc=strace-devel@lists.strace.io \
    --subject='Re: [RFC PATCH] ptrace: add PTRACE_GET_SYSCALL_INFO request' \
    /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

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).