Bug 560887 (CVE-2010-0309)

Summary: CVE-2010-0309 kvm: cat /dev/port in guest cause the host hang
Product: [Other] Security Response Reporter: Eugene Teo (Security Response) <eteo>
Component: vulnerabilityAssignee: Red Hat Product Security <security-response-team>
Status: CLOSED ERRATA QA Contact:
Severity: medium Docs Contact:
Priority: medium    
Version: unspecifiedCC: arozansk, dhoward, ehabkost, eren, jasowang, jpirko, lihuang, llim, lwang, ndai, plyons, pmatouse, shuang, syeghiay, ykaul
Target Milestone: ---Keywords: Security
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2013-04-08 17:19:36 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On: 553126, 560888, 560889, 560905    
Bug Blocks:    

Description Eugene Teo (Security Response) 2010-02-02 05:25:52 UTC
Description of problem:
When execute the command: cat /dev/port in the guest, the host hang immediately (General Protection Fault).

Version-Release number of selected component (if applicable):
kvm-83-140.el5
kmod-kvm-83-140.el5
kvm-qemu-img-83-140.el5
2.6.18-182.el5

How reproducible:
100%

Steps to Reproduce:
1. boot the virtual machine
2. type cat /dev/port in the guest
3.

Actual results:
Host hang

Expected results:
Guest should display the information about virtual devices normally.

Additional info:
1 qemu-kvm command:
/home/devel/autotest/client/tests/kvm/qemu -name vm1 -monitor
tcp:0:6001,server,nowait -drive
file=/home/devel/autotest/client/tests/kvm/images/RHEL-Server-5.4-64.qcow2,if=ide,boot=on
-net nic,vlan=0,model=e1000,macaddr=00:9B:81:0E:91:01 -net
tap,vlan=0,ifname=e1000_0_6001,script=/home/devel/autotest/client/tests/kvm/scripts/qemu-ifup-switch,downscript=no
-m 512 -smp 1 -usbdevice tablet -rtc-td-hack -no-hpet -cpu qemu64,+sse2
-no-kvm-pit-reinjection -vnc :0
2 could be reproduced in kvm-83-142 & 2.6.18.183.el5

Re-tested:

Host \ Guest  |    2.6.18.182  | 2.6.33-rc4  |
--------------+----------------+--------------
2.6.18.185el5 |      FAIL      |   FAIL      |
--------------+----------------+--------------
2.6.33-rc4    |      PASS      |   PASS      |
--------------+----------------+--------------

bt from kernel crash dump:
[root@localhost 2010-01-27-03:10]# gdb
/usr/lib/debug/lib/modules/2.6.18-185.el5debug/vmlinux ./vmcore 
GNU gdb Fedora (6.8-37.el5)
Copyright (C) 2008 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-redhat-linux-gnu"...
[New process 32372]
[New process 0]
#0  0xffffffff8002202b in sys_mprotect (start=18446604440097613992, 
    len=18446604435883844864, prot=18446744071700444726) at mm/mprotect.c:250
250   prot |= PROT_EXEC;
(gdb) bt
#0  0xffffffff8002202b in sys_mprotect (start=18446604440097613992, 
    len=18446604435883844864, prot=18446744071700444726) at mm/mprotect.c:250
#1  0x0000000000001000 in ?? ()

As malicious user could use this method to do the attack, move the priority and
severity to urgent.

Comment 3 Eugene Teo (Security Response) 2010-02-02 05:31:18 UTC
The problem is pit_state->channels[] has 3 elements, and pit_ioport_read uses "addr" as index to pit_get_count, so inb(0x43) reads (and potentially writes) into other data of kvm_kpit_state.

Comment 4 Eugene Teo (Security Response) 2010-02-02 05:46:06 UTC
http://www.mail-archive.com/kvm@vger.kernel.org/msg28002.html

Comment 6 errata-xmlrpc 2010-02-09 10:02:03 UTC
This issue has been addressed in following products:

  Red Hat Enterprise Linux 5

Via RHSA-2010:0088 https://rhn.redhat.com/errata/RHSA-2010-0088.html

Comment 7 errata-xmlrpc 2010-02-09 15:24:11 UTC
This issue has been addressed in following products:

  Red Hat Enterprise Virtualization for RHEL-5

Via RHSA-2010:0095 https://rhn.redhat.com/errata/RHSA-2010-0095.html