lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <Y1pW9AeKjKNDGb5L@anrayabh-desk>
Date:   Thu, 27 Oct 2022 15:31:24 +0530
From:   Anirudh Rayabharam <anrayabh@...ux.microsoft.com>
To:     "Michael Kelley (LINUX)" <mikelley@...rosoft.com>
Cc:     KY Srinivasan <kys@...rosoft.com>,
        Haiyang Zhang <haiyangz@...rosoft.com>,
        Stephen Hemminger <sthemmin@...rosoft.com>,
        "wei.liu@...nel.org" <wei.liu@...nel.org>,
        Dexuan Cui <decui@...rosoft.com>,
        "tglx@...utronix.de" <tglx@...utronix.de>,
        "mingo@...hat.com" <mingo@...hat.com>,
        "bp@...en8.de" <bp@...en8.de>,
        "dave.hansen@...ux.intel.com" <dave.hansen@...ux.intel.com>,
        "x86@...nel.org" <x86@...nel.org>, "hpa@...or.com" <hpa@...or.com>,
        "daniel.lezcano@...aro.org" <daniel.lezcano@...aro.org>,
        Arnd Bergmann <arnd@...db.de>,
        "linux-hyperv@...r.kernel.org" <linux-hyperv@...r.kernel.org>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
        "linux-arch@...r.kernel.org" <linux-arch@...r.kernel.org>,
        "kumarpraveen@...ux.microsoft.com" <kumarpraveen@...ux.microsoft.com>,
        "mail@...rudhrb.com" <mail@...rudhrb.com>
Subject: Re: [PATCH 1/2] x86/hyperv: fix invalid writes to MSRs during root
 partition kexec

On Wed, Oct 26, 2022 at 02:58:16PM +0000, Michael Kelley (LINUX) wrote:
> From: Anirudh Rayabharam <anrayabh@...ux.microsoft.com> Sent: Wednesday, October 26, 2022 6:47 AM
> > 
> > hv_cleanup resets the hypercall page by setting the MSR to 0. However,
> > the root partition is not allowed to write to the GPA bits of the MSR.
> > Instead, it uses the hypercall page provided by the MSR. Similar is the
> > case with the reference TSC MSR.
> > 
> > Clear only the enable bit instead of zeroing the entire MSR to make
> > the code valid for root partition too.
> 
> When the enable bit is cleared (but not the PFN) in the MSR, do we know
> for sure that Hyper-V removes the overlay page for the PFN?  Making sure
> that the overlay page is removed is the main reason for clearing the entire
> MSR.   If we're going to leave the PFN in place and just clear the enable bit,
> we need to confirm with the Hyper-V guys that the overlay page will be
> removed.

I checked the hypervisor code. Just clearing the enable bit does cause
the overlay page to be unmapped by the hypervisor.

Thanks,
Anirudh.

> 
> Michael
> 
> > 
> > Signed-off-by: Anirudh Rayabharam <anrayabh@...ux.microsoft.com>
> > ---
> >  arch/x86/hyperv/hv_init.c | 9 ++++++---
> >  1 file changed, 6 insertions(+), 3 deletions(-)
> > 
> > diff --git a/arch/x86/hyperv/hv_init.c b/arch/x86/hyperv/hv_init.c
> > index 29774126e931..76ff63d69461 100644
> > --- a/arch/x86/hyperv/hv_init.c
> > +++ b/arch/x86/hyperv/hv_init.c
> > @@ -537,6 +537,7 @@ void __init hyperv_init(void)
> >  void hyperv_cleanup(void)
> >  {
> >  	union hv_x64_msr_hypercall_contents hypercall_msr;
> > +	u64 tsc_msr;
> > 
> >  	unregister_syscore_ops(&hv_syscore_ops);
> > 
> > @@ -552,12 +553,14 @@ void hyperv_cleanup(void)
> >  	hv_hypercall_pg = NULL;
> > 
> >  	/* Reset the hypercall page */
> > -	hypercall_msr.as_uint64 = 0;
> > +	rdmsrl(HV_X64_MSR_HYPERCALL, hypercall_msr.as_uint64);
> > +	hypercall_msr.enable = 0;
> >  	wrmsrl(HV_X64_MSR_HYPERCALL, hypercall_msr.as_uint64);
> > 
> >  	/* Reset the TSC page */
> > -	hypercall_msr.as_uint64 = 0;
> > -	wrmsrl(HV_X64_MSR_REFERENCE_TSC, hypercall_msr.as_uint64);
> > +	rdmsrl(HV_X64_MSR_REFERENCE_TSC, tsc_msr);
> > +	tsc_msr &= ~BIT_ULL(0);
> > +	wrmsrl(HV_X64_MSR_REFERENCE_TSC, tsc_msr);
> >  }
> > 
> >  void hyperv_report_panic(struct pt_regs *regs, long err, bool in_die)
> > --
> > 2.34.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ