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: <YUwp7VkjApRQr/pb@hirez.programming.kicks-ass.net>
Date:   Thu, 23 Sep 2021 09:17:01 +0200
From:   Peter Zijlstra <peterz@...radead.org>
To:     Fenghua Yu <fenghua.yu@...el.com>
Cc:     Thomas Gleixner <tglx@...utronix.de>,
        Ingo Molnar <mingo@...hat.com>, Borislav Petkov <bp@...en8.de>,
        Andy Lutomirski <luto@...nel.org>,
        Dave Hansen <dave.hansen@...el.com>,
        Tony Luck <tony.luck@...el.com>,
        Lu Baolu <baolu.lu@...ux.intel.com>,
        Joerg Roedel <joro@...tes.org>,
        Josh Poimboeuf <jpoimboe@...hat.com>,
        Dave Jiang <dave.jiang@...el.com>,
        Jacob Jun Pan <jacob.jun.pan@...el.com>,
        Ashok Raj <ashok.raj@...el.com>,
        Ravi V Shankar <ravi.v.shankar@...el.com>,
        iommu@...ts.linux-foundation.org, x86 <x86@...nel.org>,
        linux-kernel <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH 7/8] tools/objtool: Check for use of the ENQCMD
 instruction in the kernel

On Wed, Sep 22, 2021 at 11:44:41PM +0000, Fenghua Yu wrote:

> > Since you're making it a fatal error, before doing much of anything
> > else, you might at well fail decode and keep it all in the x86/decode.c
> > file, no need to spread this 'knowledge' any further.

> Is the following updated patch a right one?

Yes, that's what I was thinking of.

> diff --git a/tools/objtool/arch/x86/decode.c b/tools/objtool/arch/x86/decode.c
> index bc821056aba9..3e0f928e28a5 100644
> --- a/tools/objtool/arch/x86/decode.c
> +++ b/tools/objtool/arch/x86/decode.c
> @@ -110,7 +110,7 @@ int arch_decode_instruction(const struct elf *elf, const struct section *sec,
>  {
>  	struct insn insn;
>  	int x86_64, ret;
> -	unsigned char op1, op2,
> +	unsigned char op1, op2, op3,
>  		      rex = 0, rex_b = 0, rex_r = 0, rex_w = 0, rex_x = 0,
>  		      modrm = 0, modrm_mod = 0, modrm_rm = 0, modrm_reg = 0,
>  		      sib = 0, /* sib_scale = 0, */ sib_index = 0, sib_base = 0;
> @@ -137,6 +137,7 @@ int arch_decode_instruction(const struct elf *elf, const struct section *sec,
>  
>  	op1 = insn.opcode.bytes[0];
>  	op2 = insn.opcode.bytes[1];
> +	op3 = insn.opcode.bytes[2];
>  
>  	if (insn.rex_prefix.nbytes) {
>  		rex = insn.rex_prefix.bytes[0];
> @@ -489,6 +490,16 @@ int arch_decode_instruction(const struct elf *elf, const struct section *sec,
>  			/* nopl/nopw */
>  			*type = INSN_NOP;
>  
> +		} else if (op2 == 0x38 && op3 == 0xf8) {
> +			if (insn.prefixes.nbytes == 1 &&
> +			    insn.prefixes.bytes[0] == 0xf2) {
> +				/* ENQCMD cannot be used in the kernel. */
> +				WARN("ENQCMD instruction at %s:%lx", sec->name,
> +				     offset);
> +
> +				return -1;
> +			}

The only concern here is if we want it to be fatal or not. But otherwise
this seems to be all that's required.

> +
>  		} else if (op2 == 0xa0 || op2 == 0xa8) {
>  
>  			/* push fs/gs */

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ