[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 2/9] seqlock: fix seqlock_write_unlock_impl function
From: |
Paolo Bonzini |
Subject: |
[PULL 2/9] seqlock: fix seqlock_write_unlock_impl function |
Date: |
Wed, 12 Feb 2020 17:41:22 +0100 |
From: Luc Michel <address@hidden>
The seqlock write unlock function was incorrectly calling
seqlock_write_begin() instead of seqlock_write_end(), and was releasing
the lock before incrementing the sequence. This could lead to a race
condition and a corrupted sequence number becoming odd even though the
lock is not held.
Signed-off-by: Luc Michel <address@hidden>
Reviewed-by: Philippe Mathieu-Daudé <address@hidden>
Message-Id: <address@hidden>
Fixes: 988fcafc73 ("seqlock: add QemuLockable support", 2018-08-23)
Signed-off-by: Paolo Bonzini <address@hidden>
---
include/qemu/seqlock.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/include/qemu/seqlock.h b/include/qemu/seqlock.h
index fd408b7ec5..8b6b4ee4bb 100644
--- a/include/qemu/seqlock.h
+++ b/include/qemu/seqlock.h
@@ -55,11 +55,11 @@ static inline void seqlock_write_lock_impl(QemuSeqLock *sl,
QemuLockable *lock)
#define seqlock_write_lock(sl, lock) \
seqlock_write_lock_impl(sl, QEMU_MAKE_LOCKABLE(lock))
-/* Lock out other writers and update the count. */
+/* Update the count and release the lock. */
static inline void seqlock_write_unlock_impl(QemuSeqLock *sl, QemuLockable
*lock)
{
+ seqlock_write_end(sl);
qemu_lockable_unlock(lock);
- seqlock_write_begin(sl);
}
#define seqlock_write_unlock(sl, lock) \
seqlock_write_unlock_impl(sl, QEMU_MAKE_LOCKABLE(lock))
--
2.21.0
- [PULL 0/9] Mini misc patches queue for 2020-02-12, Paolo Bonzini, 2020/02/12
- [PULL 1/9] vl: Don't mismatch g_strsplit()/g_free(), Paolo Bonzini, 2020/02/12
- [PULL 2/9] seqlock: fix seqlock_write_unlock_impl function,
Paolo Bonzini <=
- [PULL 3/9] Remove support for CLOCK_MONOTONIC not being defined, Paolo Bonzini, 2020/02/12
- [PULL 4/9] minikconf: accept alnum identifiers, Paolo Bonzini, 2020/02/12
- [PULL 5/9] exec: do not define use_icount for user-mode emulation, Paolo Bonzini, 2020/02/12
- [PULL 6/9] build: move TARGET_GPROF to config-host.mak, Paolo Bonzini, 2020/02/12
- [PULL 7/9] target/i386: fix TCG UCODE_REV access, Paolo Bonzini, 2020/02/12
- [PULL 8/9] target/i386: check for availability of MSR_IA32_UCODE_REV as an emulated MSR, Paolo Bonzini, 2020/02/12
- [PULL 9/9] target/i386: enable monitor and ucode revision with -cpu max, Paolo Bonzini, 2020/02/12
- Re: [PULL 0/9] Mini misc patches queue for 2020-02-12, Peter Maydell, 2020/02/13