xenoprof: limit consumption of shared buffer data
authorJan Beulich <jbeulich@suse.com>
Tue, 14 Apr 2020 12:33:19 +0000 (14:33 +0200)
committerJan Beulich <jbeulich@suse.com>
Tue, 14 Apr 2020 12:33:19 +0000 (14:33 +0200)
commit50ef9a3cb26e2f9383f6fdfbed361d8f174bae9f
tree183c43ff03ee3e6e1d60805b3be2da9d95f639fb
parent0763a7ebfcdad66cf9e5475a1301eefb29bae9ed
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>
xen/common/xenoprof.c
xen/include/xen/xenoprof.h