[PATCH v2 4/6] powerpc: use common ptrace_syscall_enter hook to handle _TIF_SYSCALL_EMU
Sudeep Holla
sudeep.holla at arm.com
Tue Mar 19 04:24:57 AEDT 2019
On Mon, Mar 18, 2019 at 06:20:24PM +0100, Oleg Nesterov wrote:
> On 03/18, Sudeep Holla wrote:
> >
> > --- a/arch/powerpc/kernel/ptrace.c
> > +++ b/arch/powerpc/kernel/ptrace.c
> > @@ -3278,35 +3278,29 @@ long do_syscall_trace_enter(struct pt_regs *regs)
> >
> > user_exit();
> >
> > - flags = READ_ONCE(current_thread_info()->flags) &
> > - (_TIF_SYSCALL_EMU | _TIF_SYSCALL_TRACE);
> > -
> > - if (flags) {
> > - int rc = tracehook_report_syscall_entry(regs);
> > + if (unlikely(ptrace_syscall_enter(regs))) {
> > + /*
> > + * A nonzero return code from tracehook_report_syscall_entry()
> > + * tells us to prevent the syscall execution, but we are not
> > + * going to execute it anyway.
> > + *
> > + * Returning -1 will skip the syscall execution. We want to
> > + * avoid clobbering any registers, so we don't goto the skip
> > + * label below.
> > + */
> > + return -1;
> > + }
> >
> > - if (unlikely(flags & _TIF_SYSCALL_EMU)) {
> > - /*
> > - * A nonzero return code from
> > - * tracehook_report_syscall_entry() tells us to prevent
> > - * the syscall execution, but we are not going to
> > - * execute it anyway.
> > - *
> > - * Returning -1 will skip the syscall execution. We want
> > - * to avoid clobbering any registers, so we don't goto
> > - * the skip label below.
> > - */
> > - return -1;
> > - }
> > + flags = READ_ONCE(current_thread_info()->flags) & _TIF_SYSCALL_TRACE;
>
> Why do we need READ_ONCE() with this change?
>
> And now that we change a single bit "flags" doesn't look like a good name.
>
> Again, to me this patch just makes the code look worse. Honestly, I don't
> think that the new (badly named) ptrace_syscall_enter() hook makes any sense.
>
Worse because we end up reading current_thread_info->flags twice ?
--
Regards,
Sudeep
More information about the Linuxppc-dev
mailing list