summaryrefslogtreecommitdiffstats
path: root/authz
diff options
context:
space:
mode:
authorDaniel P. Berrangé2019-03-19 16:47:47 +0100
committerDaniel P. Berrangé2019-04-02 14:52:02 +0200
commitb4682a63f86ed81abcaa543ea6135e17f9e99d01 (patch)
treeb5096dd2bc5394a56e9eeb3fee0cd268201b60e4 /authz
parentfilemon: ensure watch IDs are unique to QFileMonitor scope (diff)
downloadqemu-b4682a63f86ed81abcaa543ea6135e17f9e99d01.tar.gz
qemu-b4682a63f86ed81abcaa543ea6135e17f9e99d01.tar.xz
qemu-b4682a63f86ed81abcaa543ea6135e17f9e99d01.zip
filemon: fix watch IDs to avoid potential wraparound issues
Watch IDs are allocated from incrementing a int counter against the QFileMonitor object. In very long life QEMU processes with a huge amount of USB MTP activity creating & deleting directories it is just about conceivable that the int counter can wrap around. This would result in incorrect behaviour of the file monitor watch APIs due to clashing watch IDs. Instead of trying to detect this situation, this patch changes the way watch IDs are allocated. It is turned into an int64_t variable where the high 32 bits are set from the underlying inotify "int" ID. This gives an ID that is guaranteed unique for the directory as a whole, and we can rely on the kernel to enforce this. QFileMonitor then sets the low 32 bits from a per-directory counter. The USB MTP device only sets watches on the directory as a whole, not files within, so there is no risk of guest triggered wrap around on the low 32 bits. Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com> Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
Diffstat (limited to 'authz')
-rw-r--r--authz/listfile.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/authz/listfile.c b/authz/listfile.c
index d4579767e7..bc2b58ef6d 100644
--- a/authz/listfile.c
+++ b/authz/listfile.c
@@ -93,7 +93,7 @@ qauthz_list_file_load(QAuthZListFile *fauthz, Error **errp)
static void
-qauthz_list_file_event(int wd G_GNUC_UNUSED,
+qauthz_list_file_event(int64_t wd G_GNUC_UNUSED,
QFileMonitorEvent ev G_GNUC_UNUSED,
const char *name G_GNUC_UNUSED,
void *opaque)