]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
Fix getting tunable values on big-endian (BZ #21109)
authorSiddhesh Poyarekar <siddhesh@sourceware.org>
Thu, 9 Feb 2017 16:28:54 +0000 (17:28 +0100)
committerMike Frysinger <vapier@gentoo.org>
Sun, 12 Mar 2017 22:08:03 +0000 (15:08 -0700)
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)
(cherry picked from commit 58520986c38e34db60e07260c64c563e3efcf353)

elf/dl-tunable-types.h
elf/dl-tunables.c
malloc/arena.c

index a986f0b5930d8aba0aac86560bea3d863ed0da5b..37a4e8021f8f1d4d1f3d5f0b7a0a4093dfe7f88c 100644 (file)
@@ -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
index a8d53d6a311d4f532608b4805979c01180c03be2..e42aa670033131f75a682aedf492c017f2bcb673 100644 (file)
@@ -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;
 
index b91d7d6b16cd5fa4931747dc250f64636ad89222..d49e4a21c840b059647a418aca9c210fc77b758d 100644 (file)
@@ -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);                                                     \
 }