unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
blob bab52ea578b31b9d2ac8b299654f899d539076c2 4789 bytes (raw)
name: gnu/packages/patches/glibc-2-26-0072.patch 	 # note: path name is non-authoritative(*)

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
 
From 77eea8950ce5495ff033bca3465ccfd2db072ae6 Mon Sep 17 00:00:00 2001
From: Alexey Makhalov <amakhalov@vmware.com>
Date: Wed, 27 Sep 2017 02:44:09 +0530
Subject: [PATCH 72/90] Fix range check in do_tunable_update_val

Current implementation of tunables does not set arena_max and arena_test
values. Any value provided by glibc.malloc.arena_max and
glibc.malloc.arena_test parameters is ignored.

These tunables have minval value set to 1 (see elf/dl-tunables.list file)
and undefined maxval value. In that case default value (which is 0. see
scripts/gen-tunables.awk) is being used to set maxval.

For instance, generated tunable_list[] entry for arena_max is:
(gdb) p *cur
$1 = {name = 0x7ffff7df6217 "glibc.malloc.arena_max",
 type = {type_code = TUNABLE_TYPE_SIZE_T, min = 1, max = 0},
  val = {numval = 0, strval = 0x0}, initialized = false,
   security_level = TUNABLE_SECLEVEL_SXID_IGNORE,
    env_alias = 0x7ffff7df622e "MALLOC_ARENA_MAX"}

As a result, any value of glibc.malloc.arena_max is ignored by
TUNABLE_SET_VAL_IF_VALID_RANGE macro
  __type min = (__cur)->type.min;                    <- initialized to 1
  __type max = (__cur)->type.max;                    <- initialized to 0!
  if (min == max)                                    <- false
    {
      min = __default_min;
      max = __default_max;
    }
  if ((__type) (__val) >= min && (__type) (val) <= max)  <- false
    {
      (__cur)->val.numval = val;
      (__cur)->initialized = true;
    }

Assigning correct min/max values at a build time fixes a problem.
Plus, a bit of optimization: Setting of default min/max values for the
given type at a run time might be eliminated.

	* elf/dl-tunables.c (do_tunable_update_val): Range checking fix.
	* scripts/gen-tunables.awk: Set unspecified minval and/or maxval
	values to correct default value for given type.

diff --git a/ChangeLog b/ChangeLog
index 7a3bcf7de0..366eaba804 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2017-10-23  Alexey Makhalov  <amakhalov@vmware.com>
+
+	* elf/dl-tunables.c (do_tunable_update_val): Range checking fix.
+	* scripts/gen-tunables.awk: Set unspecified minval and/or maxval
+	values to correct default value for given type.
+
 2017-10-19  Joseph Myers  <joseph@codesourcery.com>
 
 	[BZ #22322]
diff --git a/elf/dl-tunables.c b/elf/dl-tunables.c
index 231fb8ca93..d9975ef2d0 100644
--- a/elf/dl-tunables.c
+++ b/elf/dl-tunables.c
@@ -88,18 +88,11 @@ get_next_env (char **envp, char **name, size_t *namelen, char **val,
   return NULL;
 }
 
-#define TUNABLE_SET_VAL_IF_VALID_RANGE(__cur, __val, __type, __default_min, \
-				       __default_max)			      \
+#define TUNABLE_SET_VAL_IF_VALID_RANGE(__cur, __val, __type)		      \
 ({									      \
   __type min = (__cur)->type.min;					      \
   __type max = (__cur)->type.max;					      \
 									      \
-  if (min == max)							      \
-    {									      \
-      min = __default_min;						      \
-      max = __default_max;						      \
-    }									      \
-									      \
   if ((__type) (__val) >= min && (__type) (val) <= max)			      \
     {									      \
       (__cur)->val.numval = val;					      \
@@ -119,17 +112,17 @@ do_tunable_update_val (tunable_t *cur, const void *valp)
     {
     case TUNABLE_TYPE_INT_32:
 	{
-	  TUNABLE_SET_VAL_IF_VALID_RANGE (cur, val, int64_t, INT32_MIN, INT32_MAX);
+	  TUNABLE_SET_VAL_IF_VALID_RANGE (cur, val, int64_t);
 	  break;
 	}
     case TUNABLE_TYPE_UINT_64:
 	{
-	  TUNABLE_SET_VAL_IF_VALID_RANGE (cur, val, uint64_t, 0, UINT64_MAX);
+	  TUNABLE_SET_VAL_IF_VALID_RANGE (cur, val, uint64_t);
 	  break;
 	}
     case TUNABLE_TYPE_SIZE_T:
 	{
-	  TUNABLE_SET_VAL_IF_VALID_RANGE (cur, val, uint64_t, 0, SIZE_MAX);
+	  TUNABLE_SET_VAL_IF_VALID_RANGE (cur, val, uint64_t);
 	  break;
 	}
     case TUNABLE_TYPE_STRING:
diff --git a/scripts/gen-tunables.awk b/scripts/gen-tunables.awk
index ccdd0c6c71..622199061a 100644
--- a/scripts/gen-tunables.awk
+++ b/scripts/gen-tunables.awk
@@ -1,6 +1,14 @@
 # Generate dl-tunable-list.h from dl-tunables.list
 
 BEGIN {
+  min_of["STRING"]="0"
+  max_of["STRING"]="0"
+  min_of["INT_32"]="INT32_MIN"
+  max_of["INT_32"]="INT32_MAX"
+  min_of["UINT_64"]="0"
+  max_of["UINT_64"]="UINT64_MAX"
+  min_of["SIZE_T"]="0"
+  max_of["SIZE_T"]="SIZE_MAX"
   tunable=""
   ns=""
   top_ns=""
@@ -43,10 +51,10 @@ $1 == "}" {
       types[top_ns,ns,tunable] = "STRING"
     }
     if (!minvals[top_ns,ns,tunable]) {
-      minvals[top_ns,ns,tunable] = "0"
+      minvals[top_ns,ns,tunable] = min_of[types[top_ns,ns,tunable]]
     }
     if (!maxvals[top_ns,ns,tunable]) {
-      maxvals[top_ns,ns,tunable] = "0"
+      maxvals[top_ns,ns,tunable] = max_of[types[top_ns,ns,tunable]]
     }
     if (!env_alias[top_ns,ns,tunable]) {
       env_alias[top_ns,ns,tunable] = "NULL"

debug log:

solving bab52ea57 ...
found bab52ea57 in https://yhetil.org/guix-patches/87ine0pjiu.fsf@fastmail.com/ ||
	https://yhetil.org/guix-patches/87d148pe57.fsf@fastmail.com/

applying [1/1] https://yhetil.org/guix-patches/87ine0pjiu.fsf@fastmail.com/
diff --git a/gnu/packages/patches/glibc-2-26-0072.patch b/gnu/packages/patches/glibc-2-26-0072.patch
new file mode 100644
index 000000000..bab52ea57

1:63: trailing whitespace.
 
1:64: space before tab in indent.
 	[BZ #22322]
1:72: trailing whitespace.
 
1:79: space before tab in indent.
 									      \
1:92: space before tab in indent.
 	{
Checking patch gnu/packages/patches/glibc-2-26-0072.patch...
Applied patch gnu/packages/patches/glibc-2-26-0072.patch cleanly.
warning: squelched 9 whitespace errors
warning: 14 lines add whitespace errors.

skipping https://yhetil.org/guix-patches/87d148pe57.fsf@fastmail.com/ for bab52ea57
index at:
100644 bab52ea578b31b9d2ac8b299654f899d539076c2	gnu/packages/patches/glibc-2-26-0072.patch

(*) Git path names are given by the tree(s) the blob belongs to.
    Blobs themselves have no identifier aside from the hash of its contents.^

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).