qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v4 05/13] hvf: Fix OOB write in RDTSCP instruction decode


From: Philippe Mathieu-Daudé
Subject: Re: [PATCH v4 05/13] hvf: Fix OOB write in RDTSCP instruction decode
Date: Mon, 14 Feb 2022 13:49:03 +0100
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:91.0) Gecko/20100101 Thunderbird/91.5.1

Hi Cameron,

On 11/2/22 17:34, Philippe Mathieu-Daudé wrote:
From: Cameron Esfahani <dirty@apple.com>

A guest could craft a specific stream of instructions that will have QEMU
write 0xF9 to inappropriate locations in memory.  Add additional asserts
to check for this.  Generate a #UD if there are more than 14 prefix bytes.

Found by Julian Stecklina <julian.stecklina@cyberus-technology.de>

Signed-off-by: Cameron Esfahani <dirty@apple.com>
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
  target/i386/hvf/x86_decode.c | 11 +++++++++--
  target/i386/hvf/x86hvf.c     |  8 ++++++++
  target/i386/hvf/x86hvf.h     |  1 +
  3 files changed, 18 insertions(+), 2 deletions(-)

@@ -1847,7 +1849,8 @@ void calc_modrm_operand(CPUX86State *env, struct 
x86_decode *decode,
static void decode_prefix(CPUX86State *env, struct x86_decode *decode)
  {
-    while (1) {
+    /* At most 14 prefix bytes. */
+    for (int i = 0; i < 14; i++) {

Could we have a definition instead of this magic '14' number?

          /*
           * REX prefix must come after legacy prefixes.
           * REX before legacy is ignored.
@@ -1892,6 +1895,8 @@ static void decode_prefix(CPUX86State *env, struct 
x86_decode *decode)
              return;
          }
      }
+    /* Too many prefixes!  Generate #UD. */
+    hvf_inject_ud(env);
  }



reply via email to

[Prev in Thread] Current Thread [Next in Thread]