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]
Date:   Wed, 8 Apr 2020 07:58:53 +0200
From:   Jan Kiszka <jan.kiszka@...mens.com>
To:     Steven Rostedt <rostedt@...dmis.org>,
        Peter Zijlstra <peterz@...radead.org>
Cc:     tglx@...utronix.de, linux-kernel@...r.kernel.org,
        hch@...radead.org, sean.j.christopherson@...el.com,
        mingo@...hat.com, bp@...en8.de, hpa@...or.com, x86@...nel.org,
        kenny@...ix.com, jeyu@...nel.org, rasmus.villemoes@...vas.dk,
        pbonzini@...hat.com, fenghua.yu@...el.com, xiaoyao.li@...el.com,
        nadav.amit@...il.com, thellstrom@...are.com, tony.luck@...el.com,
        gregkh@...uxfoundation.org, jannh@...gle.com,
        keescook@...omium.org, David.Laight@...lab.com,
        dcovelli@...are.com, mhiramat@...nel.org,
        Wolfgang Mauerer <wolfgang.mauerer@...-regensburg.de>
Subject: Re: [PATCH 4/4] x86,module: Detect CRn and DRn manipulation

On 07.04.20 23:48, Steven Rostedt wrote:
> On Tue, 07 Apr 2020 13:02:40 +0200
> Peter Zijlstra <peterz@...radead.org> wrote:
> 
>> Since we now have infrastructure to analyze module text, disallow
>> modules that write to CRn and DRn registers.
>>
>> Signed-off-by: Peter Zijlstra (Intel) <peterz@...radead.org>
>> ---
>>   arch/x86/kernel/module.c |   21 +++++++++++++++++++++
>>   1 file changed, 21 insertions(+)
>>
>> --- a/arch/x86/kernel/module.c
>> +++ b/arch/x86/kernel/module.c
>> @@ -266,6 +266,22 @@ static bool insn_is_vmx(struct insn *ins
>>   	return false;
>>   }
>>   
>> +static bool insn_is_mov_CRn(struct insn *insn)
>> +{
>> +	if (insn->opcode.bytes[0] == 0x0f && insn->opcode.bytes[1] == 0x22)
>> +		return true;
>> +
>> +	return false;
>> +}
>> +
>> +static bool insn_is_mov_DRn(struct insn *insn)
>> +{
>> +	if (insn->opcode.bytes[0] == 0x0f && insn->opcode.bytes[1] == 0x23)
>> +		return true;
>> +
>> +	return false;
>> +}
>> +
>>   static int decode_module(struct module *mod, void *text, void *text_end, bool sld_safe)
>>   {
>>   	bool allow_vmx = sld_safe || !split_lock_enabled();
>> @@ -285,6 +301,11 @@ static int decode_module(struct module *
>>   			return -ENOEXEC;
>>   		}
>>   
>> +		if (insn_is_mov_CRn(&insn) || insn_is_mov_DRn(&insn)) {
>> +			pr_err("Module writes to CRn or DRn, please use the proper accessors: %s\n", mod->name);
>> +			return -ENOEXEC;
>> +		}
> 
> Hmm, wont this break jailhouse?

Yes, possibly. We load the hypervisor binary via request_firmware into 
executable memory and then jump into it. So most of the "suspicious" 
code is there - except two cr4_init_shadow() calls to propagate the 
non-transparent update of VMXE into that shadow. We could hide that CR4 
flag, but that could mislead root Linux to try to use VMX while in jail.

Jan

-- 
Siemens AG, Corporate Technology, CT RDA IOT SES-DE
Corporate Competence Center Embedded Linux

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ