Received: from eggs.gnu.org ([2001:4830:134:3::10]:46481) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aIXkG-0003IK-Ec for qemu-devel@nongnu.org; Mon, 11 Jan 2016 03:22:33 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aIXkD-0003tK-5N for qemu-devel@nongnu.org; Mon, 11 Jan 2016 03:22:32 -0500 Received: from mx1.redhat.com ([209.132.183.28]:38579) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aIXkD-0003tF-0N for qemu-devel@nongnu.org; Mon, 11 Jan 2016 03:22:29 -0500 Date: Mon, 11 Jan 2016 13:52:19 +0530 (IST) From: P J P In-Reply-To: <20160111075914.GA28466@olga> Message-ID: References: <20160108091949.GA14724@olga> <20160108130251.GA17847@olga> <20160108143831.GA7632@olga> <1907860725.4.388b58e8-5b06-4844-be0c-df2778eb46fb.open-xchange@webmail.proxmox.com> <56920EC7.6090109@msgid.tls.msk.ru> <20160111075914.GA28466@olga> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Subject: Re: [Qemu-devel] [PATCH] hmp: avoid redundant null termination of buffer List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Wolfgang Bumiller Cc: Michael Tokarev , qemu-devel@nongnu.org, Ling Liu +-- On Mon, 11 Jan 2016, Wolfgang Bumiller wrote --+ | Seems we concluded it's best to keep keyname_len around and simply check it | against the sizeof(keyname_buf). | | Here's a full new version as I haven't seen one yet. (With an adapted commit | message and the CVE id added.) Sorry, i thought you were sending it. | === | >From 8da4a3bf8fb076314f986a0d58cb94f5458e3659 Mon Sep 17 00:00:00 2001 | From: Wolfgang Bumiller | Date: Mon, 11 Jan 2016 08:21:25 +0100 | Subject: [PATCH] hmp: fix sendkey out of bounds write (CVE-2015-8619) | | 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. | | Now checking the length against the buffer size before using | it. | | Reported-by: Ling Liu | Signed-off-by: Wolfgang Bumiller | --- | hmp.c | 4 +++- | 1 file changed, 3 insertions(+), 1 deletion(-) | | diff --git a/hmp.c b/hmp.c | index c2b2c16..0c7a04c 100644 | --- a/hmp.c | +++ b/hmp.c | @@ -1749,6 +1749,8 @@ void hmp_sendkey(Monitor *mon, const QDict *qdict) | while (1) { | separator = strchr(keys, '-'); | keyname_len = separator ? separator - keys : strlen(keys); | + if (keyname_len >= sizeof(keyname_buf)) | + goto err_out; | pstrcpy(keyname_buf, sizeof(keyname_buf), keys); | | /* Be compatible with old interface, convert user inputted "<" */ | @@ -1800,7 +1802,7 @@ out: | return; | | err_out: | - monitor_printf(mon, "invalid parameter: %s\n", keyname_buf); | + monitor_printf(mon, "invalid parameter: %s\n", keys); | goto out; | } It looks good. Thank you. -- Prasad J Pandit / Red Hat Product Security Team 47AF CE69 3A90 54AA 9045 1053 DD13 3D32 FE5B 041F