qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Richard Henderson <rth@twiddle.net>
To: Pranith Kumar <bobby.prani+qemu@gmail.com>,
	Peter Maydell <peter.maydell@linaro.org>
Cc: Qemu Developers <qemu-devel@nongnu.org>, Jann Horn <jannh@google.com>
Subject: Re: [Qemu-devel] [BUG] user-to-root privesc inside VM via bad translation caching
Date: Thu, 23 Mar 2017 06:01:17 +1000	[thread overview]
Message-ID: <9f45e912-5fc8-bb99-506e-221f2cb6ac7e@twiddle.net> (raw)
In-Reply-To: <CAJhHMCDfmT_zrnuEBcmoJ+CJV9j8CB79ybehWoMBeh3rd+hA3Q@mail.gmail.com>

On 03/23/2017 02:29 AM, Pranith Kumar wrote:
> On Wed, Mar 22, 2017 at 11:21 AM, Peter Maydell
> <peter.maydell@linaro.org> wrote:
>> On 22 March 2017 at 15:14, Pranith Kumar <bobby.prani+qemu@gmail.com> wrote:
>>> On Wed, Mar 22, 2017 at 11:04 AM, Peter Maydell
>>> <peter.maydell@linaro.org> wrote:
>>>> This doesn't look right because it means we'll check
>>>> only after we've emitted all the code to do the
>>>> instruction operation, so the effect will be
>>>> "execute instruction, then take illegal-opcode
>>>> exception".
>>
>>> The pc is restored to original address (s->pc = pc_start), so the
>>> exception will overwrite the generated illegal instruction and will be
>>> executed first.
>>
>> s->pc is the guest PC -- moving that backwards will
>> not do anything about the generated TCG IR that's
>> already been written. You'd need to rewind the
>> write pointer in the IR stream, which there is
>> no support for doing AFAIK.
>
> Ah, OK. Thanks for the explanation. May be we should check the size of
> the instruction while decoding the prefixes and error out once we
> exceed the limit. We would not generate any IR code.

Yes.

It would not enforce a true limit of 15 bytes, since you can't know that until 
you've done the rest of the decode.  But you'd be able to say that no more than 
14 prefix + 1 opc + 6 modrm+sib+ofs + 4 immediate = 25 bytes is used.

Which does fix the bug.


r~

  reply	other threads:[~2017-03-22 20:01 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-20 14:36 [Qemu-devel] [BUG] user-to-root privesc inside VM via bad translation caching Jann Horn
2017-03-20 14:46 ` Peter Maydell
2017-03-22 14:55   ` Pranith Kumar
2017-03-22 15:04     ` Peter Maydell
2017-03-22 15:14       ` Pranith Kumar
2017-03-22 15:21         ` Peter Maydell
2017-03-22 16:29           ` Pranith Kumar
2017-03-22 20:01             ` Richard Henderson [this message]
2017-03-23 10:27               ` Paolo Bonzini
2017-03-23 16:50                 ` Pranith Kumar
2017-03-23 17:37                   ` Paolo Bonzini
2017-03-23 17:43                     ` Pranith Kumar

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=9f45e912-5fc8-bb99-506e-221f2cb6ac7e@twiddle.net \
    --to=rth@twiddle.net \
    --cc=bobby.prani+qemu@gmail.com \
    --cc=jannh@google.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).