[PATCH] x86/domctl: Fix unitialized copyback in XEN_DOMCTL_PSR_GET_*

Johann Höpfner posted 1 patch 3 days, 9 hours ago
Patches applied successfully (tree, apply log)
git fetch https://gitlab.com/xen-project/patchew/xen tags/patchew/anWrDspbnvRYCwGZ@cit.tum.de
xen/arch/x86/domctl.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[PATCH] x86/domctl: Fix unitialized copyback in XEN_DOMCTL_PSR_GET_*
Posted by Johann Höpfner 3 days, 9 hours ago
domctl_psr_get_val() copies unitialized stack space back if psr_get_val
fails. Fix by zero-initializing v_.

Fixes: 03f30dc193c8 ("x86: refactor psr: L3 CAT: implement get value flow.")
Signed-off-by: Johann Höpfner <hoepf@cit.tum.de>
---

Consider instead removing the local variable indirection introduced by
03f30dc193c8 and passing &(domctl)->u.psr_alloc.data to psr_get_val
instead or only conditionally setting copyback true.

 xen/arch/x86/domctl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/xen/arch/x86/domctl.c b/xen/arch/x86/domctl.c
index f26990208d..6e42fa383c 100644
--- a/xen/arch/x86/domctl.c
+++ b/xen/arch/x86/domctl.c
@@ -1347,7 +1347,7 @@ long arch_do_domctl(
             break;
 
 #define domctl_psr_get_val(d, domctl, type, copyback) ({    \
-    uint32_t v_;                                            \
+    uint32_t v_ = 0;                                        \
     int r_ = psr_get_val((d), (domctl)->u.psr_alloc.target, \
                          &v_, (type));                      \
                                                             \
-- 
2.53.0


Re: [PATCH] x86/domctl: Fix unitialized copyback in XEN_DOMCTL_PSR_GET_*
Posted by Jan Beulich 1 day ago
On 10.08.2026 00:38, Johann Höpfner wrote:
> domctl_psr_get_val() copies unitialized stack space back if psr_get_val
> fails. Fix by zero-initializing v_.
> 
> Fixes: 03f30dc193c8 ("x86: refactor psr: L3 CAT: implement get value flow.")
> Signed-off-by: Johann Höpfner <hoepf@cit.tum.de>

Reviewed-by: Jan Beulich <jbeulich@suse.com>

> Consider instead removing the local variable indirection introduced by
> 03f30dc193c8 and passing &(domctl)->u.psr_alloc.data to psr_get_val
> instead or only conditionally setting copyback true.

Well - the way you've done it is clearly easiest / most obviously correct.

Jan