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: <20180115173928.7ajrdwah24jwxmku@treble>
Date:   Mon, 15 Jan 2018 11:39:28 -0600
From:   Josh Poimboeuf <jpoimboe@...hat.com>
To:     Peter Zijlstra <peterz@...radead.org>
Cc:     David Woodhouse <dwmw2@...radead.org>,
        linux-kernel@...r.kernel.org, Dave Hansen <dave.hansen@...el.com>,
        Ashok Raj <ashok.raj@...el.com>,
        Thomas Gleixner <tglx@...utronix.de>,
        Tim Chen <tim.c.chen@...ux.intel.com>,
        Andy Lutomirski <luto@...nel.org>,
        Linus Torvalds <torvalds@...ux-foundation.org>,
        Greg KH <gregkh@...uxfoundation.org>,
        Andrea Arcangeli <aarcange@...hat.com>,
        Andi Kleen <ak@...ux.intel.com>,
        Arjan Van De Ven <arjan.van.de.ven@...el.com>,
        Dan Williams <dan.j.williams@...el.com>,
        Paolo Bonzini <pbonzini@...hat.com>,
        Jun Nakajima <jun.nakajima@...el.com>,
        Asit Mallick <asit.k.mallick@...el.com>,
        Borislav Petkov <bp@...en8.de>
Subject: Re: [PATCH 1/4] objtool: Implement base jump_assert support

Big props to you for braving the bowels of the objtool code.

On Mon, Jan 15, 2018 at 05:44:29PM +0100, Peter Zijlstra wrote:
> +static int read_jump_assertions(struct objtool_file *file)

This does more than just _read_ the assertions.  Can you call it
something like assert_static_jumps() or do_static_jump_assertions() and
then call it from the main check() function?

> +{
> +	struct section *sec, *relasec;
> +	struct instruction *insn;
> +	struct rela *rela;
> +	int i;
> +
> +	sec = find_section_by_name(file->elf, ".discard.jump_assert");
> +	if (!sec)
> +		return 0;
> +
> +	relasec = sec->rela;
> +	if (!relasec) {
> +		WARN("missing .rela.discard.jump_assert section");
> +		return -1;
> +	}
> +
> +	if (sec->len % sizeof(unsigned long)) {
> +		WARN("jump_assert size mismatch: %d %ld", sec->len, sizeof(unsigned long));
> +		return -1;
> +	}
> +
> +	for (i = 0; i < sec->len / sizeof(unsigned long); i++) {
> +		rela = find_rela_by_dest(sec, i * sizeof(unsigned long));
> +		if (!rela) {
> +			WARN("can't find rela for jump_assert[%d]", i);
> +			return -1;
> +		}
> +
> +		insn = find_insn(file, rela->sym->sec, rela->addend);
> +		if (!insn) {
> +			WARN("can't find insn for jump_assert[%d]", i);
> +			return -1;
> +		}
> +
> +		if (!insn->br_static) {
> +			WARN_FUNC("static assert FAIL", insn->sec, insn->offset);
> +			return -1;
> +		}
> +	}
> +
> +	return 0;
> +}
> +
>  static int decode_sections(struct objtool_file *file)
>  {
>  	int ret;
> @@ -1105,6 +1167,10 @@ static int decode_sections(struct objtoo
>  	if (ret)
>  		return ret;
>  
> +	ret = read_jump_assertions(file);
> +	if (ret)
> +		return ret;
> +
>  	return 0;
>  }
>  
> --- a/tools/objtool/check.h
> +++ b/tools/objtool/check.h
> @@ -45,6 +45,7 @@ struct instruction {
>  	unsigned char type;
>  	unsigned long immediate;
>  	bool alt_group, visited, dead_end, ignore, hint, save, restore, ignore_alts;
> +	bool br_static;

s/br_static/static_jump_dest/?

Also, fellow objtool expert, you forgot the patch to the MAINTAINERS
file ;-)

-- 
Josh

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ