Message ID | 20230629102051.42E8360467@lion.mk-sys.cz |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp9532631vqr; Thu, 29 Jun 2023 03:25:42 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ49tk0HZV6rW8UM7J1RDkUip88jB0m2Iv9XDL/9Y8ulRRl8loeBNPI4+l5h8su3/L1q9pJc X-Received: by 2002:a05:6a00:d8b:b0:681:9fe0:b543 with SMTP id bf11-20020a056a000d8b00b006819fe0b543mr2804275pfb.2.1688034341791; Thu, 29 Jun 2023 03:25:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688034341; cv=none; d=google.com; s=arc-20160816; b=IkVy69gVNSGEzhLTYM1mjzV04bavDBrs7C1scqptdOXsYSu4ysKlGg7wPNilZr2Sle BWp3GxWI8Q4lJwCYktjANqfDYZvXXafHnSu6n1Y6sHjz7b9s3YbKzZQW/t3ow3pf+Jhv jVwkNv4iB8j56eDe8iTUhv71QUQLTKuL8K6xy0IwKA8gSMaR1CrhSuHLz9LZITu+Z9Hj xNsz4qv9gX7N0s1Vr26NZOKn/lMfuwFxIe8dS6hAOQdpAeKn+YspoWmje+91Xc8TRNVa bezHZEKwrM0s4NjLjZ+wzEjmIaQi+V+ZAIUt/yHj9iuduDOXZiQV54/u90+vgeg22yon 0Z4Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:to:subject:date:from:dkim-signature :dkim-signature; bh=LECm0m+o+ZGRGygtSk68YR+QZWIj672OOurGXfyr1cw=; fh=6fzjPYpZ77N8VlnWv6JKU25XVjCreGrjztShxVCqZeY=; b=GhmOlFkx+nG5cSzUWunjfo8inWrG6KqDTmp/F9l4c38oCJ6eaaKG+V6277bWpqTFXy pO+FpHvFbcHeHrBz0pGoKKMcpgvZaQnqHZj+IS1rkrJAqIsnUQcAm5FXzrt1LH+epjDr GgssyDwq+6gbCPGXOsmy0kSvZJAB0NUMhN5iry8x73iwMBmtbh4GRXvBIIZpAIF4KDu8 +EwKeO4ivyxHlqOJOeVptkn99CgLNISSatqw7RlPeXZJWzz9vTjTDLccXb6Ou4Pp4LYh aTqK+kp9kdA9CQv0p8q1XS4/9R+gk2LzW4uZ6wg6FnbBIeZ7sxL0CCWdUgPYTtaC315R Kx+w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=lCOfNeyf; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519 header.b=KVx3ER4n; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e193-20020a6369ca000000b0055afc8d8a09si5465004pgc.448.2023.06.29.03.25.28; Thu, 29 Jun 2023 03:25:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=lCOfNeyf; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519 header.b=KVx3ER4n; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231445AbjF2KVB (ORCPT <rfc822;ivan.orlov0322@gmail.com> + 99 others); Thu, 29 Jun 2023 06:21:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51460 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230036AbjF2KU7 (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Thu, 29 Jun 2023 06:20:59 -0400 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 47FB8A2 for <linux-kernel@vger.kernel.org>; Thu, 29 Jun 2023 03:20:58 -0700 (PDT) Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id D8D081F8AA; Thu, 29 Jun 2023 10:20:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1688034056; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc; bh=LECm0m+o+ZGRGygtSk68YR+QZWIj672OOurGXfyr1cw=; b=lCOfNeyf5kzJv7YTXv9OeKNWsYWCcZv6BbYgs8PIYnowiGyZY4qoVr0OMwpL3XEnV2M2Do Vvm+TzgEAtfOUkwy67XkUKn5TB7kUZ4hnRAdQPh8wSyoTAVoP/kaU20oZcT2VsfC0ebnZ7 o+2cLO2G/48Me5nG7gO9LzJWKIiqMYM= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1688034056; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc; bh=LECm0m+o+ZGRGygtSk68YR+QZWIj672OOurGXfyr1cw=; b=KVx3ER4ncZWVE1Igx2AfojNi3NgSNVipgG3+blOuTMWIUoIwRxL0mNRWXrPVmd1Nsce1sF c6mORTabMiAZHxAA== Received: from lion.mk-sys.cz (unknown [10.163.44.94]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by relay2.suse.de (Postfix) with ESMTPS id C63DB2C141; Thu, 29 Jun 2023 10:20:56 +0000 (UTC) Received: by lion.mk-sys.cz (Postfix, from userid 1000) id 42E8360467; Thu, 29 Jun 2023 12:20:51 +0200 (CEST) From: Michal Kubecek <mkubecek@suse.cz> Date: Thu, 29 Jun 2023 12:05:05 +0200 Subject: [PATCH] objtool: initialize all of struct elf To: Josh Poimboeuf <jpoimboe@kernel.org>, Peter Zijlstra <peterz@infradead.org>, linux-kernel@vger.kernel.org Message-Id: <20230629102051.42E8360467@lion.mk-sys.cz> X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1770032297812247706?= X-GMAIL-MSGID: =?utf-8?q?1770032297812247706?= |
Series |
objtool: initialize all of struct elf
|
|
Commit Message
Michal Kubecek
June 29, 2023, 10:05 a.m. UTC
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(-)
Comments
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>
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);