diff options
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | elf/dl-tunables.c | 15 | ||||
-rw-r--r-- | scripts/gen-tunables.awk | 12 |
3 files changed, 20 insertions, 13 deletions
@@ -1,3 +1,9 @@ +2017-09-26 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-09-26 H.J. Lu <hongjiu.lu@intel.com> [BZ #22101] diff --git a/elf/dl-tunables.c b/elf/dl-tunables.c index b964a09413..cc2c637543 100644 --- a/elf/dl-tunables.c +++ b/elf/dl-tunables.c @@ -89,18 +89,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; \ @@ -120,17 +113,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" |