]> xenbits.xensource.com Git - xen.git/commit
xen/evtchn: Add missing barriers when accessing/allocating an event channel
authorJulien Grall <jgrall@amazon.com>
Tue, 22 Sep 2020 15:08:00 +0000 (17:08 +0200)
committerJan Beulich <jbeulich@suse.com>
Tue, 22 Sep 2020 15:08:00 +0000 (17:08 +0200)
commit253a1e64d30e09ae089a060e364a01b4d442d550
tree10d51206ee1afca61ae81b6c2df6dd9cf0abfcde
parent3e039e12ecfdefbf3ecbc5a63052620a1fe51ad5
xen/evtchn: Add missing barriers when accessing/allocating an event channel

While the allocation of a bucket is always performed with the per-domain
lock, the bucket may be accessed without the lock taken (for instance, see
evtchn_send()).

Instead such sites relies on port_is_valid() to return a non-zero value
when the port has a struct evtchn associated to it. The function will
mostly check whether the port is less than d->valid_evtchns as all the
buckets/event channels should be allocated up to that point.

Unfortunately a compiler is free to re-order the assignment in
evtchn_allocate_port() so it would be possible to have d->valid_evtchns
updated before the new bucket has finish to allocate.

Additionally on Arm, even if this was compiled "correctly", the
processor can still re-order the memory access.

Add a write memory barrier in the allocation side and a read memory
barrier when the port is valid to prevent any re-ordering issue.

This is XSA-340.

Reported-by: Julien Grall <jgrall@amazon.com>
Signed-off-by: Julien Grall <jgrall@amazon.com>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
xen/common/event_channel.c
xen/include/xen/event.h