Re: [PATCH 2/2] LoadPin: Make sysctl table const

From: kernel test robot
Date: Sun Feb 02 2025 - 06:11:47 EST


Hi Ricardo,

kernel test robot noticed the following build errors:

[auto build test ERROR on a9a5e0bdc5a77a7c662ad4be0ad661f0b0d5e99d]

url: https://github.com/intel-lab-lkp/linux/commits/Ricardo-B-Marliere/yama-Make-sysctl-table-const/20250124-033808
base: a9a5e0bdc5a77a7c662ad4be0ad661f0b0d5e99d
patch link: https://lore.kernel.org/r/20250123-sysctl-kees-v1-2-533359e74d66%40suse.com
patch subject: [PATCH 2/2] LoadPin: Make sysctl table const
config: arm64-allmodconfig (https://download.01.org/0day-ci/archive/20250202/202502021853.d0nqHvPc-lkp@xxxxxxxxx/config)
compiler: clang version 18.1.8 (https://github.com/llvm/llvm-project 3b5b5c1ec4a3095ab096dd780e84d7ab81f3d7ff)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250202/202502021853.d0nqHvPc-lkp@xxxxxxxxx/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@xxxxxxxxx>
| Closes: https://lore.kernel.org/oe-kbuild-all/202502021853.d0nqHvPc-lkp@xxxxxxxxx/

All errors (new ones prefixed by >>):

>> security/loadpin/loadpin.c:75:34: error: cannot assign to variable 'loadpin_sysctl_table' with const-qualified type 'const struct ctl_table[1]'
75 | loadpin_sysctl_table[0].extra1 = SYSCTL_ZERO;
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^
security/loadpin/loadpin.c:56:31: note: variable 'loadpin_sysctl_table' declared const here
56 | static const struct ctl_table loadpin_sysctl_table[] = {
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
57 | {
| ~
58 | .procname = "enforce",
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
59 | .data = &enforce,
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~
60 | .maxlen = sizeof(int),
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
61 | .mode = 0644,
| ~~~~~~~~~~~~~~~~~~~~~~~
62 | .proc_handler = proc_dointvec_minmax,
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
63 | .extra1 = SYSCTL_ONE,
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
64 | .extra2 = SYSCTL_ONE,
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
65 | },
| ~~
66 | };
| ~
security/loadpin/loadpin.c:77:34: error: cannot assign to variable 'loadpin_sysctl_table' with const-qualified type 'const struct ctl_table[1]'
77 | loadpin_sysctl_table[0].extra1 = SYSCTL_ONE;
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^
security/loadpin/loadpin.c:56:31: note: variable 'loadpin_sysctl_table' declared const here
56 | static const struct ctl_table loadpin_sysctl_table[] = {
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
57 | {
| ~
58 | .procname = "enforce",
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
59 | .data = &enforce,
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~
60 | .maxlen = sizeof(int),
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
61 | .mode = 0644,
| ~~~~~~~~~~~~~~~~~~~~~~~
62 | .proc_handler = proc_dointvec_minmax,
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
63 | .extra1 = SYSCTL_ONE,
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
64 | .extra2 = SYSCTL_ONE,
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
65 | },
| ~~
66 | };
| ~
2 errors generated.


vim +75 security/loadpin/loadpin.c

9b091556a073a9 Kees Cook 2016-04-20 67
60ba1028fc7b73 Kees Cook 2022-12-09 68 static void set_sysctl(bool is_writable)
9b091556a073a9 Kees Cook 2016-04-20 69 {
9b091556a073a9 Kees Cook 2016-04-20 70 /*
9b091556a073a9 Kees Cook 2016-04-20 71 * If load pinning is not enforced via a read-only block
9b091556a073a9 Kees Cook 2016-04-20 72 * device, allow sysctl to change modes for testing.
9b091556a073a9 Kees Cook 2016-04-20 73 */
60ba1028fc7b73 Kees Cook 2022-12-09 74 if (is_writable)
60ba1028fc7b73 Kees Cook 2022-12-09 @75 loadpin_sysctl_table[0].extra1 = SYSCTL_ZERO;
60ba1028fc7b73 Kees Cook 2022-12-09 76 else
60ba1028fc7b73 Kees Cook 2022-12-09 77 loadpin_sysctl_table[0].extra1 = SYSCTL_ONE;
60ba1028fc7b73 Kees Cook 2022-12-09 78 }
60ba1028fc7b73 Kees Cook 2022-12-09 79 #else
60ba1028fc7b73 Kees Cook 2022-12-09 80 static inline void set_sysctl(bool is_writable) { }
60ba1028fc7b73 Kees Cook 2022-12-09 81 #endif
60ba1028fc7b73 Kees Cook 2022-12-09 82

--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki