All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andy Lutomirski <luto@kernel.org>
To: "Dmitry V. Levin" <ldv@altlinux.org>
Cc: paul.burton@mips.com, Ralf Baechle <ralf@linux-mips.org>,
	jhogan@kernel.org, Oleg Nesterov <oleg@redhat.com>,
	Andrew Lutomirski <luto@kernel.org>,
	Elvira Khabirova <lineprinter@altlinux.org>,
	Eugene Syromiatnikov <esyr@redhat.com>,
	Kees Cook <keescook@chromium.org>, Jann Horn <jannh@google.com>,
	Linux API <linux-api@vger.kernel.org>,
	strace-devel@lists.strace.io, LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v5 24/25] ptrace: add PTRACE_GET_SYSCALL_INFO request
Date: Mon, 10 Dec 2018 11:38:17 -0800	[thread overview]
Message-ID: <CALCETrV4J8+_gSHONAcQHt6XFgtuW487b9DHZ8MV-xa6XhZ_Og@mail.gmail.com> (raw)
In-Reply-To: <20181210160940.GF14149@altlinux.org>

> On Dec 10, 2018, at 8:09 AM, Dmitry V. Levin <ldv@altlinux.org> wrote:
>
> Hi, things are getting too complicated and we need some advice how to deal
> with this frame_pointer issue.
>
>> On Mon, Dec 10, 2018 at 10:26:50PM +0800, kbuild test robot wrote:
>> Hi Elvira,
>>
>> Thank you for the patch! Yet something to improve:
>>
>> [auto build test ERROR on linus/master]
>> [also build test ERROR on v4.20-rc6]
>> [cannot apply to next-20181207]
>> [if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
>>
>> url:    https://github.com/0day-ci/linux/commits/Dmitry-V-Levin/ptrace-add-PTRACE_GET_SYSCALL_INFO-request/20181210-174745
>> config: mips-malta_kvm_defconfig (attached as .config)
>> compiler: mipsel-linux-gnu-gcc (Debian 7.2.0-11) 7.2.0
>> reproduce:
>>        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
>>        chmod +x ~/bin/make.cross
>>        # save the attached .config to linux build tree
>>        GCC_VERSION=7.2.0 make.cross ARCH=mips
>>
>> All errors (new ones prefixed by >>):
>>
>>   kernel/ptrace.c: In function 'ptrace_get_syscall_info':
>>>> kernel/ptrace.c:942:20: error: implicit declaration of function 'frame_pointer'; did you mean 'trace_printk'? [-Werror=implicit-function-declaration]
>>      .frame_pointer = frame_pointer(regs)
>>                       ^~~~~~~~~~~~~
>>                       trace_printk
>>   cc1: some warnings being treated as errors
>>
>> vim +942 kernel/ptrace.c
>>
>>   931
>>   932    static int
>>   933    ptrace_get_syscall_info(struct task_struct *child, unsigned long user_size,
>>   934                void __user *datavp)
>>   935    {
>>   936        struct pt_regs *regs = task_pt_regs(child);
>>   937        struct ptrace_syscall_info info = {
>>   938            .op = PTRACE_SYSCALL_INFO_NONE,
>>   939            .arch = syscall_get_arch(child),
>>   940            .instruction_pointer = instruction_pointer(regs),
>>   941            .stack_pointer = user_stack_pointer(regs),
>>> 942            .frame_pointer = frame_pointer(regs)
>>   943        };
>>   944        unsigned long actual_size = offsetof(struct ptrace_syscall_info, entry);
>>   945        unsigned long write_size;
>>   946
>>   947        /*
>>   948         * This does not need lock_task_sighand() to access
>>   949         * child->last_siginfo because ptrace_freeze_traced()
>>   950         * called earlier by ptrace_check_attach() ensures that
>>   951         * the tracee cannot go away and clear its last_siginfo.
>>   952         */
>>   953        switch (child->last_siginfo ? child->last_siginfo->si_code : 0) {
>>   954        case SIGTRAP | 0x80:
>>   955            switch (child->ptrace_message) {
>>   956            case PTRACE_EVENTMSG_SYSCALL_ENTRY:
>>   957                actual_size = ptrace_get_syscall_info_entry(child, regs,
>>   958                                        &info);
>>   959                break;
>>   960            case PTRACE_EVENTMSG_SYSCALL_EXIT:
>>   961                actual_size = ptrace_get_syscall_info_exit(child, regs,
>>   962                                       &info);
>>   963                break;
>>   964            }
>>   965            break;
>>   966        case SIGTRAP | (PTRACE_EVENT_SECCOMP << 8):
>>   967            actual_size = ptrace_get_syscall_info_seccomp(child, regs,
>>   968                                      &info);
>>   969            break;
>>   970        }
>>   971
>>   972        write_size = min(actual_size, user_size);
>>   973        return copy_to_user(datavp, &info, write_size) ? -EFAULT : actual_size;
>>   974    }
>>   975
>
> We decided to add .frame_pointer to struct ptrace_syscall_info just for
> consistency with .instruction_pointer and .stack_pointer; I must have been
> misled by comments in asm-generic/ptrace.h into thinking that
> frame_pointer() is universally available across architectures.
>
> Unlike .instruction_pointer and .stack_pointer that are actually needed
> in strace, .frame_pointer is not used, so from strace PoV we don't really
> need it.
>
> So the question is, does anybody need a
> struct ptrace_syscall_info.frame_pointer?
>
> If yes, how can frame_pointer() be defined on MIPS?
> Or should we just forget about making sense of frame_pointer() and remove
> struct ptrace_syscall_info.frame_pointer from the proposed API?
>

I would suggest getting rid of frame_pointer. Anyone who needs that
degree of debugging can use existing ptrace APIs for it.

>
> --
> ldv

WARNING: multiple messages have this Message-ID (diff)
From: Andy Lutomirski <luto-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
To: "Dmitry V. Levin" <ldv-u2l5PoMzF/Vg9hUCZPvPmw@public.gmane.org>
Cc: LKML <linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
	Kees Cook <keescook-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>,
	Jann Horn <jannh-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org>,
	jhogan-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org,
	Oleg Nesterov <oleg-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>,
	Ralf Baechle <ralf-6z/3iImG2C8G8FEW9MqTrA@public.gmane.org>,
	Eugene Syromiatnikov
	<esyr-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>,
	paul.burton-8NJIiSa5LzA@public.gmane.org,
	Andrew Lutomirski <luto-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>,
	Linux API <linux-api-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
	strace-devel-3+4lAyCyj6AWlMsSdNXQLw@public.gmane.org
Subject: Re: [PATCH v5 24/25] ptrace: add PTRACE_GET_SYSCALL_INFO request
Date: Mon, 10 Dec 2018 11:38:17 -0800	[thread overview]
Message-ID: <CALCETrV4J8+_gSHONAcQHt6XFgtuW487b9DHZ8MV-xa6XhZ_Og@mail.gmail.com> (raw)
In-Reply-To: <20181210160940.GF14149-u2l5PoMzF/Vg9hUCZPvPmw@public.gmane.org>

> On Dec 10, 2018, at 8:09 AM, Dmitry V. Levin <ldv-u2l5PoMzF/Vg9hUCZPvPmw@public.gmane.org> wrote:
>
> Hi, things are getting too complicated and we need some advice how to deal
> with this frame_pointer issue.
>
>> On Mon, Dec 10, 2018 at 10:26:50PM +0800, kbuild test robot wrote:
>> Hi Elvira,
>>
>> Thank you for the patch! Yet something to improve:
>>
>> [auto build test ERROR on linus/master]
>> [also build test ERROR on v4.20-rc6]
>> [cannot apply to next-20181207]
>> [if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
>>
>> url:    https://github.com/0day-ci/linux/commits/Dmitry-V-Levin/ptrace-add-PTRACE_GET_SYSCALL_INFO-request/20181210-174745
>> config: mips-malta_kvm_defconfig (attached as .config)
>> compiler: mipsel-linux-gnu-gcc (Debian 7.2.0-11) 7.2.0
>> reproduce:
>>        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
>>        chmod +x ~/bin/make.cross
>>        # save the attached .config to linux build tree
>>        GCC_VERSION=7.2.0 make.cross ARCH=mips
>>
>> All errors (new ones prefixed by >>):
>>
>>   kernel/ptrace.c: In function 'ptrace_get_syscall_info':
>>>> kernel/ptrace.c:942:20: error: implicit declaration of function 'frame_pointer'; did you mean 'trace_printk'? [-Werror=implicit-function-declaration]
>>      .frame_pointer = frame_pointer(regs)
>>                       ^~~~~~~~~~~~~
>>                       trace_printk
>>   cc1: some warnings being treated as errors
>>
>> vim +942 kernel/ptrace.c
>>
>>   931
>>   932    static int
>>   933    ptrace_get_syscall_info(struct task_struct *child, unsigned long user_size,
>>   934                void __user *datavp)
>>   935    {
>>   936        struct pt_regs *regs = task_pt_regs(child);
>>   937        struct ptrace_syscall_info info = {
>>   938            .op = PTRACE_SYSCALL_INFO_NONE,
>>   939            .arch = syscall_get_arch(child),
>>   940            .instruction_pointer = instruction_pointer(regs),
>>   941            .stack_pointer = user_stack_pointer(regs),
>>> 942            .frame_pointer = frame_pointer(regs)
>>   943        };
>>   944        unsigned long actual_size = offsetof(struct ptrace_syscall_info, entry);
>>   945        unsigned long write_size;
>>   946
>>   947        /*
>>   948         * This does not need lock_task_sighand() to access
>>   949         * child->last_siginfo because ptrace_freeze_traced()
>>   950         * called earlier by ptrace_check_attach() ensures that
>>   951         * the tracee cannot go away and clear its last_siginfo.
>>   952         */
>>   953        switch (child->last_siginfo ? child->last_siginfo->si_code : 0) {
>>   954        case SIGTRAP | 0x80:
>>   955            switch (child->ptrace_message) {
>>   956            case PTRACE_EVENTMSG_SYSCALL_ENTRY:
>>   957                actual_size = ptrace_get_syscall_info_entry(child, regs,
>>   958                                        &info);
>>   959                break;
>>   960            case PTRACE_EVENTMSG_SYSCALL_EXIT:
>>   961                actual_size = ptrace_get_syscall_info_exit(child, regs,
>>   962                                       &info);
>>   963                break;
>>   964            }
>>   965            break;
>>   966        case SIGTRAP | (PTRACE_EVENT_SECCOMP << 8):
>>   967            actual_size = ptrace_get_syscall_info_seccomp(child, regs,
>>   968                                      &info);
>>   969            break;
>>   970        }
>>   971
>>   972        write_size = min(actual_size, user_size);
>>   973        return copy_to_user(datavp, &info, write_size) ? -EFAULT : actual_size;
>>   974    }
>>   975
>
> We decided to add .frame_pointer to struct ptrace_syscall_info just for
> consistency with .instruction_pointer and .stack_pointer; I must have been
> misled by comments in asm-generic/ptrace.h into thinking that
> frame_pointer() is universally available across architectures.
>
> Unlike .instruction_pointer and .stack_pointer that are actually needed
> in strace, .frame_pointer is not used, so from strace PoV we don't really
> need it.
>
> So the question is, does anybody need a
> struct ptrace_syscall_info.frame_pointer?
>
> If yes, how can frame_pointer() be defined on MIPS?
> Or should we just forget about making sense of frame_pointer() and remove
> struct ptrace_syscall_info.frame_pointer from the proposed API?
>

I would suggest getting rid of frame_pointer. Anyone who needs that
degree of debugging can use existing ptrace APIs for it.

>
> --
> ldv
-- 
Strace-devel mailing list
Strace-devel-3+4lAyCyj6AWlMsSdNXQLw@public.gmane.org
https://lists.strace.io/mailman/listinfo/strace-devel

  parent reply	other threads:[~2018-12-10 19:38 UTC|newest]

Thread overview: 90+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-12-10  4:23 [PATCH v5 00/25] ptrace: add PTRACE_GET_SYSCALL_INFO request Dmitry V. Levin
2018-12-10  4:23 ` Dmitry V. Levin
2018-12-10  4:23 ` Dmitry V. Levin
2018-12-10  4:23 ` [OpenRISC] " Dmitry V. Levin
2018-12-10  4:23 ` Dmitry V. Levin
2018-12-10  4:23 ` Dmitry V. Levin
2018-12-10  4:23 ` Dmitry V. Levin
2018-12-10  4:27 ` [PATCH v5 01/25] alpha: define remaining syscall_get_* functions Dmitry V. Levin
2018-12-10  4:28 ` [PATCH v5 02/25] Move EM_ARCOMPACT and EM_ARCV2 to uapi/linux/elf-em.h Dmitry V. Levin
2018-12-10  4:28   ` Dmitry V. Levin
2018-12-10  4:29 ` [PATCH v5 03/25] arc: define syscall_get_arch() Dmitry V. Levin
2018-12-10  4:29   ` Dmitry V. Levin
2018-12-10  4:29 ` [PATCH v5 04/25] c6x: " Dmitry V. Levin
2018-12-11 22:40   ` Mark Salter
2018-12-10  4:29 ` [PATCH v5 05/25] elf-em.h: add EM_CSKY Dmitry V. Levin
2018-12-10  4:29 ` [PATCH v5 06/25] csky: define syscall_get_arch() Dmitry V. Levin
2018-12-10  4:29 ` [PATCH v5 07/25] h8300: define remaining syscall_get_* functions Dmitry V. Levin
2018-12-10  4:29 ` [PATCH v5 08/25] Move EM_HEXAGON to uapi/linux/elf-em.h Dmitry V. Levin
2018-12-10  4:29 ` [PATCH v5 09/25] hexagon: define remaining syscall_get_* functions Dmitry V. Levin
2018-12-10  4:29 ` [PATCH v5 10/25] Move EM_NDS32 to uapi/linux/elf-em.h Dmitry V. Levin
2018-12-10  4:29 ` [PATCH v5 11/25] nds32: define syscall_get_arch() Dmitry V. Levin
2018-12-10  4:30 ` [PATCH v5 12/25] nios2: " Dmitry V. Levin
2018-12-10  4:30 ` [PATCH v5 13/25] m68k: add asm/syscall.h Dmitry V. Levin
2018-12-10  8:45   ` Geert Uytterhoeven
2018-12-10 12:40     ` Dmitry V. Levin
2018-12-10 13:06       ` Geert Uytterhoeven
2018-12-10 13:30         ` Dmitry V. Levin
2018-12-12  8:55           ` Dmitry V. Levin
2018-12-12  9:01             ` Geert Uytterhoeven
2018-12-12  9:27               ` Dmitry V. Levin
2018-12-12  9:43                 ` Geert Uytterhoeven
2018-12-12 12:04                   ` Dmitry V. Levin
2018-12-12 12:27                     ` Geert Uytterhoeven
2018-12-12 12:37                       ` Dmitry V. Levin
2018-12-12 12:54                         ` Geert Uytterhoeven
2018-12-12 13:07                           ` Dmitry V. Levin
2018-12-12 23:12                             ` Dmitry V. Levin
2019-03-29 22:04             ` Dmitry V. Levin
2019-03-30 20:57               ` Geert Uytterhoeven
2018-12-10  4:30 ` [PATCH v5 14/25] mips: define syscall_get_error() Dmitry V. Levin
2018-12-10  4:30 ` [PATCH v5 15/25] parisc: " Dmitry V. Levin
2018-12-10  4:30 ` [PATCH v5 16/25] powerpc: " Dmitry V. Levin
2018-12-10  4:30   ` Dmitry V. Levin
2018-12-10  4:30 ` [PATCH v5 17/25] riscv: define syscall_get_arch() Dmitry V. Levin
2018-12-10  4:30   ` Dmitry V. Levin
2018-12-10  4:30 ` [PATCH v5 18/25] Move EM_XTENSA to uapi/linux/elf-em.h Dmitry V. Levin
2018-12-10  4:30 ` [PATCH v5 19/25] xtensa: define syscall_get_* functions Dmitry V. Levin
2018-12-10  5:02   ` Max Filippov
2018-12-10 12:53     ` Dmitry V. Levin
2018-12-10 20:14       ` Max Filippov
2018-12-10 20:24         ` Dmitry V. Levin
2018-12-10 20:30           ` Dmitry V. Levin
2018-12-10 21:29             ` Max Filippov
2018-12-12 10:45   ` kbuild test robot
2018-12-19  5:58   ` kbuild test robot
2018-12-10  4:30 ` [PATCH v5 20/25] Move EM_UNICORE to uapi/linux/elf-em.h Dmitry V. Levin
2018-12-10  4:30 ` [PATCH v5 21/25] unicore32: add asm/syscall.h Dmitry V. Levin
2018-12-10  4:31 ` [PATCH v5 22/25] syscall_get_arch: add "struct task_struct *" argument Dmitry V. Levin
2018-12-10  4:31   ` [OpenRISC] " Dmitry V. Levin
2018-12-10  4:31   ` Dmitry V. Levin
2018-12-10  4:31   ` Dmitry V. Levin
2018-12-10  4:31   ` Dmitry V. Levin
2018-12-10  4:31   ` Dmitry V. Levin
2018-12-10  4:31   ` Dmitry V. Levin
2018-12-10 17:29   ` Kees Cook
2018-12-11 22:44   ` Mark Salter
2018-12-10  4:31 ` [PATCH v5 23/25] powerpc/ptrace: replace ptrace_report_syscall() with a tracehook call Dmitry V. Levin
2018-12-10  4:31   ` Dmitry V. Levin
2018-12-10  4:31 ` [PATCH v5 24/25] ptrace: add PTRACE_GET_SYSCALL_INFO request Dmitry V. Levin
2018-12-10  4:31   ` Dmitry V. Levin
2018-12-10 14:11   ` Oleg Nesterov
2018-12-10 16:21     ` Dmitry V. Levin
2018-12-10 16:21       ` Dmitry V. Levin
2018-12-11 15:29       ` Oleg Nesterov
2018-12-11 16:23         ` Dmitry V. Levin
2018-12-11 16:23           ` Dmitry V. Levin
2018-12-11 20:27           ` Dmitry V. Levin
2018-12-12 18:00             ` Oleg Nesterov
2018-12-10 14:26   ` kbuild test robot
2018-12-10 16:09     ` Dmitry V. Levin
2018-12-10 16:09       ` Dmitry V. Levin
2018-12-10 18:04       ` Paul Burton
2018-12-10 21:04         ` Palmer Dabbelt
2018-12-10 19:38       ` Andy Lutomirski [this message]
2018-12-10 19:38         ` Andy Lutomirski
2018-12-10 17:44   ` Kees Cook
2018-12-12  9:28   ` kbuild test robot
2018-12-10  4:31 ` [PATCH v5 25/25] selftests/ptrace: add a test case for PTRACE_GET_SYSCALL_INFO Dmitry V. Levin
2018-12-10  4:31   ` Dmitry V. Levin
2018-12-10  4:31   ` ldv

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=CALCETrV4J8+_gSHONAcQHt6XFgtuW487b9DHZ8MV-xa6XhZ_Og@mail.gmail.com \
    --to=luto@kernel.org \
    --cc=esyr@redhat.com \
    --cc=jannh@google.com \
    --cc=jhogan@kernel.org \
    --cc=keescook@chromium.org \
    --cc=ldv@altlinux.org \
    --cc=lineprinter@altlinux.org \
    --cc=linux-api@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=oleg@redhat.com \
    --cc=paul.burton@mips.com \
    --cc=ralf@linux-mips.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.