summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSiddhesh Poyarekar <siddhesh@sourceware.org>2017-02-09 17:28:54 +0100
committerFlorian Weimer <fweimer@redhat.com>2017-02-09 17:28:54 +0100
commit58520986c38e34db60e07260c64c563e3efcf353 (patch)
tree58e82d735221aba2766d43cb72864aaa26100746
parentdb0242e3023436757bbc7c488a779e6e3343db04 (diff)
downloadglibc-58520986c38e34db60e07260c64c563e3efcf353.tar.gz
Fix getting tunable values on big-endian (BZ #21109)
The code to set value passed a tunable_val_t, which when cast to int32_t on big-endian gives the wrong value. Instead, use tunable_val_t.numval instead, which can then be safely cast into int32_t. (cherry picked from commit 8cbc826c37c0221ada65a7a622fe079b4e89a4b0)
-rw-r--r--ChangeLog10
-rw-r--r--NEWS6
-rw-r--r--elf/dl-tunable-types.h4
-rw-r--r--elf/dl-tunables.c2
-rw-r--r--malloc/arena.c8
5 files changed, 24 insertions, 6 deletions
diff --git a/ChangeLog b/ChangeLog
index f140ee67de..c88238e0fa 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2017-02-08 Siddhesh Poyarekar <siddhesh@sourceware.org>
+
+ [BZ #21109]
+ * elf/dl-tunable-types.h (tunable_callback_t): Accept
+ tunable_val_t as argument.
+ * elf/dl-tunables.c (__tunable_set_val): Add comment.
+ * malloc/arena.c (set_mallopt_check): Take tunable_val_t as
+ argument.
+ (DL_TUNABLE_CALLBACK_FNDECL): Likewise.
+
2017-02-05 Siddhesh Poyarekar <siddhesh@sourceware.org>
* version.h (RELEASE): Set to "stable"
diff --git a/NEWS b/NEWS
index ec15dde761..325cac78e4 100644
--- a/NEWS
+++ b/NEWS
@@ -5,6 +5,12 @@ See the end for copying conditions.
Please send GNU C library bug reports via <http://sourceware.org/bugzilla/>
using `glibc' in the "product" field.
+Version 2.25.1
+
+The following bugs are resolved with this release:
+
+ [21109] Tunables broken on big-endian
+
Version 2.25
* The feature test macro __STDC_WANT_LIB_EXT2__, from ISO/IEC TR
diff --git a/elf/dl-tunable-types.h b/elf/dl-tunable-types.h
index a986f0b593..37a4e8021f 100644
--- a/elf/dl-tunable-types.h
+++ b/elf/dl-tunable-types.h
@@ -21,8 +21,6 @@
# define _TUNABLE_TYPES_H_
#include <stddef.h>
-typedef void (*tunable_callback_t) (void *);
-
typedef enum
{
TUNABLE_TYPE_INT_32,
@@ -43,6 +41,8 @@ typedef union
const char *strval;
} tunable_val_t;
+typedef void (*tunable_callback_t) (tunable_val_t *);
+
/* Security level for tunables. This decides what to do with individual
tunables for AT_SECURE binaries. */
typedef enum
diff --git a/elf/dl-tunables.c b/elf/dl-tunables.c
index a8d53d6a31..e42aa67003 100644
--- a/elf/dl-tunables.c
+++ b/elf/dl-tunables.c
@@ -455,6 +455,8 @@ __tunable_set_val (tunable_id_t id, void *valp, tunable_callback_t callback)
if (cur->strval == NULL)
return;
+ /* Caller does not need the value, just call the callback with our tunable
+ value. */
if (valp == NULL)
goto cb;
diff --git a/malloc/arena.c b/malloc/arena.c
index b91d7d6b16..d49e4a21c8 100644
--- a/malloc/arena.c
+++ b/malloc/arena.c
@@ -212,9 +212,9 @@ __malloc_fork_unlock_child (void)
#if HAVE_TUNABLES
static inline int do_set_mallopt_check (int32_t value);
void
-DL_TUNABLE_CALLBACK (set_mallopt_check) (void *valp)
+DL_TUNABLE_CALLBACK (set_mallopt_check) (tunable_val_t *valp)
{
- int32_t value = *(int32_t *) valp;
+ int32_t value = (int32_t) valp->numval;
do_set_mallopt_check (value);
if (check_action != 0)
__malloc_check_init ();
@@ -223,9 +223,9 @@ DL_TUNABLE_CALLBACK (set_mallopt_check) (void *valp)
# define DL_TUNABLE_CALLBACK_FNDECL(__name, __type) \
static inline int do_ ## __name (__type value); \
void \
-DL_TUNABLE_CALLBACK (__name) (void *valp) \
+DL_TUNABLE_CALLBACK (__name) (tunable_val_t *valp) \
{ \
- __type value = *(__type *) valp; \
+ __type value = (__type) (valp)->numval; \
do_ ## __name (value); \
}