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: <bb007ee6-0921-9396-e1a2-d9ed022a8399@redhat.com>
Date:   Thu, 14 Dec 2017 12:41:06 +0100
From:   Paolo Bonzini <pbonzini@...hat.com>
To:     Lan Tianyu <tianyu.lan@...el.com>
Cc:     rkrcmar@...hat.com, tglx@...utronix.de, mingo@...hat.com,
        hpa@...or.com, x86@...nel.org, kvm@...r.kernel.org,
        linux-kernel@...r.kernel.org, dvyukov@...gle.com,
        jmattson@...gle.com
Subject: Re: [PATCH V2] KVM/x86: Check input paging mode when cs.l is set

On 14/12/2017 04:55, Lan Tianyu wrote:
> +	 * When EFER.LME and CR0.PG are set, CR4.PAE and EFER.LMA
> +	 * must be set.
> +	 */
> +	if ((sregs->efer & EFER_LME) && (sregs->cr0 & X86_CR0_PG_BIT)) {
> +		if (!(sregs->cr4 & X86_CR4_PAE_BIT))
> +			return -EINVAL;
> +		if (!(sregs->efer & EFER_LMA))
> +			return -EINVAL;
> +	} else if (sregs->efer & EFER_LMA)

This can just be "(sregs->efer & EFER_LMA) || sregs->cs.l", making the
next "if" redundant.  Even better written as

	if ((sregs->efer & EFER_LME) && (sregs->cr0 & X86_CR0_PG_BIT)) {
		/*
		 * When EFER.LME and CR0.PG are set, the processor is in
		 * 64-bit mode (though maybe in a 32-bit code segment).
		 * CR4.PAE and EFER.LMA must be set.
		 */
		if (... || ...)
			return -EINVAL;
	} else {
		/*
		 * Not in 64-bit mode: EFER.LMA is clear and the code
		 * segment cannot be 64-bit.
		 */
		if (... || ...)
			return -EINVAL;
	}

Paolo

> +		return -EINVAL;
> +
> +	/* When CS.L is set, vcpu should run in 64-bit mode. */
> +	if (sregs->cs.l)
> +		if (!((sregs->cr0 & X86_CR0_PG_BIT) &&
> +		      (sregs->cr4 & X86_CR4_PAE_BIT) &&
> +		      (sregs->efer & EFER_LME)))
> +			return -EINVAL;

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ