]> git.hungrycats.org Git - linux/commitdiff
KVM: x86: Zero reserved synic flags when delivering message to avoid stack leak
authorSean Christopherson <seanjc@google.com>
Wed, 26 Aug 2026 18:44:49 +0000 (11:44 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 6 Nov 2026 17:06:09 +0000 (12:06 -0500)
commit 2616f497506a772db53e7bb1024cde50b4c165e0 upstream.

Ensure all reserved flags are zeroed when setting the msg_pending flag as
part of SynIC message delivery, as setting only msg_pending can leak seven
bits of kernel stack data to the guest.  E.g. gcc typically uses a
bitwise-OR to set the msg_pending flag, without initializing the on-stack
variable.

Precisely zero the flags, e.g. as opposed to zeroing the entire structure,
to make it somewhat more obvious that the flags *need* to be zeroed.  E.g.
it would be quite easy to misread the initial read of guest memory and
think that zeroing the entire structure is completely superfluous.

Fixes: 3a0e7731724f ("x86: kvm: hyperv: simplify SynIC message delivery")
Cc: stable@vger.kernel.org
Reported-by: Stefan Teodorescu <fane@google.com>
Reviewed-by: Vitaly Kuznetsov <vkuznets@redhat.com>
Link: https://patch.msgid.link/20260826184449.814130-1-seanjc@google.com
Signed-off-by: Sean Christopherson <seanjc@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
arch/x86/kvm/hyperv.c

index 284adaf508688f2e14881a1df1725d461a74e40f..a72348edd239da99be93f97de7106e4d2f4529b7 100644 (file)
@@ -798,7 +798,9 @@ static int synic_deliver_msg(struct kvm_vcpu_hv_synic *synic, u32 sint,
                if (no_retry)
                        return 0;
 
+               hv_hdr.message_flags.asu8 = 0;
                hv_hdr.message_flags.msg_pending = 1;
+
                r = kvm_vcpu_write_guest_page(vcpu, msg_page_gfn,
                                              &hv_hdr.message_flags,
                                              msg_off +