summaryrefslogtreecommitdiffstats
path: root/server/reds.c
Commit message (Collapse)AuthorAgeFilesLines
* server: remove OpenGLMarc-André Lureau2015-11-211-4/+0
| | | | | | | | | | This is really not supported, requires X11, so better to remove it for now. Some day it might be revived, using DRM, .. Note for later, this could be removed too (not used by client): - spice-common/common/ogl_ctx Acked-by: Fabiano Fidêncio <fidencio@redhat.com>
* reds: Do not abort due to wrong headerPavel Grunt2015-11-131-1/+4
| | | | | | | | | | | | | | | | | | | | | Just prevent the buggy client from connecting. #0 0x00007fffe83b2a98 in raise () at /lib64/libc.so.6 #1 0x00007fffe83b469a in abort () at /lib64/libc.so.6 #2 0x00007ffff7b1533d in spice_logv (log_domain=0x7ffff7b87226 "Spice", log_level=SPICE_LOG_LEVEL_ERROR, strloc=0x7ffff7b92aba "reds.c:1373", function=0x7ffff7b94f40 <__FUNCTION__.31775> "reds_send_link_ack", format=0x7ffff7b871fe "assertion `%s' failed", args=args@entry=0x7fffffffcb68) at log.c:109 #3 0x00007ffff7b15468 in spice_log (log_domain=log_domain@entry=0x7ffff7b87226 "Spice", log_level=log_level@entry=SPICE_LOG_LEVEL_ERROR, strloc=strloc@entry=0x7ffff7b92aba "reds.c:1373", function=function@entry=0x7ffff7b94f40 <__FUNCTION__.31775> "reds_send_link_ack", format=format@entry=0x7ffff7b871fe "assertion `%s' failed") at log.c:123 #4 0x00007ffff7aee335 in reds_handle_read_link_done (link=0x555556b27c70) at reds.c:1373 #5 0x00007ffff7aee335 in reds_handle_read_link_done (opaque=0x555556b27c70) at reds.c:2139 #6 0x000055555588acc6 in qemu_iohandler_poll () #7 0x000055555588a8e1 in main_loop_wait () #8 0x0000555555614064 in main () Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1281442 Acked-by: Fabiano Fidêncio <fidencio@redhat.com> Acked-by: Frediano Ziglio <fziglio@redhat.com>
* worker: remove need for WorkerInitDataMarc-André Lureau2015-10-261-2/+42
| | | | | | Move code around to declare and place it where it fits better. Acked-by: Frediano Ziglio <fziglio@redhat.com>
* fix spelling mistakes in comments (reseting to resetting & dummym to dummy)snir sheriber2015-10-191-1/+1
| | | | Acked-by: Frediano Ziglio <fziglio@redhat.com>
* Avoid core calling spice_server_destroyFrediano Ziglio2015-08-261-2/+5
| | | | | | | | | spice_server_destroy calls reds_exit which is called also at exit time (is registered with atexit) so avoid to keep dangling pointers. Currently this does not happen as spice_server_destroy is not called by Qemu. Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
* Fix typo in commentsJonathon Jongsma2015-08-111-2/+2
|
* Cleanup: move static function declarations out of headerJonathon Jongsma2015-08-111-0/+4
| | | | | It doesn't make much sense to have static function declarations in a header, even a private header. So move them down into the source file.
* Adjust to new SpiceImageCompress nameChristophe Fergeau2015-07-291-6/+6
| | | | | | | | This has been renamed to SpiceImageCompression in order to avoid clashes with older spice-server in the SPICE_IMAGE_COMPRESS_ namespace. This commit is a straight rename of SpiceImageCompress to SpiceImageCompression and SPICE_IMAGE_COMPRESS_ to SPICE_IMAGE_COMPRESSION_
* reds: Assure we don't have stale statistic files before trying to create a ↵Frediano Ziglio2015-07-201-0/+1
| | | | | | | | | | | | | | | | | new one If a previous Qemu executable is not able to delete the statistic file on the next creation with same name (statitics file are based on pid numbers so if pid get reused for another Qemu process you get the same name) it fails as you can't open a file with 0444 permissions (these are the permission used to create these files). This patch assure there are no stale file trying to remove it before the creation of the new one. As file is based on pid and name used for spice you are not deleting another file. Fixes: rhbz#1177326 Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
* server: spice_debug() messages don't need a trailing '\n'.Francois Gouget2015-07-201-2/+2
| | | | Signed-off-by: Francois Gouget <fgouget@codeweavers.com>
* Use image compress constants from spice-protocolJavier Celaya2015-06-301-4/+4
|
* reds: increase listening socket backlogMarc-André Lureau2015-06-171-1/+1
| | | | | | | | | | | | | | | With a TCP socket, the backlog doesn't seem to matter much, perhaps because of latency or underlying protocol behaviour. However, on UNIX socket, it is fairly easy to reach the backlog limit and the client will get an EAGAIN error (but not ECONNREFUSED as stated in listen(7)) that is not easy to deal with: attempting to reconnect in a loop might busy-loop forever as there are no guarantee the server will accept new connections, so it will be inherently racy. Typically, Spice server can easily have up to 15 concurrent incoming connections that are established during initialization of the session. To improve the situation, raise the backlog limit to the default maximum system value, which is 128 on Linux.
* Add password length checkCédric Bosdonnat2015-06-161-0/+2
| | | | Don't allow setting a too long password.
* Remove duplicate streaming enumerationJonathon Jongsma2015-06-151-1/+1
| | | | | | There is already a enumeration in a public header that defines the different streaming options, so there's no need to duplicate that enumeration internally. Just use the public enum values.
* LZ4: warn if trying to set lz4 but not supportedJavier Celaya2015-06-111-0/+8
|
* ppc: Fix endianness handling in initial SPICE connectionChristophe Fergeau2015-04-101-17/+45
| | | | | | | | | | | | This commit fixes enough endianness issues that it's possible to connect to a spice-server/qemu running on a big-endian box with a client running on a little-endian machine. I haven't tested more than getting to the bios/bootloader and typing a bit on the keyboard as I did not manage to boot a distro afterwards :( This is based on patches send by Erlon R. Cruz <erlon.cruz@br.flextronics.com>
* Remove spice-experimentalMarc-André Lureau2015-01-151-18/+0
| | | | | Remove unneded symbols that nobody should be using anyway. ABI is modified with this patch, but the library version is not bumped.
* Do not perform network tests on UNIX socketMarc-André Lureau2015-01-151-1/+3
| | | | | By default, stream latency is 0 and bandwidth is infinite. On UNIX socket do not perform unnecessary testing and keep those values.
* reds: add Unix socket supportMarc-André Lureau2015-01-151-6/+32
| | | | | Learn to listen on a Unix address. In this case, the connection is plain only (non-tls).
* Rename mm_timer/mm_timeMarc-André Lureau2014-11-271-6/+6
| | | | As suggested by Christophe on the mailing list.
* Remove guest side video time-stampingMarc-André Lureau2014-11-271-13/+0
| | | | | | | | | | | | | | | | | The multimedia time is defined by the server side monotonic time [1], but the drawing time-stamp is done in guest side, so it requires synchronization between host and guest. This is expensive, when no audio is playing, there is a ~30x/sec wakeup to update the qxl device mmtime, and it requires marking dirty the rom region. Instead, the video timestamping can be done more efficiently on server side, without visible drawbacks. [1] a better timestamp could be the audio time, since audio players are usually sync with audio time) Related to: https://bugzilla.redhat.com/show_bug.cgi?id=912763
* Don't set SpiceLinkReply::pub_key if client advertises SASL capChristophe Fergeau2014-11-241-23/+38
| | | | | | | | | | | | | | | | | If the client advertises the SASL cap, it means it guarantees it will be able to use SASL if the server supports, and that it does not need a valid SpiceLinkReply::pub_key field when using SASL. When the client cap is set, we thus don't need to create a RSA public key if SASL is enabled server side. The reason for needing client guarantees about not looking at the pub_key field is that its presence and size is hardcoded in the protocol, but in some hardened setups (using fips mode), generating a RSA 1024 bit key as expected is forbidden and fails. With this new capability, the server knows the client will be able to handle SASL if needed, and can skip the generation of the key altogether. This means that on the setups described above, SASL authentication has to be used.
* Introduce red_link_info_test_capability()Christophe Fergeau2014-11-241-3/+18
| | | | | This just hides a bit of pointer arithmetic away from reds_send_link_ack. This helper will be used in the next commits.
* migration: Don't assert() if MIGRATE_DATA comes before attaching the agentUri Lublin2014-10-141-11/+28
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | During seamless migration, after switching host, if a client was connected during the migration, it will have data to send back to the new qemu/spice-server instance. This is handled through MIGRATE_DATA messages. SPICE char devices use such MIGRATE_DATA messages to restore their state. However, the MIGRATE_DATA message can arrive any time after the new qemu instance has started, this can happen before or after the SPICE char devices have been created. In order to handle this, if the migrate data arrives early, it's stored in reds->agent_state.mig_data, and attach_to_red_agent() will restore the agent state as appropriate. Unfortunately this does not work as expected, for main channel (agent messages). If attach_to_red_agent() is called before the MIGRATE_DATA message reaches the server, all goes well, but if MIGRATE_DATA reaches the server before attach_to_red_agent() gets called, then some assert() gets triggered in spice_char_device_state_restore(): ((null):32507): Spice-ERROR **: char_device.c:937:spice_char_device_state_restore: assertion `dev->num_clients == 1 && dev->wait_for_migrate_data' failed Thread 3 (Thread 0x7f406b543700 (LWP 32543)): Thread 2 (Thread 0x7f40697ff700 (LWP 32586)): Thread 1 (Thread 0x7f4079b45a40 (LWP 32507)): When restoring state, a client must already be added to the spice-char-device. What happens is that a client is not being added to the char-device when when MIGRATE_DATA arrives first, which leaves both dev->num_clients and dev->wait_for_migrate_data value at 0. This commit changes the logic in spice_server_char_device_add_interface(), such that if there is migrate data pending in reds->agent_state.mig_data but no client was added to the spice-char-device yet, then first the client is added to the device by calling spice_char_device_client_add(), and only then the state is restored. === How to Reproduce To reproduce, add delays to the migration connection between qmeu-kvm on the source host (SRC) and on the destination (DST). Specifically I added a man in the middle DLY host between migration ports from SRC to DST. +-----+ +-----+ +-----+ | SRC |--> | DLY | --> | DST | +-----+ +-----+ +-----+ DLY listens on port P1 (e.g. 4444) and DST listens on port PINCOMING (e.g. 4444, from qemu-kvm '-incoming' command line option) Precondition: make sure port P1 on DLY is accessible in iptables. Option 1: use ssh tcp port forwarding On DLY host run ssh: ssh DLY:P1:DST:PINCOMING DST Then use the following migration command (on qemu-kvm monitor): client_migrate_info spice DST PSPICE migrate -d tcp:DLY:P1 Option 2: Use a simple proxy program that forwards packets from SRC to DST while adding some delays. The program runs on DLY, listens to port D1, upon accept connects to DST:PINCOMING and forward all packets from DLY:D1 to DST:PINCOMING. Then use the same migrate command as in option 1: client_migrate_info spice DST PSPICE migrate -d tcp:DLY:P1 === How to Reproduce Ends This fixes https://bugzilla.redhat.com/show_bug.cgi?id=1035184 Based-on-a-patch-by: Christophe Fergeau <cfergeau@redhat.com>
* clean-up: remove unused functionMarc-André Lureau2014-09-081-5/+0
|
* reds: lookup corresponding channel idMarc-André Lureau2014-09-081-1/+2
| | | | | | | | | | In reds_send_link_ack(), lookup the channel with the same id as the link message. The bug was found during code review a while ago. A reproducer bug was later reported: https://bugzilla.redhat.com/show_bug.cgi?id=1058625
* Call correct SASL helper in reds_handle_auth_sasl_stepChristophe Fergeau2014-04-161-1/+1
| | | | sasl_handle_auth_start() was called instead of reds_sasl_handle_auth_step()
* Remove RedLinkInfo::async_readChristophe Fergeau2014-04-161-25/+19
| | | | | | | | | | | | | | | | | 9feed69 moved the async reader code to RedsStream so that it can be used for the SASL authentication code. In particular, it introduced a RedsStream::async_read member which is used by the SASL authentication code for its async operations. However, what was not done is to remove the now redundant RedLinkInfo::async_read field. This causes failures when using SASL authentication as the async read error callback is getting set on the RedLinkInfo::async_read structure, but then the SASL code is trying to use the RedeStream::async_read structure for its async IOs, which do not have the needed error callback set. This commit makes use of the newly introduced reds_stream_async_read() helper in order to make use of RedsStream::async_read.
* Check RSA_generate_key_ex return valueChristophe Fergeau2014-03-201-2/+9
| | | | | | | | | | | | | | | | | | This can fail in fips mode for example. If we ignore the failure, we'll get a crash: #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 This commit will cause the client connection to fail but qemu won't segfault.
* Associate org.spice-space.webdav.0 port to webdav channelMarc-André Lureau2014-03-191-1/+6
| | | | | | | | | | For example, with qemu, a webdav channel can be created this way: -chardev spiceport,name=org.spice-space.webdav.0,... And redirected to a virtio port: -device virtserialport,...,name=org.spice-space.webdav.0
* Fix test_capability() typoChristophe Fergeau2014-03-131-2/+2
| | | | It was spelt 'capabilty'
* Fix typo in log messageChristophe Fergeau2014-03-131-1/+1
|
* Introduce reds_stream_set_channel()Christophe Fergeau2014-01-201-3/+3
|
* Introduce reds_stream_set_info_flag()Christophe Fergeau2014-01-201-1/+1
|
* Introduce reds_stream_is_ssl()Christophe Fergeau2014-01-201-5/+5
|
* Move SASL authentication to reds_stream.hChristophe Fergeau2014-01-201-423/+35
| | | | | | SASL authentication mostly use members from RedsStream to do its work, so it makes sense to have its code in reds_stream.c. This should allow to make RedsStream::sasl private in the future.
* Move async code to RedsStreamChristophe Fergeau2014-01-201-60/+0
| | | | | | The AsyncRead structure in reds.h wraps an async read + callback to be done on a stream. Moving it to reds_stream.h is needed in order to move SASL authentication there.
* Move stream read/write callbacks to reds_stream.cChristophe Fergeau2014-01-201-77/+0
| | | | | | Now that stream creation and SSL enabling are done by helpers in reds_stream.c, we can move the initialization of the vfunc read/write pointers there too.
* Introduce reds_stream_new() helperChristophe Fergeau2014-01-201-20/+2
| | | | | | Initializing a new stream means initializing quite a few fields. This commit factors this initialization in a dedicated reds_stream_new helper. This also helps moving more code from reds.c to reds_stream.c
* reds: Move SSL-related code to RedsStreamChristophe Fergeau2014-01-201-55/+30
| | | | Code to initiate a SSL stream belongs there
* Move sync_write* to reds_stream.hChristophe Fergeau2014-01-201-55/+25
| | | | They are renamed to reds_stream_write*
* Add reds_stream.[ch]Christophe Fergeau2014-01-201-180/+1
| | | | | Gather common RedsStream code there rather than having it in reds.c
* Use TLS version 1.0 or betterDavid Jaša2013-12-121-1/+4
| | | | | | | | | | | | | When creating a TLS socket, both spice-server and spice-gtk currently call SSL_CTX_new(TLSv1_method()). The TLSv1_method() function set the protocol version to TLS 1.0 exclusively. The correct way to support multiple protocol versions is to call SSLv23_method() in spite of its scary name. This method will enable all SSL/TLS protocol versions. The protocol suite may be further narrowed down by setting respective SSL_OP_NO_<version_code> options of SSL context. This possibility is used in this patch in order to block use of SSLv3 that is enabled by default in openssl for client sockets as of now but spice has never used it.
* Fix buffer overflow when decrypting client SPICE ticketChristophe Fergeau2013-10-301-12/+32
| | | | | | | | | | | | | | | | | | | | | | | reds_handle_ticket uses a fixed size 'password' buffer for the decrypted password whose size is SPICE_MAX_PASSWORD_LENGTH. However, RSA_private_decrypt which we call for the decryption expects the destination buffer to be at least RSA_size(link->tiTicketing.rsa) bytes long. On my spice-server build, SPICE_MAX_PASSWORD_LENGTH is 60 while RSA_size() is 128, so we end up overflowing 'password' when using long passwords (this was reproduced using the string: 'fullscreen=1proxy=#enter proxy here; e.g spice_proxy = http://[proxy]:[port]' as a password). When the overflow occurs, QEMU dies with: *** stack smashing detected ***: qemu-system-x86_64 terminated This commit ensures we use a corectly sized 'password' buffer, and that it's correctly nul-terminated so that we can use strcmp instead of strncmp. To keep using strncmp, we'd need to figure out which one of 'password' and 'taTicket.password' is the smaller buffer, and use that size. This fixes rhbz#999839
* Remove tunneling supportChristophe Fergeau2013-10-281-26/+0
| | | | | | It's depending on an unmaintained package (slirp), and I don't think anyone uses that code. It's not tested upstream nor in fedora, so let's remove it.
* reds: remove dead codeMarc-André Lureau2013-10-081-33/+0
|
* reds: Fix 'asyc' typoChristophe Fergeau2013-10-081-23/+23
|
* Fix 'recive' typo throughout the code baseChristophe Fergeau2013-10-081-36/+36
| | | | 'receive' was mispelt 'recive' in multiple places.
* server: set dispatcher before calling attache_workerMarc-André Lureau2013-10-071-1/+1
| | | | | This allows to call spice_qxl_add_memslot during attache_worker(), like done in the tests.
* main_channel: monitoring client connection statusYonit Halperin2013-08-141-2/+1
| | | | | | | rhbz#994175 Start monitoring if the client connection is alive after completing the bit-rate test.