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=-3.9 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 33C821F454 for ; Sun, 3 Nov 2019 21:19:22 +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:subject:in-reply-to:references :reply-to:mime-version:content-transfer-encoding:content-type :message-id; q=dns; s=default; b=VSuJGw6UuNt2QA7IRK7JYvP13Yq9C6o P1dyd/BdYNQPoFpzIyZEvEz2rx5r7muBxyFKYlor2zOhD/WXvt040ptA0TOl3J/m gcExQN6Gqi92gyKBzu2pWifOhtkxpVnVNVGLhNtFFoEm+bKHcfeB0baftk3jjj4N fVMoRpHGktLg= 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:subject:in-reply-to:references :reply-to:mime-version:content-transfer-encoding:content-type :message-id; s=default; bh=B2SR2GDJ6ad2RrI7m7lvD/SseFc=; b=AJlTm a7usMZcKM2NPCc4VezYzpvKuW2iFtfhS4yR0yxwh25K6uLHlzxucGGDO2npodHzK 9Zj6fs9sh3VGKNRAJePV/CR5El2X2iTOKUgWdtkcpMCXC0BnTK0l1pKozEnJCOX7 GSz/T/FBT3lDoyapo8cPmKBrLpCnV7fxwyOuCo= Received: (qmail 120576 invoked by alias); 3 Nov 2019 21:19:19 -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 120568 invoked by uid 89); 3 Nov 2019 21:19:19 -0000 Authentication-Results: sourceware.org; auth=none X-HELO: mx1.osci.io X-Gerrit-PatchSet: 1 Date: Sun, 3 Nov 2019 16:19:14 -0500 From: "Carlos O'Donell (Code Review)" To: Florian Weimer , libc-alpha@sourceware.org Auto-Submitted: auto-generated X-Gerrit-MessageType: comment 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 In-Reply-To: References: X-Gerrit-Comment-Date: Sun, 3 Nov 2019 16:19:14 -0500 Reply-To: gnutoolchain-gerrit@osci.io 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 Message-Id: <20191103211914.C04AB25B28@gnutoolchain-gerrit.osci.io> Carlos O'Donell has posted comments on this change. Change URL: https://gnutoolchain-gerrit.osci.io/r/c/glibc/+/488 ...................................................................... Patch Set 1: Code-Review+2 (4 comments) Looks good to me. Reviewed-by: Carlos O'Donell https://gnutoolchain-gerrit.osci.io/r/c/glibc/+/488/1/include/link.h File include/link.h: https://gnutoolchain-gerrit.osci.io/r/c/glibc/+/488/1/include/link.h@338 PS1, Line 338: 333 | . */ 334 | struct auditstate 335 | { 336 | uintptr_t cookie; 337 | unsigned int bindflags; 338 > }; 339 | 340 | 341 | #if __ELF_NATIVE_CLASS == 32 342 | # define symbind symbind32 343 | #elif __ELF_NATIVE_CLASS == 64 OK. Move definition out of the link_map struct. https://gnutoolchain-gerrit.osci.io/r/c/glibc/+/488/1/sysdeps/generic/ldsodefs.h File sysdeps/generic/ldsodefs.h: https://gnutoolchain-gerrit.osci.io/r/c/glibc/+/488/1/sysdeps/generic/ldsodefs.h@387 PS1, Line 387: 382 | /* Structure describing the dynamic linker itself. */ 383 | EXTERN struct link_map _dl_rtld_map; 384 | #ifdef SHARED 385 | /* Used to store the audit information for the link map of the 386 | dynamic loader. */ 387 > struct auditstate _dl_rtld_auditstate[DL_NNS]; 388 | #endif 389 | 390 | #if defined SHARED && defined _LIBC_REENTRANT \ 391 | && defined __rtld_lock_default_lock_recursive 392 | EXTERN void (*_dl_rtld_lock_recursive) (void *); OK. Renamed, but effectively the same. https://gnutoolchain-gerrit.osci.io/r/c/glibc/+/488/1/sysdeps/generic/ldsodefs.h@1184 PS1, Line 1184: 1179 | static inline struct auditstate * 1180 | link_map_audit_state (struct link_map *l, size_t index) 1181 | { 1182 | if (l == &GL (dl_rtld_map)) 1183 | /* The auditstate array is stored separately. */ 1184 > return &GL (dl_rtld_auditstate) [index]; 1185 | else 1186 | { 1187 | /* The auditstate array follows the link map in memory. */ 1188 | struct auditstate *base = (struct auditstate *) (l + 1); 1189 | return &base[index]; OK, for the normal layout of dl_rtld_map. https://gnutoolchain-gerrit.osci.io/r/c/glibc/+/488/1/sysdeps/generic/ldsodefs.h@1189 PS1, Line 1189: 1180 | link_map_audit_state (struct link_map *l, size_t index) | ... 1184 | return &GL (dl_rtld_auditstate) [index]; 1185 | else 1186 | { 1187 | /* The auditstate array follows the link map in memory. */ 1188 | struct auditstate *base = (struct auditstate *) (l + 1); 1189 > return &base[index]; 1190 | } 1191 | } 1192 | #endif /* SHARED */ 1193 | 1194 | __END_DECLS OK. We adjust the base pointer to point at the end of the link_map, then cast to an audit state structure. This is not an aliasing violation, the pointer is outside of the current structure. Once computed we take the array offset based on index and return that. -- Gerrit-Project: glibc Gerrit-Branch: master Gerrit-Change-Id: Ic911100730f9124d4ea977ead8e13cee64b84d45 Gerrit-Change-Number: 488 Gerrit-PatchSet: 1 Gerrit-Owner: Florian Weimer Gerrit-Reviewer: Carlos O'Donell Gerrit-Comment-Date: Sun, 03 Nov 2019 21:19:14 +0000 Gerrit-HasComments: Yes Gerrit-Has-Labels: Yes Gerrit-MessageType: comment