From 17796419b5fd694348cceb65c3f77601faae082c Mon Sep 17 00:00:00 2001 From: Szabolcs Nagy Date: Tue, 7 Jul 2020 10:49:11 +0100 Subject: rtld: Account static TLS surplus for audit modules The new static TLS surplus size computation is surplus_tls = 192 * (nns-1) + 144 * nns + 512 where nns is controlled via the rtld.nns tunable. This commit accounts audit modules too so nns = rtld.nns + audit modules. rtld.nns should only include the namespaces required by the application, namespaces for audit modules are accounted on top of that so audit modules don't use up the static TLS that is reserved for the application. This allows loading many audit modules without tuning rtld.nns or using up static TLS, and it fixes FAIL: elf/tst-auditmany Note that DL_NNS is currently a hard upper limit for nns, and if rtld.nns + audit modules go over the limit that's a fatal error. By default rtld.nns is 4 which allows 12 audit modules. Counting the audit modules is based on existing audit string parsing code, we cannot use GLRO(dl_naudit) before the modules are actually loaded. --- sysdeps/generic/ldsodefs.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'sysdeps') diff --git a/sysdeps/generic/ldsodefs.h b/sysdeps/generic/ldsodefs.h index 3b0c6d9620..eb3ef5bb28 100644 --- a/sysdeps/generic/ldsodefs.h +++ b/sysdeps/generic/ldsodefs.h @@ -1106,8 +1106,9 @@ extern size_t _dl_count_modids (void) attribute_hidden; /* Calculate offset of the TLS blocks in the static TLS block. */ extern void _dl_determine_tlsoffset (void) attribute_hidden; -/* Calculate the size of the static TLS surplus. */ -void _dl_tls_static_surplus_init (void) attribute_hidden; +/* Calculate the size of the static TLS surplus, when the given + number of audit modules are loaded. */ +void _dl_tls_static_surplus_init (size_t naudit) attribute_hidden; #ifndef SHARED /* Set up the TCB for statically linked applications. This is called -- cgit 1.4.1