From: Oleg Nesterov <oleg@redhat.com>
To: Andy Lutomirski <luto@amacapital.net>
Cc: X86 ML <x86@kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
Roland McGrath <roland@hack.frob.com>,
Andi Kleen <andi@firstfloor.org>, Borislav Petkov <bp@alien8.de>,
Brian Gerst <brgerst@gmail.com>
Subject: Re: ptrace vs FSGSBASE
Date: Mon, 2 May 2016 17:35:08 +0200 [thread overview]
Message-ID: <20160502153508.GA7874@redhat.com> (raw)
In-Reply-To: <CALCETrWK_FjgyekSbJ5Cbk=fjBWkQogBWjGGDyXBskb-r-+BBg@mail.gmail.com>
On 05/02, Andy Lutomirski wrote:
>
> On Mon, May 2, 2016 at 7:27 AM, Oleg Nesterov <oleg@redhat.com> 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.
>
> Yeah, the member of user_regs_struct.
Still can't understand this... user_regs_struct is just the set of offsets
we use to "name" the registers for getreg/putreg. We simply do not have
"the actual fs_base" we could use in getreg(), we need to calculate it.
> > I can't understand what does "atomically" mean in this context.
>
> I mean "change fs and fs_base to these two values in a single syscall
> so that the kernel can do something intelligent."
>
> Let me give some background:
> [... snip ...]
Thanks Andy. I need to re-read your explanation, but it seems I am starting
to understand. And yes, I didn't bother to look at putreg() when I wrote
my reply.
> If you write, say, 0x2b to
> fs and 12345 to fs_base using the ptrace API, you'd end up with FS ==
> 0x2b and FSBASE == 0,
Hmm. I can be easily wrong again but afaics in this case do_arch_prctl()
will change fs/fs_base first and set
fsindex = FS_TLS_SEL
fs = 0
and then... and then I simply can't understand what set_segment_reg(fs)
will/should do in this case. Nor I can understand the "thread.fs != value"
check before do_arch_prctl(ARCH_SET_FS). Confused.
Oleg.
next prev parent reply other threads:[~2016-05-02 16:37 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-04-29 18:22 ptrace vs FSGSBASE Andy Lutomirski
2016-05-02 12:40 ` Oleg Nesterov
2016-05-02 14:27 ` Oleg Nesterov
2016-05-02 15:38 ` Andy Lutomirski
2016-05-02 15:35 ` Oleg Nesterov [this message]
2016-05-02 17:26 ` Andy Lutomirski
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=20160502153508.GA7874@redhat.com \
--to=oleg@redhat.com \
--cc=andi@firstfloor.org \
--cc=bp@alien8.de \
--cc=brgerst@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=luto@amacapital.net \
--cc=roland@hack.frob.com \
--cc=x86@kernel.org \
/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.