Received: from eggs.gnu.org ([2001:4830:134:3::10]:41814) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a9oAK-0002hq-PK for qemu-devel@nongnu.org; Fri, 18 Dec 2015 01:05:26 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1a9oAG-0000wc-EJ for qemu-devel@nongnu.org; Fri, 18 Dec 2015 01:05:20 -0500 Received: from mx1.redhat.com ([209.132.183.28]:46045) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a9oAG-0000wY-8n for qemu-devel@nongnu.org; Fri, 18 Dec 2015 01:05:16 -0500 Date: Fri, 18 Dec 2015 11:35:07 +0530 (IST) From: P J P Message-ID: MIME-Version: 1.0 Content-Type: text/plain; format=flowed; charset=US-ASCII Subject: [Qemu-devel] [PATCH] i386: avoid null pointer dereference List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Ling Liu Hello, A null pointer dereference issue was reported by Mr Ling Liu, CC'd here. It occurs while doing I/O port write operations via hmp interface. In that, 'current_cpu' remains null as it is not called from cpu_exec loop, which results in the said issue. Below is a proposed (tested)patch to fix this issue; Does it look okay? === >From ae88a4947fab9a148cd794f8ad2d812e7f5a1d0f Mon Sep 17 00:00:00 2001 From: Prasad J Pandit Date: Fri, 18 Dec 2015 11:16:07 +0530 Subject: [PATCH] i386: avoid null pointer dereference When I/O port write operation is called from hmp interface, 'current_cpu' remains null, as it is not called from cpu_exec() loop. This leads to a null pointer dereference in vapic_write routine. Add check to avoid it. Reported-by: Ling Liu Signed-off-by: Prasad J Pandit --- hw/i386/kvmvapic.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/hw/i386/kvmvapic.c b/hw/i386/kvmvapic.c index c6d34b2..18157c7 100644 --- a/hw/i386/kvmvapic.c +++ b/hw/i386/kvmvapic.c @@ -634,6 +634,10 @@ static int vapic_prepare(VAPICROMState *s) static void vapic_write(void *opaque, hwaddr addr, uint64_t data, unsigned int size) { + if (!current_cpu) { + return; + } + CPUState *cs = current_cpu; X86CPU *cpu = X86_CPU(cs); CPUX86State *env = &cpu->env; -- 2.4.3 === Thank you. -- Prasad J Pandit / Red Hat Product Security Team 47AF CE69 3A90 54AA 9045 1053 DD13 3D32 FE5B 041F