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: <20181119180233.mdvuah3geacujpr4@treble>
Date:   Mon, 19 Nov 2018 12:02:33 -0600
From:   Josh Poimboeuf <jpoimboe@...hat.com>
To:     Artem Savkov <asavkov@...hat.com>
Cc:     Peter Zijlstra <peterz@...radead.org>, linux-kernel@...r.kernel.org
Subject: Re: [PATCH v3 2/2] objtool: fix .cold functions parent symbols search

On Mon, Nov 12, 2018 at 01:55:19PM +0100, Artem Savkov wrote:
> Because find_symbol_by_name() traverses the same lists as read_symbols()
> changing sym->name in place without copying it affects the result of
> find_symbol_by_name() and, in case when ".cold" function precedes it's
> parent in sec->symbol_list, can result in function being considered a
> parent of itself. This leads to function length being set to 0 and other
> consequent side-effects including a segfault in add_switch_table().
> The effects of this bug are only visible when building with
> -ffunction-sections in KCFLAGS.
> 
> Fix by copying the search string instead of modifying it in place.
> 
> Fixes: 13810435b9a7 "objtool: Support GCC 8's cold subfunctions"

Same here, needs parentheses.

> Signed-off-by: Artem Savkov <asavkov@...hat.com>
> ---
>  tools/objtool/elf.c | 17 ++++++++++++++---
>  1 file changed, 14 insertions(+), 3 deletions(-)
> 
> diff --git a/tools/objtool/elf.c b/tools/objtool/elf.c
> index 3decd43477df..15d9acfb2c97 100644
> --- a/tools/objtool/elf.c
> +++ b/tools/objtool/elf.c
> @@ -31,6 +31,8 @@
>  #include "elf.h"
>  #include "warn.h"
>  
> +#define MAX_NAME_LEN 128
> +
>  struct section *find_section_by_name(struct elf *elf, const char *name)
>  {
>  	struct section *sec;
> @@ -298,6 +300,8 @@ static int read_symbols(struct elf *elf)
>  	/* Create parent/child links for any cold subfunctions */
>  	list_for_each_entry(sec, &elf->sections, list) {
>  		list_for_each_entry(sym, &sec->symbol_list, list) {
> +			char pname[MAX_NAME_LEN + 1];
> +			size_t pnamelen;
>  			if (sym->type != STT_FUNC)
>  				continue;
>  			sym->pfunc = sym->cfunc = sym;
> @@ -305,9 +309,16 @@ static int read_symbols(struct elf *elf)
>  			if (!coldstr)
>  				continue;
>  
> -			coldstr[0] = '\0';
> -			pfunc = find_symbol_by_name(elf, sym->name);
> -			coldstr[0] = '.';
> +			pnamelen = coldstr - sym->name;
> +			if (pnamelen > MAX_NAME_LEN) {
> +				WARN("%s(): parent function name exceeds maximum length of %d characters",
> +				     sym->name, MAX_NAME_LEN);
> +				goto cold_err;

Same here, makes more sense to just return -1 and let elf_close() clean
it up I think.

-- 
Josh

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ