From: Anthony Liguori <aliguori@us.ibm.com>
To: "Petersson, Mats" <Mats.Petersson@amd.com>
Cc: xen-devel@lists.xensource.com
Subject: Re: Fetching instructions after page-fault, near page boundary?
Date: Fri, 02 Jun 2006 15:35:56 -0500 [thread overview]
Message-ID: <4480A12C.3090601@us.ibm.com> (raw)
In-Reply-To: <907625E08839C4409CE5768403633E0BA7FCE1@sefsexmb1.amd.com>
Petersson, Mats wrote:
> Ah, yet another place where segments show their "ugly" head.... And the
> current code is not doing this very well... In fact, it assumes that
> non-real-mode segments have base=0 and that the limit "is big enough".
>
> Although, in a normal system, that sort of violation would be caught by
> the processor itself [GP faulting the instruction] before we get the
> page-fault, unless:
> 1. Someone is modifying the instructions we're emulating - and that
> would have to be done at exactly the right time for the page-fault to be
> in transit in Xen, but not yet read the data from the page - which I'm
> sure someone can figure out how to do [it's actually several thousand
> cycles, so it's not exactly a tiny hole as such], but it's not exactly
> the most likely attack scenario I can think of.
>
> 2. Someone is updating the descriptor tables between the processor
> executing the original trapping instruction, and us emulating the same
> instruction.
>
> However, I think we should START this project [moving
> x86_emulate_memop() into QEMU] by aiming to achieve something that is
> better than the current solution - not fill every hole and gap possible
> all in one go. So do you think it's fair to say that we can make a note
> of this lack of security and ignore it for now? [Otherwise, I fear that
> I will be moved to another project before I even get a chance to finish
> this project].
>
heh, sure, I think that's fine :-)
I haven't been able to think of a way to actually exploit this FWIW.
It's certainly a correctness issue so we should eventually address it
but for now I think it's fine to just sweep it under the table.
Regards,
Anthony Liguori
> --
> Mats
>
>> Regards,
>>
>> Anthony Liguori
>>
>> Petersson, Mats wrote:
>>
>>> If we get a page-fault due to a MMIO access to a virtual
>>>
>> MMIO device
>>
>>> (such as VGA screen in HVM), we shouldn't need to worry
>>>
>> about crossing
>>
>>> the page-boundary at the end of the instruction, right?
>>>
>> Let's say the
>>
>>> instruction is a 7-byte instruction like this:
>>>
>>> xxxx1FFD: 11 22 33 <page boundary to page xxxx2000> 44 55 66 77
>>>
>>> If the page xxxx2000 isn't present when the instruction is started,
>>> then we'd FIRST get a page-fault for this address, so
>>>
>> either we fail
>>
>>> the instruction (if xxxx2000 page isn't actually possible
>>>
>> to be fixed
>>
>>> up), or we get the page fixed up and therefore the second
>>>
>> time, when
>>
>>> we get to the page-fault handler looking at the address the
>>> instruction is accessing [doing the MMIO part], the second page is
>>> present [assuming we haven't got any sneaky code going
>>>
>> round modifying
>>
>>> the page-tables for this guest domain - which I don't think
>>>
>> is a VALID
>>
>>> thing to expect, is it?]
>>>
>>> Next case is where we have a short instruction before an
>>>
>> empty(unused
>>
>>> page), say a three-byte instruction (RR is another
>>>
>> instructon, such as
>>
>>> a return instruction).
>>>
>>> xxx1FFC: 11 22 33 RR <page boundary to xxxx2000> [not
>>>
>> readable since
>>
>>> it's not present].
>>>
>>>
>>> My design idea for the merged x86_emulate.c in QEMU is to read
>>> instruction bytes blind (i.e. not knowing the actual instruction
>>> length) by the this method:
>>> Try to read 15 bytes (MAX_INST_LEN), and if the instruction bytes
>>> happen to cross a page-boundary, and the second page is not
>>>
>> readable,
>>
>>> I'll just cut the number of bytes short, assuming that the valid
>>> instruction is shorter than 15 bytes.
>>>
>>> Does anyone see a problem with this method?
>>>
>>> [By the way, this makes an improvement over the current
>>>
>> setup, which
>>
>>> fails if we try to read a page that isn't readable - which at least
>>> the SVM model does try sometimes].
>>>
>>> --
>>> Mats
>>>
>>>
>>> _______________________________________________
>>> Xen-devel mailing list
>>> Xen-devel@lists.xensource.com
>>> http://lists.xensource.com/xen-devel
>>>
>>>
>>
>>
>
>
prev parent reply other threads:[~2006-06-02 20:35 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-06-02 16:34 Fetching instructions after page-fault, near page boundary? Petersson, Mats
2006-06-02 16:40 ` Keir Fraser
2006-06-02 17:07 ` Petersson, Mats
2006-06-02 17:12 ` Keir Fraser
2006-06-02 17:20 ` Petersson, Mats
2006-06-02 18:50 ` Keir Fraser
2006-06-02 19:04 ` Petersson, Mats
2006-06-03 8:53 ` Keir Fraser
2006-06-02 21:39 ` Usage of "container_of" in QEMU Petersson, Mats
2006-06-03 8:50 ` Keir Fraser
2006-06-02 20:16 ` Fetching instructions after page-fault, near page boundary? Anthony Liguori
2006-06-02 20:29 ` Petersson, Mats
2006-06-02 20:35 ` Anthony Liguori [this message]
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=4480A12C.3090601@us.ibm.com \
--to=aliguori@us.ibm.com \
--cc=Mats.Petersson@amd.com \
--cc=xen-devel@lists.xensource.com \
/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.