i386: avoid null pointer dereference
PATCH 1/1 i386: avoid null pointer dereference
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?
===
Quoted 1 line
From
ae88a4947fab9a148cd794f8ad2d812e7f5a1d0fMon Sep 17 00:00:00 2001
From: Prasad J Pandit <[email protected]>
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.
--- hw/i386/kvmvapic.c | 4 ++++ 1 file changed, 4 insertions(+)
hw/i386/kvmvapic.c +4 -0
@@ -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;
Signature · 8 lines
2.4.3 === Thank you. -- Prasad J Pandit / Red Hat Product Security Team 47AF CE69 3A90 54AA 9045 1053 DD13 3D32 FE5B 041F
+-- On Fri, 18 Dec 2015, P J P wrote --+ | 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.
Ping..! -> https://patchwork.ozlabs.org/patch/558748/
--
Prasad J Pandit / Red Hat Product Security Team 47AF CE69 3A90 54AA 9045 1053 DD13 3D32 FE5B 041F
Quoted 7 lines · P J P
+-- On Fri, 18 Dec 2015, P J P wrote --+ | 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.Ping..! -> https://patchwork.ozlabs.org/patch/558748/
I was on vacation until today. I'll send a pull request some time next week.
Paolo
+-- On Thu, 7 Jan 2016, Paolo Bonzini wrote --+ | On 04/01/2016 16:49, P J P wrote: | > Ping..! -> https://patchwork.ozlabs.org/patch/558748/ | | I was on vacation until today. I'll send a pull request some time next | week.
Sure okay, thank you.
--
Prasad J Pandit / Red Hat Product Security Team
47AF CE69 3A90 54AA 9045 1053 DD13 3D32 FE5B 041F