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:   Fri, 2 Oct 2020 11:01:14 -0500
From:   Josh Poimboeuf <jpoimboe@...hat.com>
To:     Vasily Gorbik <gor@...ux.ibm.com>
Cc:     Peter Zijlstra <peterz@...radead.org>,
        Thomas Gleixner <tglx@...utronix.de>,
        Masami Hiramatsu <mhiramat@...nel.org>,
        David Laight <David.Laight@...lab.com>,
        Ingo Molnar <mingo@...hat.com>, Borislav Petkov <bp@...en8.de>,
        x86@...nel.org, "H. Peter Anvin" <hpa@...or.com>,
        Miroslav Benes <mbenes@...e.cz>,
        Alexandre Chartre <alexandre.chartre@...cle.com>,
        Julien Thierry <jthierry@...hat.com>,
        linux-kernel@...r.kernel.org
Subject: Re: [RFC PATCH v3 4/4] objtool: fix x86 orc generation on big endian
 cross compiles

On Thu, Oct 01, 2020 at 12:17:32AM +0200, Vasily Gorbik wrote:
> +++ b/tools/objtool/arch/x86/special.c
> @@ -9,7 +9,7 @@
>  
>  void arch_handle_alternative(unsigned short feature, struct special_alt *alt)
>  {
> -	switch (feature) {
> +	switch (le16_to_cpu(feature)) {

It might be cleaner for the endian conversion to be done when the
'feature' value is first read.

		feature = *(unsigned short *)(sec->data->d_buf + offset +
					      entry->feature);


>  	case X86_FEATURE_SMAP:
>  		/*
>  		 * If UACCESS validation is enabled; force that alternative;
> diff --git a/tools/objtool/check.c b/tools/objtool/check.c
> index 2df9f769412e..f20a4be2fb22 100644
> --- a/tools/objtool/check.c
> +++ b/tools/objtool/check.c
> @@ -1370,7 +1370,7 @@ static int read_unwind_hints(struct objtool_file *file)
>  		cfa = &insn->cfi.cfa;
>  
>  		if (hint->type == UNWIND_HINT_TYPE_RET_OFFSET) {
> -			insn->ret_offset = hint->sp_offset;
> +			insn->ret_offset = le16_to_cpu(hint->sp_offset);

Since this is common code, we might not always be able to assume the
value is little endian.  Could you make a more generic conversion macro
which -- when the target ELF file's endianness doesn't match the host
CPU's -- does a byte swap?  For example:

	insn->ret_offset = bswap_if_needed(hint->sp_offset);

The macro could detect the type size, and would also know the
host/target endianness, and could swap accordingly.  It could then be
called for all such multi-byte reads.

-- 
Josh

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ