From 61117bfa1b08ca048e6512c0652c568300fedf6a Mon Sep 17 00:00:00 2001 From: Siddhesh Poyarekar Date: Fri, 5 Feb 2021 13:18:58 +0530 Subject: tunables: Simplify TUNABLE_SET interface The TUNABLE_SET interface took a primitive C type argument, which resulted in inconsistent type conversions internally due to incorrect dereferencing of types, especialy on 32-bit architectures. This change simplifies the TUNABLE setting logic along with the interfaces. Now all numeric tunable values are stored as signed numbers in tunable_num_t, which is intmax_t. All calls to set tunables cast the input value to its primitive type and then to tunable_num_t for storage. This relies on gcc-specific (although I suspect other compilers woul also do the same) unsigned to signed integer conversion semantics, i.e. the bit pattern is conserved. The reverse conversion is guaranteed by the standard. --- elf/dl-tunable-types.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'elf/dl-tunable-types.h') diff --git a/elf/dl-tunable-types.h b/elf/dl-tunable-types.h index 3fcc0806f5..626ca334be 100644 --- a/elf/dl-tunable-types.h +++ b/elf/dl-tunable-types.h @@ -38,8 +38,8 @@ typedef enum typedef struct { tunable_type_code_t type_code; - int64_t min; - int64_t max; + tunable_num_t min; + tunable_num_t max; } tunable_type_t; /* Security level for tunables. This decides what to do with individual -- cgit 1.4.1