This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
[review] Avoid zero-length array at the end of struct link_map [BZ #25097]
- From: "Carlos O'Donell (Code Review)" <gerrit at gnutoolchain-gerrit dot osci dot io>
- To: Florian Weimer <fweimer at redhat dot com>, libc-alpha at sourceware dot org
- Date: Thu, 14 Nov 2019 09:59:34 -0500
- Subject: [review] Avoid zero-length array at the end of struct link_map [BZ #25097]
- Auto-submitted: auto-generated
- References: <gerrit.1572801105000.Ic911100730f9124d4ea977ead8e13cee64b84d45@gnutoolchain-gerrit.osci.io>
- Reply-to: gnutoolchain-gerrit at osci dot io
Carlos O'Donell has posted comments on this change.
Change URL: https://gnutoolchain-gerrit.osci.io/r/c/glibc/+/488
......................................................................
Patch Set 1:
(4 comments)
| --- include/link.h
| +++ include/link.h
| @@ -337,9 +329,19 @@ #endif
|
| +/* 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
| + <ldsodefs.h>. */
| +struct auditstate
| +{
| + uintptr_t cookie;
| + unsigned int bindflags;
| +};
PS1, Line 338:
Done
| +
|
| #if __ELF_NATIVE_CLASS == 32
| # define symbind symbind32
| #elif __ELF_NATIVE_CLASS == 64
| # define symbind symbind64
| #else
| # error "__ELF_NATIVE_CLASS must be defined"
| #endif
| --- sysdeps/generic/ldsodefs.h
| +++ sysdeps/generic/ldsodefs.h
| @@ -381,15 +381,16 @@ #endif
|
| - /* 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];
PS1, Line 387:
Done
| #endif
|
| #if defined SHARED && defined _LIBC_REENTRANT \
| && defined __rtld_lock_default_lock_recursive
| EXTERN void (*_dl_rtld_lock_recursive) (void *);
| EXTERN void (*_dl_rtld_unlock_recursive) (void *);
| #endif
|
| /* Get architecture specific definitions. */
...
| @@ -1175,13 +1176,21 @@ rtld_active (void)
| return GLRO(dl_init_all_dirs) != NULL;
| }
|
| 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];
PS1, Line 1184:
Done
| + else
| + {
| + /* The auditstate array follows the link map in memory. */
| + struct auditstate *base = (struct auditstate *) (l + 1);
| + return &base[index];
PS1, Line 1189:
Done
| + }
| }
| #endif /* SHARED */
|
| __END_DECLS
|
| #endif /* ldsodefs.h */
--
Gerrit-Project: glibc
Gerrit-Branch: master
Gerrit-Change-Id: Ic911100730f9124d4ea977ead8e13cee64b84d45
Gerrit-Change-Number: 488
Gerrit-PatchSet: 1
Gerrit-Owner: Florian Weimer <fweimer@redhat.com>
Gerrit-Reviewer: Carlos O'Donell <carlos@redhat.com>
Gerrit-Comment-Date: Thu, 14 Nov 2019 14:59:34 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Carlos O'Donell <carlos@redhat.com>
Gerrit-MessageType: comment