public inbox for git-commits@fedoraproject.org
help / color / mirror / Atom feed
From: Karolina Surma <ksurma@redhat.com>
To: git-commits@fedoraproject.org
Subject: [rpms/qemu] eln: * Wed Oct 21 2026 Miroslav Rezanina <mrezanin@redhat.com> - 11.1.0-2
Date: Wed, 25 Nov 2026 08:58:36 GMT [thread overview]
Message-ID: <179559711629.1.7258165014070641999.rpms-qemu-4bb9c1c2bb14@fedoraproject.org> (raw)
A new commit has been pushed.
Repo : rpms/qemu
Branch : eln
Commit : 4bb9c1c2bb14fe094b84f5c25ce55692b5bb8596
Author : Karolina Surma <ksurma@redhat.com>
Date : 2026-11-24T14:13:42-05:00
Stats : +229/-2 in 3 file(s)
URL : https://src.fedoraproject.org/rpms/qemu/c/4bb9c1c2bb14fe094b84f5c25ce55692b5bb8596?branch=eln
Log:
* Wed Oct 21 2026 Miroslav Rezanina <mrezanin@redhat.com> - 11.1.0-2
- kvm-spec-Add-http-to-block_drivers_ro_list.patch [RHEL-276051]
- kvm-block-Fix-corruption-from-broken-RMW-atomicity.patch [RHEL-272836]
- kvm-block-Remove-now-redundant-bdrv_wait_serialising_req.patch [RHEL-272836]
- Resolves: RHEL-276051
(Allow http protocol in qemu-kvm-block-curl)
- Resolves: RHEL-272836
(Data corruption while using multiple iothreads on 4K backend disk)
---
diff --git a/kvm-block-Fix-corruption-from-broken-RMW-atomicity.patch b/kvm-block-Fix-corruption-from-broken-RMW-atomicity.patch
new file mode 100644
index 0000000..f7be24b
--- /dev/null
+++ b/kvm-block-Fix-corruption-from-broken-RMW-atomicity.patch
@@ -0,0 +1,134 @@
+From b3686a78dd821e1c2fb891e33d356f8d549b9fb8 Mon Sep 17 00:00:00 2001
+From: Kevin Wolf <kwolf@redhat.com>
+Date: Fri, 2 Oct 2026 15:21:34 +0200
+Subject: [PATCH 2/3] block: Fix corruption from broken RMW atomicity
+
+RH-Author: Kevin Wolf <kwolf@redhat.com>
+RH-MergeRequest: 525: block: Fix corruption from broken RMW atomicity in 512b-on-4k emulation
+RH-Jira: RHEL-272836
+RH-Acked-by: Eric Blake <eblake@redhat.com>
+RH-Acked-by: Hanna Czenczek <hreitz@redhat.com>
+RH-Commit: [1/2] 20be974c1171027277053b19b718c6aca8aa81d7 (kmwolf/centos-qemu-kvm)
+
+When emulating 512 byte sector devices on top of 4k native host storage,
+QEMU performs a read-modify-write cycle for misaligned write requests.
+These requests are marked as serialising so that any other writes to the
+same 4k block will have to wait and can't overwrite the block in the
+middle, which would make the RMW write back stale data.
+
+In principle, this mechanism works fine, but there is a race condition
+in the implementation: bdrv_find_conflicting_request() assumes that
+req->waiting_for == NULL means that the request is the active owner of
+the data blocks it touches and everyone else has to wait for this
+request. However, there is a window between tracked_request_begin() and
+bdrv_wait_serialising_requests_locked() where any new request has
+req->waiting_for == NULL even if it conflicts with an already running
+serialising request. So at this point, we have seemingly two active
+owners at the same time until the new request checks for conflicts.
+
+For a third request coming in, this isn't a problem, it just might wait
+for a little longer than necessary. However, if the original RMW request
+calls bdrv_wait_serialising_requests_locked() again (which it does in
+bdrv_aligned_pwritev() -> bdrv_co_write_req_prepare() before writing
+back the RMW buffer), it will now wait on the other request that snuck
+in, which is fatal and makes the RMW buffer stale. This scenario causes
+data corruption.
+
+Fix this by checking for conflicts already in tracked_request_begin()
+while holding the bs->reqs_lock mutex, so that the race window is closed
+and req->waiting_for == NULL really has the intended meaning.
+
+For good measure, add an active_owner boolean that is set when a request
+is marked serialising and has completed waiting for other requests, and
+assert that it is not set when waiting for another request, so that in
+the case of another bug, we'd crash instead of causing data corruption.
+
+Cc: qemu-stable@nongnu.org
+Buglink: https://redhat.atlassian.net/browse/RHEL-272836
+Signed-off-by: Kevin Wolf <kwolf@redhat.com>
+Message-ID: <20261002132135.93345-2-kwolf@redhat.com>
+Signed-off-by: Kevin Wolf <kwolf@redhat.com>
+(cherry picked from commit 0bd5a1b3d60cca595e19bb73eec83307259be671)
+Signed-off-by: Kevin Wolf <kwolf@redhat.com>
+---
+ block/io.c | 23 +++++++++++++++++++++++
+ include/block/block_int-common.h | 1 +
+ 2 files changed, 24 insertions(+)
+
+diff --git a/block/io.c b/block/io.c
+index a916b236c3..bd562d472f 100644
+--- a/block/io.c
++++ b/block/io.c
+@@ -50,6 +50,9 @@
+ static int coroutine_fn bdrv_co_do_pwrite_zeroes(BlockDriverState *bs,
+ int64_t offset, int64_t bytes, BdrvRequestFlags flags);
+
++static void coroutine_fn
++bdrv_wait_serialising_requests_locked(BdrvTrackedRequest *self);
++
+ static void GRAPH_RDLOCK
+ bdrv_parent_drained_begin(BlockDriverState *bs, BdrvChild *ignore)
+ {
+@@ -616,6 +619,7 @@ static void coroutine_fn tracked_request_begin(BdrvTrackedRequest *req,
+ .type = type,
+ .co = qemu_coroutine_self(),
+ .serialising = false,
++ .active_owner = false,
+ .overlap_offset = offset,
+ .overlap_bytes = bytes,
+ };
+@@ -624,6 +628,15 @@ static void coroutine_fn tracked_request_begin(BdrvTrackedRequest *req,
+
+ qemu_mutex_lock(&bs->reqs_lock);
+ QLIST_INSERT_HEAD(&bs->tracked_requests, req, list);
++
++ /*
++ * Set .waiting_for while we're holding the lock, otherwise we'd open a race
++ * window where another request in the middle of its RMW cycle starts
++ * waiting for us, leading to potential data corruption if this request
++ * overwrites a block the RMW request has already read.
++ */
++ bdrv_wait_serialising_requests_locked(req);
++
+ qemu_mutex_unlock(&bs->reqs_lock);
+ }
+
+@@ -684,6 +697,15 @@ bdrv_wait_serialising_requests_locked(BdrvTrackedRequest *self)
+ BdrvTrackedRequest *req;
+
+ while ((req = bdrv_find_conflicting_request(self))) {
++ /*
++ * If this request is the active owner of the data blocks it accesses,
++ * no other conflicting request may exist; other requests have to wait
++ * for this one, not the other way around. If this condition is
++ * violated, RMW operations may be interrupted in the middle, operate on
++ * stale data and introduce data corruption.
++ */
++ assert(!self->active_owner);
++
+ self->waiting_for = req;
+ qemu_co_queue_wait(&req->wait_queue, &self->bs->reqs_lock);
+ self->waiting_for = NULL;
+@@ -803,6 +825,7 @@ void coroutine_fn bdrv_make_request_serialising(BdrvTrackedRequest *req,
+
+ tracked_request_set_serialising(req, align);
+ bdrv_wait_serialising_requests_locked(req);
++ req->active_owner = true;
+
+ qemu_mutex_unlock(&req->bs->reqs_lock);
+ }
+diff --git a/include/block/block_int-common.h b/include/block/block_int-common.h
+index 147c08155f..46428b034d 100644
+--- a/include/block/block_int-common.h
++++ b/include/block/block_int-common.h
+@@ -80,6 +80,7 @@ typedef struct BdrvTrackedRequest {
+ enum BdrvTrackedRequestType type;
+
+ bool serialising;
++ bool active_owner;
+ int64_t overlap_offset;
+ int64_t overlap_bytes;
+
+--
+2.56.0
+
diff --git a/kvm-block-Remove-now-redundant-bdrv_wait_serialising_req.patch b/kvm-block-Remove-now-redundant-bdrv_wait_serialising_req.patch
new file mode 100644
index 0000000..56f6761
--- /dev/null
+++ b/kvm-block-Remove-now-redundant-bdrv_wait_serialising_req.patch
@@ -0,0 +1,81 @@
+From fa6154b98974fd5a90ba6b834f9cc30a004a35b7 Mon Sep 17 00:00:00 2001
+From: Kevin Wolf <kwolf@redhat.com>
+Date: Fri, 2 Oct 2026 15:21:35 +0200
+Subject: [PATCH 3/3] block: Remove now redundant
+ bdrv_wait_serialising_requests() calls
+
+RH-Author: Kevin Wolf <kwolf@redhat.com>
+RH-MergeRequest: 525: block: Fix corruption from broken RMW atomicity in 512b-on-4k emulation
+RH-Jira: RHEL-272836
+RH-Acked-by: Eric Blake <eblake@redhat.com>
+RH-Acked-by: Hanna Czenczek <hreitz@redhat.com>
+RH-Commit: [2/2] a07a1fce777e00baaa2cd1cc63d6b3d9142c8758 (kmwolf/centos-qemu-kvm)
+
+All callers of bdrv_wait_serialising_requests() (as opposed to
+bdrv_wait_serialising_requests_locked()) are just duplicating the check
+that tracked_request_begin() already performs now. After removing them,
+bdrv_wait_serialising_requests() has no callers left and can go as well.
+
+Signed-off-by: Kevin Wolf <kwolf@redhat.com>
+Message-ID: <20261002132135.93345-3-kwolf@redhat.com>
+Signed-off-by: Kevin Wolf <kwolf@redhat.com>
+(cherry picked from commit cf4f672c11d663f87462cfd99a92124b30804e99)
+Signed-off-by: Kevin Wolf <kwolf@redhat.com>
+---
+ block/io.c | 19 -------------------
+ 1 file changed, 19 deletions(-)
+
+diff --git a/block/io.c b/block/io.c
+index bd562d472f..1c05dd106d 100644
+--- a/block/io.c
++++ b/block/io.c
+@@ -802,20 +802,6 @@ void bdrv_dec_in_flight(BlockDriverState *bs)
+ bdrv_wakeup(bs);
+ }
+
+-static void coroutine_fn
+-bdrv_wait_serialising_requests(BdrvTrackedRequest *self)
+-{
+- BlockDriverState *bs = self->bs;
+-
+- if (!qatomic_read(&bs->serialising_in_flight)) {
+- return;
+- }
+-
+- qemu_mutex_lock(&bs->reqs_lock);
+- bdrv_wait_serialising_requests_locked(self);
+- qemu_mutex_unlock(&bs->reqs_lock);
+-}
+-
+ void coroutine_fn bdrv_make_request_serialising(BdrvTrackedRequest *req,
+ uint64_t align)
+ {
+@@ -1383,8 +1369,6 @@ bdrv_aligned_preadv(BdrvChild *child, BdrvTrackedRequest *req,
+ * it ensures that the CoR read and write operations are atomic and
+ * guest writes cannot interleave between them. */
+ bdrv_make_request_serialising(req, bdrv_get_cluster_size(bs));
+- } else {
+- bdrv_wait_serialising_requests(req);
+ }
+
+ if (flags & BDRV_REQ_COPY_ON_READ) {
+@@ -2021,8 +2005,6 @@ bdrv_co_write_req_prepare(BdrvChild *child, int64_t offset, int64_t bytes,
+ }
+
+ bdrv_wait_serialising_requests_locked(req);
+- } else {
+- bdrv_wait_serialising_requests(req);
+ }
+
+ assert(req->overlap_offset <= offset);
+@@ -3530,7 +3512,6 @@ static int coroutine_fn GRAPH_RDLOCK bdrv_co_copy_range_internal(
+
+ /* BDRV_REQ_SERIALISING is only for write operation */
+ assert(!(read_flags & BDRV_REQ_SERIALISING));
+- bdrv_wait_serialising_requests(&req);
+
+ ret = src->bs->drv->bdrv_co_copy_range_from(src->bs,
+ src, src_offset,
+--
+2.56.0
+
diff --git a/qemu.spec b/qemu.spec
index 0aaf7d3..8123da2 100644
--- a/qemu.spec
+++ b/qemu.spec
@@ -93,7 +93,7 @@
%global target_list %{kvm_target}-softmmu
%global block_drivers_rw_list qcow2,raw,file,host_device,nbd,iscsi,rbd,blkdebug,luks,null-co,nvme,copy-on-read,throttle,compress,virtio-blk-vhost-vdpa,virtio-blk-vfio-pci,virtio-blk-vhost-user,io_uring,nvme-io_uring
-%global block_drivers_ro_list vdi,vmdk,vhdx,vpc,https
+%global block_drivers_ro_list vdi,vmdk,vhdx,vpc,http,https
%define qemudocdir %{_docdir}/%{name}
%global firmwaredirs "%{_datadir}/qemu-firmware:%{_datadir}/ipxe/qemu:%{_datadir}/seavgabios:%{_datadir}/seabios"
@@ -201,6 +201,10 @@ Patch0031: 0031-x86-pin-x-migrate-error-code-false-on-pre-10.4-RHEL-.patch
Patch0032: 0032-hw-arm-virt-add-new-machine-type-virt-rhel10.4.0.patch
Patch0033: 0033-s390x-add-new-machine-type-s390-ccw-virtio-rhel10.4..patch
Patch0034: 0034-q35-add-new-machine-type-pc-q35-rhel10.4.0.patch
+# For RHEL-272836 - Data corruption while using multiple iothreads on 4K backend disk
+Patch35: kvm-block-Fix-corruption-from-broken-RMW-atomicity.patch
+# For RHEL-272836 - Data corruption while using multiple iothreads on 4K backend disk
+Patch36: kvm-block-Remove-now-redundant-bdrv_wait_serialising_req.patch
%if %{have_clang}
BuildRequires: clang
@@ -1290,7 +1294,15 @@ useradd -r -u 107 -g qemu -G kvm -d / -s /sbin/nologin \
%endif
%changelog
-* Thu Oct 15 2026 Yaakov Selkowitz <yselkowi@redhat.com> - 11.1.0-2
+* Wed Oct 21 2026 Miroslav Rezanina <mrezanin@redhat.com> - 11.1.0-2
+- kvm-spec-Add-http-to-block_drivers_ro_list.patch [RHEL-276051]
+- kvm-block-Fix-corruption-from-broken-RMW-atomicity.patch [RHEL-272836]
+- kvm-block-Remove-now-redundant-bdrv_wait_serialising_req.patch [RHEL-272836]
+- Resolves: RHEL-276051
+ (Allow http protocol in qemu-kvm-block-curl)
+- Resolves: RHEL-272836
+ (Data corruption while using multiple iothreads on 4K backend disk)
+- Use the default Sphinx theme for documentation
- Drop unnecessary wheel dependency
* Thu Oct 08 2026 Miroslav Rezanina <mrezanin@redhat.com> - 11.1.0-1
reply other threads:[~2026-11-25 8:58 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=179559711629.1.7258165014070641999.rpms-qemu-4bb9c1c2bb14@fedoraproject.org \
--to=ksurma@redhat.com \
--cc=git-commits@fedoraproject.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