xenoprof: limit consumption of shared buffer data
authorJan Beulich <jbeulich@suse.com>
Tue, 14 Apr 2020 13:02:37 +0000 (15:02 +0200)
committerJan Beulich <jbeulich@suse.com>
Tue, 14 Apr 2020 13:02:37 +0000 (15:02 +0200)
commit7900cb7c18b5ec5d379884166b0db35ebe3846e0
treeb8b665afc6b4d73a5107aa5c78f78e476b5916a2
parent06a5a277c7262d7ca473a8eee3cdce3e2790186e
xenoprof: limit consumption of shared buffer data

Since a shared buffer can be written to by the guest, we may only read
the head and tail pointers from there (all other fields should only ever
be written to). Furthermore, for any particular operation the two values
must be read exactly once, with both checks and consumption happening
with the thus read values. (The backtrace related xenoprof_buf_space()
use in xenoprof_log_event() is an exception: The values used there get
re-checked by every subsequent xenoprof_add_sample().)

Since that code needed touching, also fix the double increment of the
lost samples count in case the backtrace related xenoprof_add_sample()
invocation in xenoprof_log_event() fails.

Where code is being touched anyway, add const as appropriate, but take
the opportunity to entirely drop the now unused domain parameter of
xenoprof_buf_space().

This is part of XSA-313.

Reported-by: Ilja Van Sprundel <ivansprundel@ioactive.com>
Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: George Dunlap <george.dunlap@citrix.com>
Reviewed-by: Wei Liu <wl@xen.org>
master commit: 50ef9a3cb26e2f9383f6fdfbed361d8f174bae9f
master date: 2020-04-14 14:33:19 +0200
xen/common/xenoprof.c
xen/include/xen/xenoprof.h