Re: ptrace vs FSGSBASE

From: Oleg Nesterov
Date: Mon May 02 2016 - 11:30:02 EST


Hi Andy,

let me first say that I never knew how this code (and the hardware)
actually works, I am not sure I even understand what ARCH_SET_.S
exactly does ;)

What is even worse, I do not understand your question. So it is not
that I am trying to help, I am asking you to help me understand the
problem.

On 04/29, Andy Lutomirski wrote:
>
> 1. I read fs_base using ptrace. I think I should get the actual
> fs_base without any nonsense.

Which fs_base? The member of user_regs_struct? But this structure/layout
is just the ABI, so to me it seems correct that getreg() tries to look
at ->fs and/or ->fsindex.

IOW. getreg(fs) should return the same value as prctl(ARCH_GET_FS)
returns if called by the tracee, no?

> 2. I read all the regs (PEEKUSER or whatever) and then write then all
> back verbatim. At the very least, I think that if I do this
> atomically using PTRACE_SETREGSET, the task's state needs to remain
> unchanged.

Agreed... do you mean this doesn't work?

> Since ptrace doesn't seem to have any real concept of
> atomic register state changes right now

Could you spell please?

I can't understand what does "atomically" mean in this context.

Oleg.