Re: [PATCH v6 1/2] ptrace,syscall_user_dispatch: Implement Syscall User Dispatch Suspension

From: Gregory Price
Date: Thu Jan 26 2023 - 13:46:45 EST


On Thu, Jan 26, 2023 at 07:30:19PM +0100, Oleg Nesterov wrote:
> On 01/26, Andrei Vagin wrote:
> >
> > On Thu, Jan 26, 2023 at 7:07 AM Oleg Nesterov <oleg@xxxxxxxxxx> wrote:
> > >
> > > IIUC, PTRACE_O_SUSPEND_SYSCALL_USER_DISPATCH is needed to run the injected
> > > code, and this also needs to change the state of the traced process. If
> > > the tracer (CRIU) dies while the tracee runs this code, I guess the tracee
> > > will have other problems?
> >
> > Our injected code can reheal itself if something goes wrong. The hack
> > here is that we inject
> > the code with a signal frame and it calls rt_segreturn to resume the process.
>
> What will happen if CRIU dies and clears ->ptrace right before
> syscall_user_dispatch() checks PT_SUSPEND_SYSCALL_USER_DISPATCH ?
>
> How the tracee will react to SIGSYS with unexpected .si_syscall ?
>
> > I don't expect that
> > the syscall user dispatch
> > is used by many applications,
>
> Agreed, so the case when CRIU will need to do the additional
> PTRACE_SET_SYSCALL_USER_DISPATCH_CONFIG twice to disable and then re-enable
> syscall_user_dispatch is unlikely.
>
> > so I don't strongly insist on
> > PTRACE_O_SUSPEND_SYSCALL_USER_DISPATCH.
>
> I too won't argue too much. but so far I do not feel there is enough
> justification for this feature ...
>
> Oleg.
>

I'm not married to the idea, just want to make sure I have the tools
needed to make checkpoint work. The option seems like the easiest way
given the exclusion area issue.

One idea is to overwrite a portion of the exclusion area, but this
obviously can increase the complexity of the checkpoint process.

Another idea is to disable/enable SUD via get/set, but this produces
potential detach issues.

@Andrei i'm happy to take this to IRC or somewhere else out of band to
discuss the checkpoint specifics, if that would be preferable and you
are interested.