]> git.ipfire.org Git - thirdparty/libvirt.git/commit
xen: fix race in refresh of config cache
authorDaniel P. Berrange <berrange@redhat.com>
Fri, 11 Sep 2015 13:15:50 +0000 (14:15 +0100)
committerCole Robinson <crobinso@redhat.com>
Tue, 22 Sep 2015 00:18:05 +0000 (20:18 -0400)
commit9372343f7cbe5c8f1bf0a0eb87ad1ddcdcd15503
tree5e77731cd23dde214b75187e51971e36e23241c7
parentb84e9ef24b7369653d3bf3ed17ef8522ff678a49
xen: fix race in refresh of config cache

The xenXMConfigCacheRefresh method scans /etc/xen and loads
all config files it finds. It then scans its internal hash
table and purges any (previously) loaded config files whose
refresh timestamp does not match the timestamp recorded at
the start of xenXMConfigCacheRefresh(). There is unfortunately
a subtle flaw in this, because if loading the config files
takes longer than 1 second, some of the config files will
have a refresh timestamp that is 1 or more seconds different
(newer) than is checked for. So we immediately purge a bunch
of valid config files we just loaded.

To avoid this flaw, we must pass the timestamp we record at
the start of xenXMConfigCacheRefresh() into the
xenXMConfigCacheAddFile() method, instead of letting the
latter call time(NULL) again.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
(cherry picked from commit 427067f7ed880abb053ffe8f5b904b0be4af8195)
src/xen/xen_inotify.c
src/xen/xm_internal.c
src/xen/xm_internal.h