Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

x/arch/x86/x86asm: missing Control-flow Enforcement instructions; e.g. ENDBR64 #35865

Open
mewmew opened this issue Nov 27, 2019 · 1 comment
Labels
NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@mewmew
Copy link
Contributor

mewmew commented Nov 27, 2019

As a follow-up of #18665, instructions related to Control-flow Enforcement are currently not recognized by the x/arch/x86 disassembler.

Example link at play.golang.org: https://play.golang.org/p/xz6V8cSREWF

package main

import (
	"fmt"

	"golang.org/x/arch/x86/x86asm"
)

func main() {
	// ref: Section 7.1: ENDBR64 of "Control-flow Enforcement Technology Specification"
	//
	// https://software.intel.com/sites/default/files/managed/4d/2a/control-flow-enforcement-technology-preview.pdf
	text := []byte{0xF3, 0x0F, 0x1E, 0xFA} // endbr64
	inst, err := x86asm.Decode(text[:], 64)
	if err != nil {
		panic(err)
	}
	fmt.Println("inst:", inst)
	// Expected: ENDBR64
	// Got:      REP Op(0)
}

At rev golang/arch@368ea8f, the ENDBR64 instruction is incorrectly recognized as REP Op(0) without reporting any error from decode. The ENDBR64 instruction has the byte sequence 0xF3, 0x0F, 0x1E, 0xFA and was introduced as part of the Control-flow Enforcement Technology Specification: https://software.intel.com/sites/default/files/managed/4d/2a/control-flow-enforcement-technology-preview.pdf

/cc: @rsc @minux

@gopherbot gopherbot added this to the Unreleased milestone Nov 27, 2019
@smasher164 smasher164 added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Nov 27, 2019
@TACIXAT
Copy link

TACIXAT commented May 17, 2021

This affects me too.

Happy to give fixing it a shot if someone provides points on where the code that needs to be changed is. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

4 participants