Bug 787694

Summary: fail gracefully (catch exceptions instead of abort) when invalid -spice command-line options are set
Product: Red Hat Enterprise Linux 6 Reporter: David Jaša <djasa>
Component: spice-serverAssignee: Uri Lublin <uril>
Status: CLOSED ERRATA QA Contact: Desktop QE <desktop-qa-list>
Severity: medium Docs Contact:
Priority: medium    
Version: 6.2CC: acathrow, bsarathy, cfergeau, dblechte, desktop-qa-list, dyasny, juzhang, mkenneth, mkrcmari, tburke, virt-maint
Target Milestone: beta   
Target Release: 6.4   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: spice-server-0.12.0-1.el6 Doc Type: Bug Fix
Doc Text:
Cause: For some spice command line options, such as ssl-parameters, when a bad option was given spice-server aborted execution. Consequence: qemu-kvm aborted upon bad params Fix: Instead of aborting, spice-server returns error value, and qemu-kvm to exits gracefully. Result: qemu-kvm exits upon bad spice command line options, and does not abort in such cases.
Story Points: ---
Clone Of: Environment:
Last Closed: 2013-02-21 10:03:00 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:

Description David Jaša 2012-02-06 14:44:32 UTC
Description of problem:
When one calls '/usr/libexec/qemu-kvm -spice tls-port=<port>' in directory without x509_cert_file, x509_key_file or x509_cacert_file (names of variables in qemu-kvm sources), qemu-kvm gets sigabrt

Version-Release number of selected component (if applicable):
qemu-kvm-0.12.1.2-2.222.el6.x86_64

How reproducible:
always

Steps to Reproduce:
1. make sure there are no valid certificates/keys in ca-cert.pem, server-cert.pem and server-key.pem in current directory
2. run strace /usr/libexec/qemu-kvm -spice tls-port=1234
3.
  
Actual results:
qemu-kvm gets sigabrt
open("./server-cert.pem", O_RDONLY)     = -1 ENOENT (No such file or directory)
write(1, "reds_init_ssl: Could not load ce"..., 66reds_init_ssl: Could not load certificates from ./server-cert.pem
) = 66
rt_sigprocmask(SIG_UNBLOCK, [ABRT], NULL, 8) = 0
tgkill(10112, 10112, SIGABRT)           = 0
--- SIGABRT (Aborted) @ 0 (0) ---

Expected results:
qemu-kvm exits cleanly with non-zero exit code

Additional info:

Comment 1 David Jaša 2012-06-05 15:37:39 UTC
the exception is raised in spice code so moving to spice-server:

================================================
Program received signal SIGABRT, Aborted.
0x00007ffff57788a5 in raise (sig=6) at ../nptl/sysdeps/unix/sysv/linux/raise.c:64
64	  return INLINE_SYSCALL (tgkill, 3, pid, selftid, sig);
(gdb) t a a bt

Thread 1 (Thread 0x7ffff7d47940 (LWP 16819)):
#0  0x00007ffff57788a5 in raise (sig=6) at ../nptl/sysdeps/unix/sysv/linux/raise.c:64
#1  0x00007ffff577a085 in abort () at abort.c:92
#2  0x00007ffff5fade89 in reds_init_ssl (s=<value optimized out>, core=<value optimized out>) at reds.c:3067
#3  do_spice_init (s=<value optimized out>, core=<value optimized out>) at reds.c:3660
#4  spice_server_init (s=<value optimized out>, core=<value optimized out>) at reds.c:3702
#5  0x00007ffff7e72e4c in qemu_spice_init () at ui/spice-core.c:731
================================================

the problem seems to be general to any command-line checks in reds.c:

================================================
(gdb) run -spice port=5800,addr=fe80::f2de:f1ff:fe04:c0fa\\%eth0
Starting program: /usr/libexec/qemu-kvm -spice port=5800,addr=fe80::f2de:f1ff:fe04:c0fa\\%eth0
[Thread debugging using libthread_db enabled]
do_spice_init: starting 0.10.1
reds_init_socket: getaddrinfo(fe80::f2de:f1ff:fe04:c0fa\%eth0,5800): Name or service not known

Program received signal SIGABRT, Aborted.
0x00007ffff57788a5 in raise (sig=6) at ../nptl/sysdeps/unix/sysv/linux/raise.c:64
64	  return INLINE_SYSCALL (tgkill, 3, pid, selftid, sig);
(gdb) t a a bt

Thread 1 (Thread 0x7ffff7d47940 (LWP 16839)):
#0  0x00007ffff57788a5 in raise (sig=6) at ../nptl/sysdeps/unix/sysv/linux/raise.c:64
#1  0x00007ffff577a085 in abort () at abort.c:92
#2  0x00007ffff5fac0eb in reds_init_socket (portnr=5800, family=<value optimized out>, addr=0x7ffff6263f00 "fe80::f2de:f1ff:fe04:c0fa\\%eth0") at reds.c:2896
================================================

Behavior like this floods systems with meaningless core dumps.

Comment 2 RHEL Program Management 2012-07-10 06:09:51 UTC
This request was not resolved in time for the current release.
Red Hat invites you to ask your support representative to
propose this request, if still desired, for consideration in
the next release of Red Hat Enterprise Linux.

Comment 3 RHEL Program Management 2012-07-11 02:01:28 UTC
This request was erroneously removed from consideration in Red Hat Enterprise Linux 6.4, which is currently under development.  This request will be evaluated for inclusion in Red Hat Enterprise Linux 6.4.

Comment 4 Christophe Fergeau 2012-09-14 15:12:33 UTC
Behaviour has changed in newer SPICE versions, the error is no longer detected and qemu no longer exits in these cases, so there is no longer a crash ;)
However, the series at http://lists.freedesktop.org/archives/spice-devel/2012-September/010892.html (more specifically "[PATCH 3/7] reds: report SSL initialization errors" and "PATCH 4/7] reds: Check reds_init_ssl errors") should fix this. With these patches, QEMU reports an error and exits gracefully on invalid arguments.

Comment 8 errata-xmlrpc 2013-02-21 10:03:00 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.

http://rhn.redhat.com/errata/RHBA-2013-0529.html