From: Greg Kroah-Hartman Date: Mon, 15 Apr 2024 12:46:56 +0000 (+0200) Subject: 5.4-stable patches X-Git-Tag: v5.15.156~43 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=ae57c2cb23e758018439f4002c0b8d34eb55b9d6;p=thirdparty%2Fkernel%2Fstable-queue.git 5.4-stable patches added patches: btrfs-qgroup-correctly-model-root-qgroup-rsv-in-convert.patch drm-client-fully-protect-modes-with-dev-mode_config.mutex.patch vhost-add-smp_rmb-in-vhost_vq_avail_empty.patch --- diff --git a/queue-5.4/btrfs-qgroup-correctly-model-root-qgroup-rsv-in-convert.patch b/queue-5.4/btrfs-qgroup-correctly-model-root-qgroup-rsv-in-convert.patch new file mode 100644 index 00000000000..8a265b2bc89 --- /dev/null +++ b/queue-5.4/btrfs-qgroup-correctly-model-root-qgroup-rsv-in-convert.patch @@ -0,0 +1,38 @@ +From 141fb8cd206ace23c02cd2791c6da52c1d77d42a Mon Sep 17 00:00:00 2001 +From: Boris Burkov +Date: Tue, 19 Mar 2024 10:54:22 -0700 +Subject: btrfs: qgroup: correctly model root qgroup rsv in convert + +From: Boris Burkov + +commit 141fb8cd206ace23c02cd2791c6da52c1d77d42a upstream. + +We use add_root_meta_rsv and sub_root_meta_rsv to track prealloc and +pertrans reservations for subvolumes when quotas are enabled. The +convert function does not properly increment pertrans after decrementing +prealloc, so the count is not accurate. + +Note: we check that the fs is not read-only to mirror the logic in +qgroup_convert_meta, which checks that before adding to the pertrans rsv. + +Fixes: 8287475a2055 ("btrfs: qgroup: Use root::qgroup_meta_rsv_* to record qgroup meta reserved space") +CC: stable@vger.kernel.org # 6.1+ +Reviewed-by: Qu Wenruo +Signed-off-by: Boris Burkov +Signed-off-by: David Sterba +Signed-off-by: Greg Kroah-Hartman +--- + fs/btrfs/qgroup.c | 2 ++ + 1 file changed, 2 insertions(+) + +--- a/fs/btrfs/qgroup.c ++++ b/fs/btrfs/qgroup.c +@@ -4061,6 +4061,8 @@ void btrfs_qgroup_convert_reserved_meta( + BTRFS_QGROUP_RSV_META_PREALLOC); + trace_qgroup_meta_convert(root, num_bytes); + qgroup_convert_meta(fs_info, root->root_key.objectid, num_bytes); ++ if (!sb_rdonly(fs_info->sb)) ++ add_root_meta_rsv(root, num_bytes, BTRFS_QGROUP_RSV_META_PERTRANS); + } + + /* diff --git a/queue-5.4/drm-client-fully-protect-modes-with-dev-mode_config.mutex.patch b/queue-5.4/drm-client-fully-protect-modes-with-dev-mode_config.mutex.patch new file mode 100644 index 00000000000..cb4fc246105 --- /dev/null +++ b/queue-5.4/drm-client-fully-protect-modes-with-dev-mode_config.mutex.patch @@ -0,0 +1,56 @@ +From 3eadd887dbac1df8f25f701e5d404d1b90fd0fea Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Ville=20Syrj=C3=A4l=C3=A4?= +Date: Thu, 4 Apr 2024 23:33:25 +0300 +Subject: drm/client: Fully protect modes[] with dev->mode_config.mutex +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +From: Ville Syrjälä + +commit 3eadd887dbac1df8f25f701e5d404d1b90fd0fea upstream. + +The modes[] array contains pointers to modes on the connectors' +mode lists, which are protected by dev->mode_config.mutex. +Thus we need to extend modes[] the same protection or by the +time we use it the elements may already be pointing to +freed/reused memory. + +Cc: stable@vger.kernel.org +Closes: https://gitlab.freedesktop.org/drm/intel/-/issues/10583 +Signed-off-by: Ville Syrjälä +Link: https://patchwork.freedesktop.org/patch/msgid/20240404203336.10454-2-ville.syrjala@linux.intel.com +Reviewed-by: Dmitry Baryshkov +Reviewed-by: Jani Nikula +Reviewed-by: Thomas Zimmermann +Signed-off-by: Greg Kroah-Hartman +--- + drivers/gpu/drm/drm_client_modeset.c | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +--- a/drivers/gpu/drm/drm_client_modeset.c ++++ b/drivers/gpu/drm/drm_client_modeset.c +@@ -700,6 +700,7 @@ int drm_client_modeset_probe(struct drm_ + unsigned int total_modes_count = 0; + struct drm_client_offset *offsets; + unsigned int connector_count = 0; ++ /* points to modes protected by mode_config.mutex */ + struct drm_display_mode **modes; + struct drm_crtc **crtcs; + int i, ret = 0; +@@ -768,7 +769,6 @@ int drm_client_modeset_probe(struct drm_ + drm_client_pick_crtcs(client, connectors, connector_count, + crtcs, modes, 0, width, height); + } +- mutex_unlock(&dev->mode_config.mutex); + + drm_client_modeset_release(client); + +@@ -798,6 +798,7 @@ int drm_client_modeset_probe(struct drm_ + modeset->y = offset->y; + } + } ++ mutex_unlock(&dev->mode_config.mutex); + + mutex_unlock(&client->modeset_mutex); + out: diff --git a/queue-5.4/series b/queue-5.4/series index 7cf7542952b..409acfe6e1d 100644 --- a/queue-5.4/series +++ b/queue-5.4/series @@ -15,3 +15,6 @@ net-mlx5-properly-link-new-fs-rules-into-the-tree.patch af_unix-do-not-use-atomic-ops-for-unix_sk-sk-infligh.patch af_unix-fix-garbage-collector-racing-against-connect.patch net-ena-fix-potential-sign-extension-issue.patch +btrfs-qgroup-correctly-model-root-qgroup-rsv-in-convert.patch +drm-client-fully-protect-modes-with-dev-mode_config.mutex.patch +vhost-add-smp_rmb-in-vhost_vq_avail_empty.patch diff --git a/queue-5.4/vhost-add-smp_rmb-in-vhost_vq_avail_empty.patch b/queue-5.4/vhost-add-smp_rmb-in-vhost_vq_avail_empty.patch new file mode 100644 index 00000000000..911fe9cd012 --- /dev/null +++ b/queue-5.4/vhost-add-smp_rmb-in-vhost_vq_avail_empty.patch @@ -0,0 +1,70 @@ +From 22e1992cf7b034db5325660e98c41ca5afa5f519 Mon Sep 17 00:00:00 2001 +From: Gavin Shan +Date: Thu, 28 Mar 2024 10:21:47 +1000 +Subject: vhost: Add smp_rmb() in vhost_vq_avail_empty() + +From: Gavin Shan + +commit 22e1992cf7b034db5325660e98c41ca5afa5f519 upstream. + +A smp_rmb() has been missed in vhost_vq_avail_empty(), spotted by +Will. Otherwise, it's not ensured the available ring entries pushed +by guest can be observed by vhost in time, leading to stale available +ring entries fetched by vhost in vhost_get_vq_desc(), as reported by +Yihuang Yu on NVidia's grace-hopper (ARM64) platform. + + /home/gavin/sandbox/qemu.main/build/qemu-system-aarch64 \ + -accel kvm -machine virt,gic-version=host -cpu host \ + -smp maxcpus=1,cpus=1,sockets=1,clusters=1,cores=1,threads=1 \ + -m 4096M,slots=16,maxmem=64G \ + -object memory-backend-ram,id=mem0,size=4096M \ + : \ + -netdev tap,id=vnet0,vhost=true \ + -device virtio-net-pci,bus=pcie.8,netdev=vnet0,mac=52:54:00:f1:26:b0 + : + guest# netperf -H 10.26.1.81 -l 60 -C -c -t UDP_STREAM + virtio_net virtio0: output.0:id 100 is not a head! + +Add the missed smp_rmb() in vhost_vq_avail_empty(). When tx_can_batch() +returns true, it means there's still pending tx buffers. Since it might +read indices, so it still can bypass the smp_rmb() in vhost_get_vq_desc(). +Note that it should be safe until vq->avail_idx is changed by commit +275bf960ac697 ("vhost: better detection of available buffers"). + +Fixes: 275bf960ac69 ("vhost: better detection of available buffers") +Cc: # v4.11+ +Reported-by: Yihuang Yu +Suggested-by: Will Deacon +Signed-off-by: Gavin Shan +Acked-by: Jason Wang +Message-Id: <20240328002149.1141302-2-gshan@redhat.com> +Signed-off-by: Michael S. Tsirkin +Reviewed-by: Stefano Garzarella +Signed-off-by: Greg Kroah-Hartman +--- + drivers/vhost/vhost.c | 12 +++++++++++- + 1 file changed, 11 insertions(+), 1 deletion(-) + +--- a/drivers/vhost/vhost.c ++++ b/drivers/vhost/vhost.c +@@ -2519,9 +2519,19 @@ bool vhost_vq_avail_empty(struct vhost_d + r = vhost_get_avail_idx(vq, &avail_idx); + if (unlikely(r)) + return false; ++ + vq->avail_idx = vhost16_to_cpu(vq, avail_idx); ++ if (vq->avail_idx != vq->last_avail_idx) { ++ /* Since we have updated avail_idx, the following ++ * call to vhost_get_vq_desc() will read available ++ * ring entries. Make sure that read happens after ++ * the avail_idx read. ++ */ ++ smp_rmb(); ++ return false; ++ } + +- return vq->avail_idx == vq->last_avail_idx; ++ return true; + } + EXPORT_SYMBOL_GPL(vhost_vq_avail_empty); +