qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: Luc Michel <luc.michel@greensocs.com>, qemu-devel@nongnu.org
Subject: Re: [PATCH] seqlock: fix seqlock_write_unlock_impl function
Date: Thu, 30 Jan 2020 01:27:13 +0100	[thread overview]
Message-ID: <b1ce57c0-7947-e569-cbcb-f47e5b5b3aff@redhat.com> (raw)
In-Reply-To: <20200129144948.2161551-1-luc.michel@greensocs.com>

On 29/01/20 15:49, Luc Michel wrote:
> 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 <luc.michel@greensocs.com>
> ---
>  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
> @@ -53,15 +53,15 @@ static inline void seqlock_write_lock_impl(QemuSeqLock *sl, QemuLockable *lock)
>      seqlock_write_begin(sl);
>  }
>  #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))
>  
>  
> 

Queued, thanks very much.

Paolo



      parent reply	other threads:[~2020-01-30  0:28 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-29 14:49 [PATCH] seqlock: fix seqlock_write_unlock_impl function Luc Michel
2020-01-29 15:49 ` Philippe Mathieu-Daudé
2020-01-30  0:27 ` Paolo Bonzini [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=b1ce57c0-7947-e569-cbcb-f47e5b5b3aff@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=luc.michel@greensocs.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).