From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS31976 209.132.180.0/23 X-Spam-Status: No, score=-4.0 required=3.0 tests=AWL,BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,SPF_HELO_PASS,SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dcvr.yhbt.net (Postfix) with ESMTPS id 3DD001F454 for ; Sun, 3 Nov 2019 17:12:07 +0000 (UTC) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:date:from:to:cc:message-id:subject:references :reply-to:mime-version:content-transfer-encoding:content-type; q=dns; s=default; b=KNPcVfvUCGvF1b4WLznH3XbfDg+4Fznmayl9goSokuv ql4GgD4vZAFmaInsL/4Ql/aO1nTlDz5AGzhCXB9PQ8oTXf36C/SNtPca3s0MotZ5 9KE2EBLpQd3ymKKM7jcIHbpxRCeKe1Cd7wX1QGuuatDo1GShFZF5fJTZ/BPdt9zU = DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:date:from:to:cc:message-id:subject:references :reply-to:mime-version:content-transfer-encoding:content-type; s=default; bh=V8TSbFDmW+PiEBtSg010zBLztmU=; b=o3lK/4FyBvF2+bl9T +pyJwgFP78UR+q0Hw/5xvsGG4ARRFvLwGkko/6Y9kmvzapIDcc5OIAd6uYyxkaA2 WOoi2huiZCI/VFRS7e2NTF17MRb/n+gbolhrjszGCme4qCpogTNqY8GVxiTWXZk+ vxNIrZx9pf+/LI/f+oaRu8E07U= Received: (qmail 2412 invoked by alias); 3 Nov 2019 17:11:55 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Received: (qmail 2391 invoked by uid 89); 3 Nov 2019 17:11:55 -0000 Authentication-Results: sourceware.org; auth=none X-HELO: mx1.osci.io X-Gerrit-PatchSet: 1 Date: Sun, 3 Nov 2019 12:11:46 -0500 From: "Florian Weimer (Code Review)" To: libc-alpha@sourceware.org Cc: Florian Weimer Message-ID: Auto-Submitted: auto-generated X-Gerrit-MessageType: newchange Subject: [review] Avoid zero-length array at the end of struct link_map [BZ #25097] X-Gerrit-Change-Id: Ic911100730f9124d4ea977ead8e13cee64b84d45 X-Gerrit-Change-Number: 488 X-Gerrit-ChangeURL: X-Gerrit-Commit: 6a771621414cc85f218d6b13c204552afd0294c3 References: Reply-To: fweimer@redhat.com, fweimer@redhat.com, libc-alpha@sourceware.org MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Disposition: inline User-Agent: Gerrit/3.0.3-75-g9005159e5d Content-Type: text/plain; charset=UTF-8 Change URL: https://gnutoolchain-gerrit.osci.io/r/c/glibc/+/488 ...................................................................... Avoid zero-length array at the end of struct link_map [BZ #25097] l_audit ends up as an internal array with _rtld_global, and GCC 10 warns about this. This commit does not change the layout of _rtld_global, so it is suitable for backporting. Future changes could allocate more of the audit state dynamically and remove it from always-allocated data structures, to optimize the common case of inactive auditing. Change-Id: Ic911100730f9124d4ea977ead8e13cee64b84d45 --- M include/link.h M sysdeps/generic/ldsodefs.h 2 files changed, 23 insertions(+), 12 deletions(-) diff --git a/include/link.h b/include/link.h index 1184201..be52b97 100644 --- a/include/link.h +++ b/include/link.h @@ -325,16 +325,18 @@ size_t l_relro_size; unsigned long long int l_serial; - - /* Audit information. This array apparent must be the last in the - structure. Never add something after it. */ - struct auditstate - { - uintptr_t cookie; - unsigned int bindflags; - } l_audit[0]; }; +/* Information used by audit modules. For most link maps, this data + immediate follows the link map in memory. For the dynamic linker, + it is allocated separately. See link_map_audit_state in + . */ +struct auditstate +{ + uintptr_t cookie; + unsigned int bindflags; +}; + #if __ELF_NATIVE_CLASS == 32 # define symbind symbind32 diff --git a/sysdeps/generic/ldsodefs.h b/sysdeps/generic/ldsodefs.h index 04b6d17..eb6cbea 100644 --- a/sysdeps/generic/ldsodefs.h +++ b/sysdeps/generic/ldsodefs.h @@ -379,11 +379,12 @@ /* List of search directories. */ EXTERN struct r_search_path_elem *_dl_all_dirs; - /* Structure describing the dynamic linker itself. We need to - reserve memory for the data the audit libraries need. */ + /* Structure describing the dynamic linker itself. */ EXTERN struct link_map _dl_rtld_map; #ifdef SHARED - struct auditstate audit_data[DL_NNS]; + /* Used to store the audit information for the link map of the + dynamic loader. */ + struct auditstate _dl_rtld_auditstate[DL_NNS]; #endif #if defined SHARED && defined _LIBC_REENTRANT \ @@ -1178,7 +1179,15 @@ static inline struct auditstate * link_map_audit_state (struct link_map *l, size_t index) { - return &l->l_audit[index]; + if (l == &GL (dl_rtld_map)) + /* The auditstate array is stored separately. */ + return &GL (dl_rtld_auditstate) [index]; + else + { + /* The auditstate array follows the link map in memory. */ + struct auditstate *base = (struct auditstate *) (l + 1); + return &base[index]; + } } #endif /* SHARED */ -- Gerrit-Project: glibc Gerrit-Branch: master Gerrit-Change-Id: Ic911100730f9124d4ea977ead8e13cee64b84d45 Gerrit-Change-Number: 488 Gerrit-PatchSet: 1 Gerrit-Owner: Florian Weimer Gerrit-MessageType: newchange