mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Josh Poimboeuf <jpoimboe@kernel.org>
To: Michal Kubecek <mkubecek@suse.cz>
Cc: Peter Zijlstra <peterz@infradead.org>, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] objtool: initialize all of struct elf
Date: Thu, 29 Jun 2023 07:18:19 -0700	[thread overview]
Message-ID: <20230629141819.aopy23zi5wc6iqof@treble> (raw)
In-Reply-To: <20230629102051.42E8360467@lion.mk-sys.cz>

On Thu, Jun 29, 2023 at 12:05:05PM +0200, Michal Kubecek wrote:
> Function elf_open_read() only zero initializes the initial part of
> allocated struct elf; num_relocs member was recently added outside the
> zeroed part so that it was left uninitialized, resulting in build failures
> on some systems.
> 
> The partial initialization is a relic of times when struct elf had large
> hash tables embedded. This is no longer the case so remove the trap and
> initialize the whole structure instead.
> 
> Fixes: eb0481bbc4ce ("objtool: Fix reloc_hash size")
> Signed-off-by: Michal Kubecek <mkubecek@suse.cz>
> ---
>  tools/objtool/elf.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/tools/objtool/elf.c b/tools/objtool/elf.c
> index d420b5d2e2b6..081befa4674b 100644
> --- a/tools/objtool/elf.c
> +++ b/tools/objtool/elf.c
> @@ -1005,7 +1005,7 @@ struct elf *elf_open_read(const char *name, int flags)
>  		perror("malloc");
>  		return NULL;
>  	}
> -	memset(elf, 0, offsetof(struct elf, sections));
> +	memset(elf, 0, sizeof(*elf));
>  
>  	INIT_LIST_HEAD(&elf->sections);

Thanks!

Acked-by: Josh Poimboeuf <jpoimboe@kernel.org>

-- 
Josh

  reply	other threads:[~2023-06-29 14:18 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-29 10:05 Michal Kubecek
2023-06-29 14:18 ` Josh Poimboeuf [this message]
2023-07-10  8:13 ` [tip: objtool/urgent] " tip-bot2 for Michal Kubecek

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230629141819.aopy23zi5wc6iqof@treble \
    --to=jpoimboe@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mkubecek@suse.cz \
    --cc=peterz@infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®