Bug 1365708

Summary: qemu-kvm gets SIGSEGV when attach a json backing image of ssh protocol
Product: Red Hat Enterprise Linux 7 Reporter: Han Han <hhan>
Component: qemu-kvm-rhevAssignee: Hanna Czenczek <hreitz>
Status: CLOSED ERRATA QA Contact: Ping Li <pingl>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 7.3CC: aliang, coli, dyuan, hachen, jen, juzhang, knoel, meyang, michen, mrezanin, ngu, pingl, virt-maint, xuwei, xuzhang, yanyang
Target Milestone: rc   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: 2.7.0 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2017-08-01 23:32:13 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Comment 3 Hanna Czenczek 2016-08-12 13:29:28 UTC
Hi Han,

The immediate issue here is that qemu's ssh driver expects the "port" argument to be an integer and not a string. So it should work if you replace "file.port":"22" by "file.port":22.

The segfault itself is rather "safe" in that it will always only dereference NULL, so it can be used for DoS at most. However, it still is an issue that needs fixing, of course.

The problem is that the type of options passed via -drive or JSON are not validated like options passed via blockdev-add are. However, many block drivers assume they are, including SSH. The issue can be reproduced even simpler like so:
$ qemu-system-x86_64 -drive if=none,driver=ssh,host=foo,port=22
[1]    7996 segmentation fault (core dumped)  qemu-system-x86_64 -drive if=none,driver=ssh,host=foo,port=22

This is because each value is treated as a string but ssh expects the port to be set to an integer.

But the issue exists for other block drivers as well, e.g. NBD expects all of its arguments to be strings, so we can do this:
$ qemu-img info "json:{'driver':'nbd', 'host':42}"     
[1]    7103 segmentation fault (core dumped)  ./qemu-img info "json:{'driver':'nbd', 'host':42}"

Or it will ignore a port specified as an integer:
$ qemu-img info "json:{'driver':'nbd', 'host':'foo', 'port':42}"
qemu-img: Could not open 'json:{'driver':'nbd', 'host':'foo', 'port':42}': address resolution failed for foo:10809: Name or service not known

Which is better than crashing, admittedly, but not really good still.


So because I do not consider this issue absolutely critical (it will always result in a NULL pointer getting dereferenced which is certain to result in a plain crash), because the fix will not be trivial, and because we're rather late in the release process, I'd rather move this BZ to 7.4.

Max

Comment 7 Ping Li 2017-01-17 12:24:47 UTC
According to the comment 5, set the bug as verified.

Comment 9 errata-xmlrpc 2017-08-01 23:32:13 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHSA-2017:2392

Comment 10 errata-xmlrpc 2017-08-02 01:09:52 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHSA-2017:2392

Comment 11 errata-xmlrpc 2017-08-02 02:01:51 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHSA-2017:2392

Comment 12 errata-xmlrpc 2017-08-02 02:42:37 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHSA-2017:2392

Comment 13 errata-xmlrpc 2017-08-02 03:07:20 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHSA-2017:2392

Comment 14 errata-xmlrpc 2017-08-02 03:27:29 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHSA-2017:2392