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] [day] [month] [year] [list]
Date:	Tue, 5 May 2009 10:57:06 -0300
From:	Glauber Costa <glommer@...hat.com>
To:	Avi Kivity <avi@...hat.com>
Cc:	kvm@...r.kernel.org, linux-kernel@...r.kernel.org,
	"H. Peter Anvin" <hpa@...or.com>
Subject: Re: [PATCH] deal with interrupt shadow state for emulated
	instruction

> Hmm, if the guest runs an infinite emulated 'mov ss', it will keep  
> toggling the MOV_SS bit, but STI will remain set, so we'll never allow  
> an interrupt into the guest kernel.
We have no choice but returning both flags, since svm does not differentiate
between them.

But see below for an alternative path that makes it a non-issue.

>
>> diff --git a/arch/x86/kvm/x86_emulate.c b/arch/x86/kvm/x86_emulate.c
>> index d2664fc..797d41f 100644
>> --- a/arch/x86/kvm/x86_emulate.c
>> +++ b/arch/x86/kvm/x86_emulate.c
>> @@ -1618,6 +1618,16 @@ special_insn:
>>  		int err;
>>   		sel = c->src.val;
>> +		if (c->modrm_reg == VCPU_SREG_SS) {
>> +			u32 int_shadow =
>> +				kvm_x86_ops->get_interrupt_shadow(ctxt->vcpu);
>> +			/* See sti emulation for an explanation of this */
>> +			if ((int_shadow & X86_SHADOW_INT_MOV_SS))
>> +				ctxt->interruptibility &= ~X86_SHADOW_INT_MOV_SS;
>> +			else
>> +				ctxt->interruptibility |= X86_SHADOW_INT_MOV_SS;
>> +		}
>>   
>
> ^=
 =p \o/

After re-reading this, masking the flags in here makes no sense.

I am moving to an approach in which I do

                        if (!(int_shadow & X86_SHADOW_INT_MOV_SS))
                                ctxt->interruptibility = X86_SHADOW_INT_MOV_SS;

Since if the next instruction is an sti, it is certainly not an sti; sti instruction
(the current is mov ss, after all). So we should mask it anyway. This also solves
nicely the problem you raised at svm.c.
>
>> @@ -1846,10 +1856,23 @@ special_insn:
>>  		ctxt->eflags &= ~X86_EFLAGS_IF;
>>  		c->dst.type = OP_NONE;	/* Disable writeback. */
>>  		break;
>> -	case 0xfb: /* sti */
>> +	case 0xfb: { /* sti */
>> +		u32 int_shadow = kvm_x86_ops->get_interrupt_shadow(ctxt->vcpu);
>> +		/*
>> +		 * an sti; sti; sequence only disable interrupts for the first
>> +		 * instruction. So, if the last instruction, be it emulated or
>> +		 * not, left the system with the INT_STI flag enabled, it
>> +		 * means that the last instruction is an sti. We should not
>> +		 * leave the flag on in this case
>> +		 */
>> +		if ((int_shadow & X86_SHADOW_INT_STI))
>> +			ctxt->interruptibility &= ~X86_SHADOW_INT_STI;
>> +		else
>> +			ctxt->interruptibility |= X86_SHADOW_INT_STI;
>>   
>
> ^=
ditto

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ