Bug 1071176
| Summary: | qemu segmentation fault (core dumped) when boot KVM guest with spice in FIPS enabled mode | ||
|---|---|---|---|
| Product: | Red Hat Enterprise Linux 7 | Reporter: | Sibiao Luo <sluo> |
| Component: | spice | Assignee: | Christophe Fergeau <cfergeau> |
| Status: | CLOSED ERRATA | QA Contact: | SPICE QE bug list <spice-qe-bugs> |
| Severity: | medium | Docs Contact: | |
| Priority: | medium | ||
| Version: | 7.0 | CC: | cfergeau, chayang, dblechte, djasa, fidencio, fziglio, hhuang, jcody, jherrman, juzhang, lmiksik, marcandre.lureau, mazhang, michen, mkrcmari, pkotvan, qzhang, rbalakri, tpelka, virt-maint, xfu |
| Target Milestone: | rc | ||
| Target Release: | 7.2 | ||
| Hardware: | Unspecified | ||
| OS: | Unspecified | ||
| Whiteboard: | |||
| Fixed In Version: | spice-0.12.4-10.el7 | Doc Type: | Bug Fix |
| Doc Text: |
When encrypting the SPICE connection password while booting in FIPS mode, SPICE previously attempted to use a weak encryption method. Consequently, the encryption failed and QEMU terminated unexpectedly. This update adjusts SPICE to requires Simple Authentication and Security Layer (SASL) authentication when using FIPS, which prevents the described crash from occurring.
|
Story Points: | --- |
| Clone Of: | Environment: | ||
| Last Closed: | 2015-11-19 14:34:19 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: | |||
(In reply to Sibiao Luo from comment #0) > Steps to Reproduce: > 1.boot KVM guest with spice. > # /usr/libexec/qemu-kvm -M pc -enable-kvm -m 2048 -smp 2 > -no-kvm-pit-reinjection -name sluo -uuid > 990ea161-6b67-47b2-b803-19fb01d30d30 -rtc > base=localtime,clock=host,driftfix=slew -drive > file=/home/RHEL-7.0-20140116.1_Server_x86_64.qcow2,if=none,id=drive-system- > disk,format=qcow2,cache=none,aio=native,werror=stop,rerror=stop -device > virtio-blk-pci,vectors=0,bus=pci.0,addr=0x4,scsi=off,drive=drive-system-disk, > id=system-disk,bootindex=1 -netdev > tap,id=hostnet0,vhost=on,script=/etc/qemu-ifup -device > virtio-net-pci,netdev=hostnet0,id=virtio-net-pci0,mac=00:01:02:03:40:21, > bus=pci.0,addr=0x5 -k en-us -boot menu=on -spice disable-ticketing,port=5931 > -monitor stdio Reproducible with just /usr/libexec/qemu-kvm -enable-kvm -m 512 -spice disable-ticketing,port=5931 And I'm indeed not able to reproduce on a different RHEL7 machine :( The machine where this fails has fips enabled (fips=1 is set on the kernel command line and /proc/sys/crypto/fips_enabled contains 1). reds_send_link_ack() has a call to RSA_generate_key_ex(link->tiTicketing.rsa, SPICE_TICKET_KEY_PAIR_LENGTH, link->tiTicketing.bn, NULL); in order to initialize link->tiTicketing.rsa which returns 0 on the machine where this crash happens (most likely to indicate some kind of failure), and which returns 1 on a machine whithout the crash. Even after turning fips mode on on my rhel7 machine I'm not hitting this crash :( Hmm the default openssl ciphers seem different on the machine with the crash and on the machine without the crash. The one where it crashes (yours) has 50 lines in 'openssl ciphers -v' output, and no RC4/MD5 ciphers, the one where it does not crash (mine) has 75 lines there including RC4/MD5 ciphers. Have you done some crypto-related tweaking on this box? Ah, with fips=1 + OPENSSL_FORCE_FIPS_MODE=1 in the environment I can hit the bug (In reply to Christophe Fergeau from comment #7) > Ah, with fips=1 + OPENSSL_FORCE_FIPS_MODE=1 in the environment I can hit the > bug Hmm, forget to tell you about it. I enable FIPS mode via setting PRELINKING=no in the /etc/sysconfig/prelink and appending fips=1 to the /boot/grub2/grub.cfg configuration file. # cat /proc/cmdline BOOT_IMAGE=/vmlinuz-3.10.0-76.el7.x86_64 root=/dev/mapper/rhel_dhcp--11--229-root ro vconsole.font=latarcyrheb-sun16 rd.lvm.lv=rhel_dhcp-11-229/swap vconsole.keymap=us rd.lvm.lv=rhel_dhcp-11-229/root crashkernel=auto rhgb quiet fips=1 # cat /proc/sys/crypto/fips_enabled 1 (In reply to Christophe Fergeau from comment #6) > Hmm the default openssl ciphers seem different on the machine with the crash > and on the machine without the crash. The one where it crashes (yours) has > 50 lines in 'openssl ciphers -v' output, and no RC4/MD5 ciphers, the one > where it does not crash (mine) has 75 lines there including RC4/MD5 ciphers. > Have you done some crypto-related tweaking on this box? I just enable the FIPS machine to verify a bug but meet this spice issue which cause our QEMU core dumped. I refer here to enable FIPS machine: https://access.redhat.com/site/documentation/en-US/Red_Hat_Enterprise_Linux/6/html/Security_Guide/sect-Security_Guide-Federal_Standards_And_Regulations-Federal_Information_Processing_Standard.html This issue is related to FIPS mode, so i modify the title. Best Regards, sluo The crash is fixed by http://lists.freedesktop.org/archives/spice-devel/2014-March/016271.html However, clients can't successfully connect in fips mode. Fixing this is a bit more involved as a 1024 bit RSA key is hardcoded in the protocol used, in the server->clientlink reply message: #define SPICE_TICKET_KEY_PAIR_LENGTH 1024 #define SPICE_TICKET_PUBKEY_BYTES (SPICE_TICKET_KEY_PAIR_LENGTH / 8 + 34) typedef struct SPICE_ATTR_PACKED SpiceLinkReply { uint32_t error; uint8_t pub_key[SPICE_TICKET_PUBKEY_BYTES]; uint32_t num_common_caps; uint32_t num_channel_caps; uint32_t caps_offset; } SpiceLinkReply; The pubkey is sent at the same time as the AUTH_SASL cap, so even when trying to use SASL, the RSA_generate_key_ex failure will cause the connection to fail :( I think both client and server updates will be needed in order to get fips mode to work :( (In reply to Christophe Fergeau from comment #10) > The crash is fixed by > http://lists.freedesktop.org/archives/spice-devel/2014-March/016271.html > However, clients can't successfully connect in fips mode. Fixing this is a > bit more involved as a 1024 bit RSA key is hardcoded in the protocol used, > in the server->clientlink reply message: Would it be possible to add a flag/cap in link msg sent by the client? that would indicate to use a fips compliant pubkey? what would be compliant btw? > > #define SPICE_TICKET_KEY_PAIR_LENGTH 1024 > #define SPICE_TICKET_PUBKEY_BYTES (SPICE_TICKET_KEY_PAIR_LENGTH / 8 + 34) > > typedef struct SPICE_ATTR_PACKED SpiceLinkReply { > uint32_t error; > uint8_t pub_key[SPICE_TICKET_PUBKEY_BYTES]; > uint32_t num_common_caps; > uint32_t num_channel_caps; > uint32_t caps_offset; > } SpiceLinkReply; > > The pubkey is sent at the same time as the AUTH_SASL cap, so even when > trying to use SASL, the RSA_generate_key_ex failure will cause the > connection to fail :( yeah > I think both client and server updates will be needed in order to get fips > mode to work :( well, we could make it work in disable-ticketing/SASL-only, right? just do not generate a key in this case. no? (In reply to Marc-Andre Lureau from comment #11) > (In reply to Christophe Fergeau from comment #10) > > The crash is fixed by > > http://lists.freedesktop.org/archives/spice-devel/2014-March/016271.html > > However, clients can't successfully connect in fips mode. Fixing this is a > > bit more involved as a 1024 bit RSA key is hardcoded in the protocol used, > > in the server->clientlink reply message: > > Would it be possible to add a flag/cap in link msg sent by the client? that > would indicate to use a fips compliant pubkey? what would be compliant btw? Yep, that's the approach I'm currently exploring. Now that you are asking, I don't know what would be a fips-compliant pubkey :-/ Setting the key size to 2048 bits make the call not fail, but this is not consistent with what I'm seeing in openssl source. > yeah > > > I think both client and server updates will be needed in order to get fips > > mode to work :( > > well, we could make it work in disable-ticketing/SASL-only, right? just do > not generate a key in this case. no? With ticketing disabled, we the server will still decrypt a ticket sent by the client, and then ignore it. This means old clients expect to find a valid RSA pubkey to use for encryption in the SpiceLinkRepyl message. For SASL authentication, the authentication method to be used is only determined after the SpiceLinkReply message has been sent, ie after the RSA pubkey has been generated. In reds.c, we first get to reds_handle_read_link_done() which calls reds_send_link_ack() which is the function generating the RSA key. Once that is sent, we wait for the client to end back a message with the auth mechanisms to use. This is handled by the reds_handle_auth_mechanism() callback. And it seems the server has no idea whether the client supports SASL or not before getting the auth_mechanism info :( And we need to generate the RSA pubkey as old clients not supporting SASL will expect it. Current plan of action is to append a 'ticket_encryption' uint8_t to the SpiceReplyLink message to indicate whether we use the old RSA method to encrypt the ticket, or if we use some new way of encrypting it. I'm currently thinking the new way will be 'no encryption', and will only be available when the connection goes only through SSL as I'd tend to think someone enabling fips mode will not want an unencrypted connection. (In reply to Christophe Fergeau from comment #12) > Now that you are asking, I > don't know what would be a fips-compliant pubkey :-/ Setting the key size to > 2048 bits make the call not fail, but this is not consistent with what I'm > seeing in openssl source. RHEL7 openssl has: static int FIPS_rsa_builtin_keygen(RSA *rsa, int bits, BIGNUM *e_value, BN_GENCB *cb) { [snip] if (bits != 2048 && bits != 3072) { FIPSerr(FIPS_F_RSA_BUILTIN_KEYGEN, FIPS_R_INVALID_KEY_LENGTH); return 0; } so it wants a bigger key than the one we try to use. 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. *** Bug 1068288 has been marked as a duplicate of this bug. *** patches upstream: http://lists.freedesktop.org/archives/spice-devel/2014-March/016418.html Patch still hasn't been ack'ed upstream, just resent it: http://lists.freedesktop.org/archives/spice-devel/2014-October/017626.html This patch has now been acked, however this is making a slight tweak to the SPICE protocol (see patch commit log). This is fully compatible with older clients, but this is still something I"m uncomfortable pushing into RHEL late into the release cycle. As there is no customer case attached, I'll push this to 7.2. If this is something we must have in 7.1, we can revisit that change. 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://rhn.redhat.com/errata/RHBA-2015-2429.html |
Description of problem: qemu segmentation fault (core dumped) when boot KVM guest with spice, this just met in my local host, and it fail to hit with my anther host. Version-Release number of selected component (if applicable): host info: 3.10.0-76.el7.x86_64 qemu-kvm-rhev-1.5.3-49.el7.x86_64 spice-server-0.12.4-5.el7.x86_64 spice-glib-0.20-8.el7.x86_64 spice-gtk3-0.20-8.el7.x86_64 virt-viewer-0.5.7-7.el7.x86_64 seabios-1.7.2.2-11.el7.x86_64 guest info: 3.10.0-76.el7.x86_64 How reproducible: 5/5 Steps to Reproduce: 1.boot KVM guest with spice. # /usr/libexec/qemu-kvm -M pc -enable-kvm -m 2048 -smp 2 -no-kvm-pit-reinjection -name sluo -uuid 990ea161-6b67-47b2-b803-19fb01d30d30 -rtc base=localtime,clock=host,driftfix=slew -drive file=/home/RHEL-7.0-20140116.1_Server_x86_64.qcow2,if=none,id=drive-system-disk,format=qcow2,cache=none,aio=native,werror=stop,rerror=stop -device virtio-blk-pci,vectors=0,bus=pci.0,addr=0x4,scsi=off,drive=drive-system-disk,id=system-disk,bootindex=1 -netdev tap,id=hostnet0,vhost=on,script=/etc/qemu-ifup -device virtio-net-pci,netdev=hostnet0,id=virtio-net-pci0,mac=00:01:02:03:40:21,bus=pci.0,addr=0x5 -k en-us -boot menu=on -spice disable-ticketing,port=5931 -monitor stdio 2.connect the VM via 'remote-viewer spice' # remote-viewer spice://10.66.8.206:5931 (remote-viewer:4897): GSpice-WARNING **: incomplete link header (0/16) Actual results: after step 2, QEMU segmentation fault (core dumped). (qemu) (/usr/libexec/qemu-kvm:4883): SpiceWorker-Warning **: red_worker.c:11376:dev_destroy_primary_surface: double destroy of primary surface (/usr/libexec/qemu-kvm:4883): SpiceWorker-Warning **: red_worker.c:9648:red_create_surface: condition `surface->context.canvas' reached (qemu) Segmentation fault (core dumped) Core was generated by `/usr/libexec/qemu-kvm -M pc -enable-kvm -m 2048 -smp 2 -no-kvm-pit-reinjection'. Program terminated with signal 11, Segmentation fault. #0 0x00007f38d63728a0 in BN_num_bits () from /lib64/libcrypto.so.10 (gdb) bt #0 0x00007f38d63728a0 in BN_num_bits () from /lib64/libcrypto.so.10 #1 0x00007f38d639661d in RSA_size () from /lib64/libcrypto.so.10 #2 0x00007f38d7991762 in reds_handle_read_link_done () from /lib64/libspice-server.so.1 #3 0x00007f38d7990c06 in spice_server_add_client () from /lib64/libspice-server.so.1 #4 0x00007f38d7990c6a in reds_accept () from /lib64/libspice-server.so.1 #5 0x00007f38dc0d2946 in qemu_iohandler_poll (pollfds=0x7f38dedce200, ret=755449965, ret@entry=1) at iohandler.c:143 #6 0x00007f38dc0d6ea8 in main_loop_wait (nonblocking=<optimized out>) at main-loop.c:465 #7 0x00007f38dbffd7c0 in main_loop () at vl.c:1988 #8 main (argc=<optimized out>, argv=<optimized out>, envp=<optimized out>) at vl.c:4357 (gdb) bt full #0 0x00007f38d63728a0 in BN_num_bits () from /lib64/libcrypto.so.10 No symbol table info available. #1 0x00007f38d639661d in RSA_size () from /lib64/libcrypto.so.10 No symbol table info available. #2 0x00007f38d7991762 in reds_handle_read_link_done () from /lib64/libspice-server.so.1 No symbol table info available. #3 0x00007f38d7990c06 in spice_server_add_client () from /lib64/libspice-server.so.1 No symbol table info available. #4 0x00007f38d7990c6a in reds_accept () from /lib64/libspice-server.so.1 No symbol table info available. #5 0x00007f38dc0d2946 in qemu_iohandler_poll (pollfds=0x7f38dedce200, ret=755449965, ret@entry=1) at iohandler.c:143 revents = 1 #6 0x00007f38dc0d6ea8 in main_loop_wait (nonblocking=<optimized out>) at main-loop.c:465 ret = 1 timeout = 4294967295 #7 0x00007f38dbffd7c0 in main_loop () at vl.c:1988 nonblocking = <optimized out> last_io = 1 #8 main (argc=<optimized out>, argv=<optimized out>, envp=<optimized out>) at vl.c:4357 i = <optimized out> snapshot = 0 linux_boot = 0 icount_option = 0x0 initrd_filename = 0x0 kernel_filename = 0x0 kernel_cmdline = 0x7f38dc2a9ee0 "" boot_order = 0x7f38dc262146 "cad" ds = <optimized out> cyls = 0 heads = 0 secs = 0 translation = 0 hda_opts = <optimized out> opts = 0x7f38dedcdab0 machine_opts = <optimized out> olist = <optimized out> optind = 31 optarg = 0x7fff0ffad7d4 "stdio" loadvm = 0x0 machine = 0x7f38dc635140 <pc_machine_rhel700> cpu_model = 0x0 vga_model = 0x7f38dc28ce1f "cirrus" pid_file = 0x0 incoming = 0x0 show_vnc_port = 0 defconfig = <optimized out> userconfig = false log_mask = <optimized out> log_file = 0x0 mem_trace = {malloc = 0x7f38dc13dbe0 <malloc_and_trace>, realloc = 0x7f38dc13dbc0 <realloc_and_trace>, free = 0x7f38dc13dbb0 <free_and_trace>, calloc = 0x0, try_malloc = 0x0, try_realloc = 0x0} trace_events = 0x0 trace_file = 0x0 __PRETTY_FUNCTION__ = "main" args = {machine = 0x7f38dc635140 <pc_machine_rhel700>, ram_size = 2147483648, boot_device = 0x7f38dc262146 "cad", kernel_filename = 0x0, kernel_cmdline = 0x7f38dc2a9ee0 "", initrd_filename = 0x0, cpu_model = 0x0} (gdb) Expected results: It should no any qemu core dumped. Additional info: