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: <ZHoGEwFqx3kJrmJe@google.com>
Date:   Fri, 2 Jun 2023 08:09:07 -0700
From:   Sean Christopherson <seanjc@...gle.com>
To:     Robert Hoo <robert.hoo.linux@...il.com>
Cc:     Paolo Bonzini <pbonzini@...hat.com>, kvm@...r.kernel.org,
        linux-kernel@...r.kernel.org, Li RongQing <lirongqing@...du.com>,
        Yong He <zhuangel570@...il.com>,
        Kai Huang <kai.huang@...el.com>
Subject: Re: [PATCH] KVM: x86/mmu: Add "never" option to allow sticky
 disabling of nx_huge_pages

On Fri, Jun 02, 2023, Robert Hoo wrote:
> On 6/2/2023 8:58 AM, Sean Christopherson wrote:
> > @@ -6860,15 +6871,29 @@ static int set_nx_huge_pages(const char *val, const struct kernel_param *kp)
> >   	bool old_val = nx_huge_pages;
> >   	bool new_val;
> > +	if (nx_hugepage_mitigation_hard_disabled)
> > +		return -EPERM;
> > +
> >   	/* In "auto" mode deploy workaround only if CPU has the bug. */
> > -	if (sysfs_streq(val, "off"))
> > +	if (sysfs_streq(val, "off")) {
> >   		new_val = 0;
> > -	else if (sysfs_streq(val, "force"))
> > +	} else if (sysfs_streq(val, "force")) {
> >   		new_val = 1;
> > -	else if (sysfs_streq(val, "auto"))
> > +	} else if (sysfs_streq(val, "auto")) {
> >   		new_val = get_nx_auto_mode();
> > -	else if (kstrtobool(val, &new_val) < 0)
> > +	} else if (sysfs_streq(val, "never")) {
> > +		new_val = 0;
> > +
> > +		mutex_lock(&kvm_lock);
> > +		if (!list_empty(&vm_list)) {
> > +			mutex_unlock(&kvm_lock);
> > +			return -EBUSY;
> > +		}
> > +		nx_hugepage_mitigation_hard_disabled = true;
> > +		mutex_unlock(&kvm_lock);
> > +	} else if (kstrtobool(val, &new_val) < 0) {
> >   		return -EINVAL;
> > +	}
> > 
> 
> IIUC, (Initially) "auto_off"/"off" --> create some VM --> turn to "never",
> the created VMs still have those kthreads, but can never be used, until
> destroyed with VM.

Shouldn't be able to happen.  The above rejects "never" if vm_list isn't empty,
i.e. if there are any VMs, and sets nx_hugepage_mitigation_hard_disabled under
kvm_lock to ensure it can't race with KVM_CREATE_VM.  I forgot to call this out
in the changelog though.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ