qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PULL 0/1] Monitor patches for 2016-02-03
@ 2016-02-03  9:51 Markus Armbruster
  2016-02-03  9:51 ` [Qemu-devel] [PULL 1/1] hmp: fix sendkey out of bounds write (CVE-2015-8619) Markus Armbruster
  2016-02-03 12:23 ` [Qemu-devel] [PULL 0/1] Monitor patches for 2016-02-03 Peter Maydell
  0 siblings, 2 replies; 3+ messages in thread
From: Markus Armbruster @ 2016-02-03  9:51 UTC (permalink / raw)
  To: qemu-devel

The following changes since commit c65db7705b7926f4a084b93778e4bd5dd3990aad:

  Merge remote-tracking branch 'remotes/maxreitz/tags/pull-block-for-peter-2016-02-02' into staging (2016-02-02 18:04:04 +0000)

are available in the git repository at:

  git://repo.or.cz/qemu/armbru.git tags/pull-monitor-2016-02-03

for you to fetch changes up to 64ffbe04eaafebf4045a3ace52a360c14959d196:

  hmp: fix sendkey out of bounds write (CVE-2015-8619) (2016-02-03 10:13:06 +0100)

----------------------------------------------------------------
Monitor patches for 2016-02-03

----------------------------------------------------------------
Wolfgang Bumiller (1):
      hmp: fix sendkey out of bounds write (CVE-2015-8619)

 hmp.c                | 18 ++++++++----------
 include/ui/console.h |  2 +-
 ui/input-legacy.c    |  5 +++--
 3 files changed, 12 insertions(+), 13 deletions(-)

-- 
2.4.3

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Qemu-devel] [PULL 1/1] hmp: fix sendkey out of bounds write (CVE-2015-8619)
  2016-02-03  9:51 [Qemu-devel] [PULL 0/1] Monitor patches for 2016-02-03 Markus Armbruster
@ 2016-02-03  9:51 ` Markus Armbruster
  2016-02-03 12:23 ` [Qemu-devel] [PULL 0/1] Monitor patches for 2016-02-03 Peter Maydell
  1 sibling, 0 replies; 3+ messages in thread
From: Markus Armbruster @ 2016-02-03  9:51 UTC (permalink / raw)
  To: qemu-devel; +Cc: Wolfgang Bumiller

From: Wolfgang Bumiller <w.bumiller@proxmox.com>

When processing 'sendkey' command, hmp_sendkey routine null
terminates the 'keyname_buf' array. This results in an OOB
write issue, if 'keyname_len' was to fall outside of
'keyname_buf' array.

Since the keyname's length is known the keyname_buf can be
removed altogether by adding a length parameter to
index_from_key() and using it for the error output as well.

Reported-by: Ling Liu <liuling-it@360.cn>
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
Message-Id: <20160113080958.GA18934@olga>
[Comparison with "<" dumbed down, test for junk after strtoul()
tweaked]
Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 hmp.c                | 18 ++++++++----------
 include/ui/console.h |  2 +-
 ui/input-legacy.c    |  5 +++--
 3 files changed, 12 insertions(+), 13 deletions(-)

diff --git a/hmp.c b/hmp.c
index 54f2620..9c571f5 100644
--- a/hmp.c
+++ b/hmp.c
@@ -1731,21 +1731,18 @@ void hmp_sendkey(Monitor *mon, const QDict *qdict)
     int has_hold_time = qdict_haskey(qdict, "hold-time");
     int hold_time = qdict_get_try_int(qdict, "hold-time", -1);
     Error *err = NULL;
-    char keyname_buf[16];
     char *separator;
     int keyname_len;
 
     while (1) {
         separator = strchr(keys, '-');
         keyname_len = separator ? separator - keys : strlen(keys);
-        pstrcpy(keyname_buf, sizeof(keyname_buf), keys);
 
         /* Be compatible with old interface, convert user inputted "<" */
-        if (!strncmp(keyname_buf, "<", 1) && keyname_len == 1) {
-            pstrcpy(keyname_buf, sizeof(keyname_buf), "less");
+        if (keys[0] == '<' && keyname_len == 1) {
+            keys = "less";
             keyname_len = 4;
         }
-        keyname_buf[keyname_len] = 0;
 
         keylist = g_malloc0(sizeof(*keylist));
         keylist->value = g_malloc0(sizeof(*keylist->value));
@@ -1758,16 +1755,17 @@ void hmp_sendkey(Monitor *mon, const QDict *qdict)
         }
         tmp = keylist;
 
-        if (strstart(keyname_buf, "0x", NULL)) {
+        if (strstart(keys, "0x", NULL)) {
             char *endp;
-            int value = strtoul(keyname_buf, &endp, 0);
-            if (*endp != '\0') {
+            int value = strtoul(keys, &endp, 0);
+            assert(endp <= keys + keyname_len);
+            if (endp != keys + keyname_len) {
                 goto err_out;
             }
             keylist->value->type = KEY_VALUE_KIND_NUMBER;
             keylist->value->u.number = value;
         } else {
-            int idx = index_from_key(keyname_buf);
+            int idx = index_from_key(keys, keyname_len);
             if (idx == Q_KEY_CODE__MAX) {
                 goto err_out;
             }
@@ -1789,7 +1787,7 @@ out:
     return;
 
 err_out:
-    monitor_printf(mon, "invalid parameter: %s\n", keyname_buf);
+    monitor_printf(mon, "invalid parameter: %.*s\n", keyname_len, keys);
     goto out;
 }
 
diff --git a/include/ui/console.h b/include/ui/console.h
index adac36d..116bc2b 100644
--- a/include/ui/console.h
+++ b/include/ui/console.h
@@ -448,7 +448,7 @@ static inline int vnc_display_pw_expire(const char *id, time_t expires)
 void curses_display_init(DisplayState *ds, int full_screen);
 
 /* input.c */
-int index_from_key(const char *key);
+int index_from_key(const char *key, size_t key_length);
 
 /* gtk.c */
 void early_gtk_display_init(int opengl);
diff --git a/ui/input-legacy.c b/ui/input-legacy.c
index 35dfc27..3454055 100644
--- a/ui/input-legacy.c
+++ b/ui/input-legacy.c
@@ -57,12 +57,13 @@ struct QEMUPutLEDEntry {
 static QTAILQ_HEAD(, QEMUPutLEDEntry) led_handlers =
     QTAILQ_HEAD_INITIALIZER(led_handlers);
 
-int index_from_key(const char *key)
+int index_from_key(const char *key, size_t key_length)
 {
     int i;
 
     for (i = 0; QKeyCode_lookup[i] != NULL; i++) {
-        if (!strcmp(key, QKeyCode_lookup[i])) {
+        if (!strncmp(key, QKeyCode_lookup[i], key_length) &&
+            !QKeyCode_lookup[i][key_length]) {
             break;
         }
     }
-- 
2.4.3

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [Qemu-devel] [PULL 0/1] Monitor patches for 2016-02-03
  2016-02-03  9:51 [Qemu-devel] [PULL 0/1] Monitor patches for 2016-02-03 Markus Armbruster
  2016-02-03  9:51 ` [Qemu-devel] [PULL 1/1] hmp: fix sendkey out of bounds write (CVE-2015-8619) Markus Armbruster
@ 2016-02-03 12:23 ` Peter Maydell
  1 sibling, 0 replies; 3+ messages in thread
From: Peter Maydell @ 2016-02-03 12:23 UTC (permalink / raw)
  To: Markus Armbruster; +Cc: QEMU Developers

On 3 February 2016 at 09:51, Markus Armbruster <armbru@redhat.com> wrote:
> The following changes since commit c65db7705b7926f4a084b93778e4bd5dd3990aad:
>
>   Merge remote-tracking branch 'remotes/maxreitz/tags/pull-block-for-peter-2016-02-02' into staging (2016-02-02 18:04:04 +0000)
>
> are available in the git repository at:
>
>   git://repo.or.cz/qemu/armbru.git tags/pull-monitor-2016-02-03
>
> for you to fetch changes up to 64ffbe04eaafebf4045a3ace52a360c14959d196:
>
>   hmp: fix sendkey out of bounds write (CVE-2015-8619) (2016-02-03 10:13:06 +0100)
>
> ----------------------------------------------------------------
> Monitor patches for 2016-02-03
>
> ----------------------------------------------------------------

Applied, thanks.

-- PMM

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2016-02-03 12:24 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-02-03  9:51 [Qemu-devel] [PULL 0/1] Monitor patches for 2016-02-03 Markus Armbruster
2016-02-03  9:51 ` [Qemu-devel] [PULL 1/1] hmp: fix sendkey out of bounds write (CVE-2015-8619) Markus Armbruster
2016-02-03 12:23 ` [Qemu-devel] [PULL 0/1] Monitor patches for 2016-02-03 Peter Maydell

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).