[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAOLK0pyeBa7XXn7ajJJ8SCeHsM_BwWFXT_p+r-o8aTzthJPV3w@mail.gmail.com>
Date: Fri, 8 Dec 2017 16:48:17 +0800
From: Tianyu Lan <lantianyu1986@...il.com>
To: Ingo Molnar <mingo@...nel.org>
Cc: Jim Mattson <jmattson@...gle.com>,
Wanpeng Li <kernellwp@...il.com>,
Dmitry Vyukov <dvyukov@...gle.com>,
syzbot
<bot+75375385991b4f8c599704a10849863c586ea284@...kaller.appspotmail.com>,
"H. Peter Anvin" <hpa@...or.com>, kvm <kvm@...r.kernel.org>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
Ingo Molnar <mingo@...hat.com>,
Paolo Bonzini <pbonzini@...hat.com>,
Radim Krcmar <rkrcmar@...hat.com>,
syzkaller-bugs@...glegroups.com,
Thomas Gleixner <tglx@...utronix.de>,
"the arch/x86 maintainers" <x86@...nel.org>,
Andrew Jones <drjones@...hat.com>
Subject: Re: WARNING in x86_emulate_insn
2017-12-08 16:44 GMT+08:00 Ingo Molnar <mingo@...nel.org>:
>
> * Tianyu Lan <lantianyu1986@...il.com> wrote:
>
>> Hi Jim&Wanpeng:
>> Thanks for your help.
>>
>> 2017-12-08 5:25 GMT+08:00 Jim Mattson <jmattson@...gle.com>:
>> > Try disabling the module parameter, "unrestricted_guest." Make sure
>> > that the module parameter, "emulate_invalid_guest_state" is enabled.
>> > This combination allows userspace to feed invalid guest state into the
>> > in-kernel emulator.
>>
>> Yes, you are right. I need to disable unrestricted_guest to reproduce the issue.
>>
>> I find this is pop instruction emulation issue. According "SDM VOL2,
>> chapter INSTRUCTION
>> SET REFERENCE. POP—Pop a Value from the Stack"
>>
>> Protected Mode Exceptions
>> #GP(0) If attempt is made to load SS register with NULL segment selector.
>>
>> This test case hits it but current code doesn't check such case.
>> The following patch can fix the issue.
>>
>> diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c
>> index abe74f7..e2ac5cc 100644
>> --- a/arch/x86/kvm/emulate.c
>> +++ b/arch/x86/kvm/emulate.c
>> @@ -1844,6 +1844,9 @@ static int emulate_pop(struct x86_emulate_ctxt *ctxt,
>> int rc;
>> struct segmented_address addr;
>>
>> + if ( !get_segment_selector(ctxt, VCPU_SREG_SS))
>> + return emulate_gp(ctxt, 0);
>> +
>> addr.ea = reg_read(ctxt, VCPU_REGS_RSP) & stack_mask(ctxt);
>> addr.seg = VCPU_SREG_SS;
>> rc = segmented_read(ctxt, addr, dest, len);
>
> s/if ( !get_segment_selector
> /if (!get_segment_selector
Sorry. I mixed xen and kernel code style...
>
> I think it would also be nice to convert the syzkaller testcase to a new KVM unit
> test:
Sure. I will add it.
>
> git://git.kernel.org/pub/scm/virt/kvm/kvm-unit-tests.git
>
> There's a test_pop() function in kvm-unit-tests/x86/emulator.c.
>
> Thanks,
>
> Ingo
--
Best regards
Tianyu Lan
Powered by blists - more mailing lists