Re: [PATCH] ptrace RSE bug

Petr Tesarik
2007-09-05T16:25:07Z

Shaohua Li wrote:
> This is base kernel patch for ptrace RSE bug. It's basically a backport
> from the utrace RSE patch I sent out several weeks ago. please review.
>
> when a thread is stopped (ptraced), debugger might change thread's user
> stack (change memory directly), and we must avoid the RSE stored in
> kernel to override user stack (user space's RSE is newer than kernel's
> in the case). To workaround the issue, we copy kernel RSE to user RSE
> before the task is stopped, so user RSE has updated data. we then copy
> user RSE to kernel after the task is resummed from traced stop and
> kernel will use the newer RSE to return to user.

Hi Shaohua,

somehow I fail to see the need for a dedicated bit in the task flags.
The user RBS can only be more up-to-date than the kernel RBS if the
values there have been modified by a debugger. So, it should be enough
to copy the relevant part of the user RBS back into the kernel RBS when
the ptraced process is resumed, which happens AFAIK only:

1. when the debugger lets it continue via ptrace(), or
2. when the debugger ceases to exist.

Yes, we'd most likely have to add an arch_ptrace_resume() in addition to
arch_ptrace_stop(), but there are some advantages, too:

1. It would save one bit in the task flags.
2. The usual path for task switches is not modified
(OK, the few instructions needed to check for TIF_RESTORE_RSE are
negligible)

Or am I totally missing what you're trying to do?

Kind regards,
Petr Tesarik