Commit Graph

472 Commits

Author SHA1 Message Date
Frediano Ziglio
1b2c3e4067 worker: avoid to use constant directly for capabilities size
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2015-10-29 17:46:27 +00:00
Marc-André Lureau
3c1ab4a5fa Move red_bitmap_utils.h->tmpl.c
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2015-10-29 11:27:09 +00:00
Marc-André Lureau
070e0fcd63 worker: move some cursor code to cursor-channel.c
Signed-off-by: Marc-André Lureau <marcandre.lureau@gmail.com>
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2015-10-29 09:58:25 +00:00
Marc-André Lureau
266d344b7f worker: rename some cursor functions
Signed-off-by: Marc-André Lureau <marcandre.lureau@gmail.com>
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2015-10-29 09:44:29 +00:00
Marc-André Lureau
5872d0a09c worker: change CursorItem memory allocation
Do not use static allocate space but handle dynamically

Signed-off-by: Marc-André Lureau <marcandre.lureau@gmail.com>
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2015-10-29 09:35:28 +00:00
Marc-André Lureau
788c9d4790 worker: remove unused type field from AddBufInfo
value was always BUF_TYPE_RAW

Signed-off-by: Marc-André Lureau <marcandre.lureau@gmail.com>
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Uri Lublin <ulublin@redhat.com>
2015-10-28 15:31:48 +00:00
Frediano Ziglio
0b386603cb worker: fix timer queue creation
Timer queue is attached to current thread when created so it must be
created from the proper thread.
After worker initialization is moved in a following patch to main
thread the queue was created in the wrong thread causing program to
fail saying that the queue is NULL.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Uri Lublin <ulublin@redhat.com>
2015-10-28 15:28:29 +00:00
Marc-André Lureau
f55032ecba server: group worker channel related stuff
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2015-10-26 09:17:07 +00:00
Marc-André Lureau
f7b48981e3 worker: remove need for WorkerInitData
Move code around to declare and place it where it fits better.

Acked-by: Frediano Ziglio <fziglio@redhat.com>
2015-10-26 09:12:55 +00:00
Marc-André Lureau
579d65454c worker: access dispatcher pending field using helper functions
Signed-off-by: Marc-André Lureau <marcandre.lureau@gmail.com>
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2015-10-26 08:47:02 +00:00
Marc-André Lureau
f99fac0f42 server: start separate display/cursor channel headers
Just move some declarations around

Acked-by: Frediano Ziglio <fziglio@redhat.com>
2015-10-23 16:32:47 +01:00
Marc-André Lureau
b9defad7d9 server: remove worker->id
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2015-10-23 14:46:22 +01:00
Marc-André Lureau
d3153f8610 worker: remove useless MESSAGE_READY
Now that worker is created before running, and run() returns success,
there is no point in using MESSAGE_READY.

Acked-by: Frediano Ziglio <fziglio@redhat.com>
2015-10-23 11:11:18 +01:00
Marc-André Lureau
bba1bf180a server: remove worker thread creation from dispatcher
Acked-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2015-10-22 17:06:44 +01:00
Marc-André Lureau
31292412c9 worker: use a single clockid
The stat functions in worker are not generic enough to deserve to be
"non-worker", so just pass the worker instance.
2015-10-21 14:12:30 +01:00
Marc-André Lureau
0facd6fc9e server: rename red_client_cache.h to cache_item.tmpl.c
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2015-10-20 14:00:25 +01:00
Christophe Fergeau
31eb8eeecb syntax-check: Don't use tabs for indentation 2015-10-19 14:25:36 +02:00
Marc-André Lureau
b15527e063 server: move some pixmap cache code in own file
Remove that hideous template header that should really be regular code
since it's specialized and instanciated only for pixmap.

Acked-by: Frediano Ziglio <fziglio@redhat.com>
2015-10-19 13:08:21 +01:00
snir sheriber
c749853d08 fix spelling mistakes in comments (reseting to resetting & dummym to dummy)
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2015-10-19 12:59:12 +01:00
Marc-André Lureau
1d7b3ad93b Remove DRAW_ALL
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2015-10-16 14:11:01 +01:00
Marc-André Lureau
f93bf94c5c Remove PIPE_DEBUG
Acked-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2015-10-15 18:30:45 +01:00
Marc-André Lureau
dc1e589916 Remove ACYCLIC_SURFACE_DEBUG
Acked-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2015-10-15 18:30:41 +01:00
Marc-André Lureau
3dffeb25ed Remove unfinished UPDATE_AREA_BY_TREE
Acked-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2015-10-15 18:30:38 +01:00
Marc-André Lureau
c1d5181396 server: small move to red_channel
Acked-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2015-10-15 18:30:34 +01:00
Marc-André Lureau
c61404f102 worker: replace init with red_worker_new
Acked-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2015-10-15 18:30:30 +01:00
Marc-André Lureau
31a66ae6e7 red_worker: replace some abort()
Acked-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2015-10-15 18:29:47 +01:00
Frediano Ziglio
097c638b12 worker: avoid double free or double create of surfaces
A driver can overwrite surface state creating a surface with the same
id of a previous one.
Also can try to destroy surfaces that are not created.
Both requests cause invalid internal states that could lead to crashes
or memory corruptions.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2015-10-06 11:07:15 +01:00
Frediano Ziglio
dd558bb833 worker: validate correctly surfaces
Do not just give warning and continue to use an invalid index into
an array.

Resolves: CVE-2015-5260

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2015-10-06 11:07:15 +01:00
Marc-André Lureau
f2ea57335e worker: make it clear it returns from process when no cmd
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2015-10-05 14:45:16 +01:00
Marc-André Lureau
bb969255c9 worker: count in drawable_new() 2015-09-29 18:59:54 +01:00
Jonathon Jongsma
61d458119e PALLET -> PALETTE
Use the correct spelling for the enumeration
2015-09-29 18:59:54 +01:00
Frediano Ziglio
bd6ea0db84 Avoid race conditions reading monitor configs from guest
For security reasons do not assume guest do not change structures it
pass to Qemu.
Guest could change count field while Qemu is copying QXLMonitorsConfig
structure leading to heap corruption.
This patch avoid it reading count only once.

This patch solves CVE-2015-3247.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2015-09-08 16:09:50 +01:00
Frediano Ziglio
39be1c448c avoid to call red_get_streams_timout twice computing timeout
Due to how the MIN macro is defined the function was called twice
unless the compiler could demonstrate that was returning the same
value (which actually is impossible as function as clock_gettime
are not deterministic).

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2015-09-03 16:04:27 +01:00
Marc-André Lureau
59f09e6968 Remove useless pack attribute
Acked-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2015-09-01 14:18:29 +01:00
Marc-André Lureau
82e1592ee1 server: remove srand(time(NULL))
This is clearly not a library responsability.

Acked-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2015-09-01 14:18:25 +01:00
Alon Levy
30eece3e16 server/red_worker: remove redundant spice_warn_if in validate_surface
Acked-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2015-09-01 14:18:21 +01:00
Marc-André Lureau
af76aa6745 server: remove hardcoded RED_MAX_RENDERERS
Acked-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
2015-09-01 14:17:10 +01:00
Frediano Ziglio
055345d597 Simplify set_surface_release_info
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2015-08-27 23:50:29 +01:00
Frediano Ziglio
068bf4e83d prevent integer overflow on 32 bit
On 32 bit machine timespec->tv_sec (time_t) is 32 bit.
Also 1000 * 1000 * 1000 is 32 bit.
The multiplication of 2 32 bit integers gives a 32 bit integer, however
this can overflow.
Converting the first factor to 64 bit before the multiplication solves
the issue.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
2015-08-26 15:24:09 +01:00
Frediano Ziglio
a9e34bd27a worker: remove unused members from Drawable
Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
2015-08-24 13:40:18 +01:00
Alon Levy
510a6b8dca server/red_worker: record to SPICE_WORKER_RECORD_FILENAME
if the environment variable in the title is set and can be
opened for writing a log of all display commands (no cursor
commands yet) and any QXLWorker calls (particularily primary
create and destroy) will be logged to that file, and possible
to replay using the replay utility introduced later.

For an example file (4 MB download, 300 MB after unpack with xz,
these 300 MB are themselves reduced from 1.2GB using zlib compression
for any chunk):

(old file without a header)
http://annarchy.freedesktop.org/~alon/win7_boot_shutdown.cmd.xz

Signed-off-by: Alon Levy <alon@pobox.com>
Signed-off-by: Marc-André Lureau <marcandre.lureau@gmail.com>
2015-08-21 09:38:44 +01:00
Marc-André Lureau
e4bbdc3391 worker: remove unused preload_group_id 2015-08-11 17:24:36 +02:00
Marc-André Lureau
6a38af37fc server: remove unused CursorData 2015-08-11 17:24:36 +02:00
Marc-André Lureau
e3187ebd29 worker: move red_init_*() functions
There is a red_init() methods, we can group all the red_init_*() calls
in it rather than calling red_init() followed by all these calls in our
main function.
2015-08-11 17:21:59 +02:00
Christophe Fergeau
de66161c6e Adjust to new SpiceImageCompress name
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_
2015-07-29 17:40:48 +02:00
Pavel Grunt
071647780d Use desired image compression for the first image
red_marshall_image() allows to use other than QUIC compression only
when auto_lz or auto_glz image compression is set. Other images don't
have the problem because they are compressed using red_compress_image()
2015-07-13 11:52:09 +02:00
Javier Celaya
c914e96fb4 Handle preferred image compression messages 2015-06-30 16:49:29 +02:00
Javier Celaya
22c40b9d1f Use image compress constants from spice-protocol 2015-06-30 16:49:29 +02:00
Francois Gouget
aa22138d05 server: Remove the rate_control_is_active field from MJpegEncoder.
It is redundant with the corresponding callbacks.
2015-06-29 18:04:12 +02:00
Sandy Stutsman
e4a42e50c2 Lock the pixmap image cache for the entire fill_bits call
Locking the individual calls that access the pixmap cache in fill_bits is
not adequately thread safe.  Often a windows guest with multiple monitors
will be sending the same image via different threads.  Both threads can
be in fill_bits at the same time making changes to the cache for the same
image.  This can result in images being deleted before all the client
channels are finished with them or with the same image being send multiple
times.  Here's what can happen with out the lock in fill_bits

On the server in red_worker.c:fill_bits
 Thread 1 calls pixmap_cache_hit for Image A and finds it isn't in cache
 Thread 2 calls pixmap_cache_hit for Image A and finds it isn't in cache

 Thread 1 adds Image 1 to pixmap_cache (1x)
 Thread 2 adds Image 1 to pixmap_cache (2x)

On the client
 Channel 1 adds Image A to image_cache (1x)
 Channel 2 replaces Image A in image_cache (1x)

On server
 Thread 1 sends Image A rendering commands
 Thread N removes Image A from pixmap_cache (image remains - 1x)
 Thread 2 sends Image A rendering commands

On client
 Channe1 renders from Image A
 Channel N removes Image a from image_cache (image is completely removed)
 Channel2 render command hangs waiting for Image A
2015-06-29 13:21:14 +02:00