kernel.h: Move sysfs related macro to sysfs.h
Subsystems (2)
PATCH 1/1 kernel.h: Move sysfs related macro to sysfs.h
As stated in the comment of VERIFY_OCTAL_PERMISSIONS() it's related to sysfs. Move it to the corresponding header.
--- include/linux/kernel.h | 12 ------------ include/linux/sysfs.h | 13 +++++++++++++ 2 files changed, 13 insertions(+), 12 deletions(-)
include/linux/kernel.h +0 -12
@@ -489,16 +489,4 @@ static inline void ftrace_dump(enum ftrace_dump_mode oops_dump_mode) { }# define REBUILD_DUE_TO_FTRACE_MCOUNT_RECORD #endif -/* Permissions on a sysfs file: you didn't miss the 0 prefix did you? */ -#define VERIFY_OCTAL_PERMISSIONS (perms) \ - (BUILD_BUG_ON_ZERO((perms) < 0) + \ - BUILD_BUG_ON_ZERO((perms) > 0777) + \ -/* USER_READABLE >= GROUP_READABLE >= OTHER_READABLE */ \ -BUILD_BUG_ON_ZERO ((((perms) >>6 ) &4 ) < (((perms) >>3 ) &4 )) + \ -BUILD_BUG_ON_ZERO ((((perms) >>3 ) &4 ) < ((perms) &4 )) + \ -/* USER_WRITABLE >= GROUP_WRITABLE */ \ -BUILD_BUG_ON_ZERO ((((perms) >>6 ) &2 ) < (((perms) >>3 ) &2 )) + \ -/* OTHER_WRITABLE? Generally considered a bad idea. */ \ -BUILD_BUG_ON_ZERO ((perms) &2 ) + \ - (perms))#endif
include/linux/sysfs.h +13 -0
@@ -98,6 +98,19 @@ struct attribute_group {#define SYSFS_PREALLOC 010000 +/* Permissions on a sysfs file: you didn't miss the 0 prefix did you? */ +#define VERIFY_OCTAL_PERMISSIONS (perms) \ + (BUILD_BUG_ON_ZERO((perms) < 0) + \ + BUILD_BUG_ON_ZERO((perms) > 0777) + \ +/* USER_READABLE >= GROUP_READABLE >= OTHER_READABLE */ \ +BUILD_BUG_ON_ZERO ((((perms) >>6 ) &4 ) < (((perms) >>3 ) &4 )) + \ +BUILD_BUG_ON_ZERO ((((perms) >>3 ) &4 ) < ((perms) &4 )) + \ +/* USER_WRITABLE >= GROUP_WRITABLE */ \ +BUILD_BUG_ON_ZERO ((((perms) >>6 ) &2 ) < (((perms) >>3 ) &2 )) + \ +/* OTHER_WRITABLE? Generally considered a bad idea. */ \ +BUILD_BUG_ON_ZERO ((perms) &2 ) + \ + (perms)) + #define __ATTR(_name, _mode, _show, _store) { \ .attr = {.name = __stringify(_name), \ .mode = VERIFY_OCTAL_PERMISSIONS(_mode) }, \
Signature · 1 line
2.35.1
Andrew Morton
maintainerQuoted 2 lines · On Fri, 3 Jun 2022 20:21:01 +0300 Andy Shevchenko…
As stated in the comment of
VERIFY_OCTAL_PERMISSIONS()it's related to sysfs. Move it to the corresponding header.
arm allmodconfig:
In file included from arch/arm/mm/alignment.c:11:./include/linux/moduleparam.h:294:13: error: implicit declaration of function 'VERIFY_OCTAL_PERMISSIONS' [-Werror=implicit-function-declaration]
294 | VERIFY_OCTAL_PERMISSIONS(perm), level, flags, { arg } }
| ^~~~~~~~~~~~~~~~~~~~~~~~
./include/linux/moduleparam.h:330:9: note: in expansion of macro '__module_param_call'
330 | __module_param_call("", name, ¶m_ops_##type, &var, perm, -1, 0)
| ^~~~~~~~~~~~~~~~~~~
arch/arm/mm/alignment.c:87:1: note: in expansion of macro 'core_param'
87 | core_param(alignment, ai_usermode, int, 0600);
| ^~~~~~~~~~
./include/linux/moduleparam.h:294:13: error: initializer element is not constant
294 | VERIFY_OCTAL_PERMISSIONS(perm), level, flags, { arg } }
| ^~~~~~~~~~~~~~~~~~~~~~~~
./include/linux/moduleparam.h:330:9: note: in expansion of macro '__module_param_call'
330 | __module_param_call("", name, ¶m_ops_##type, &var, perm, -1, 0)
| ^~~~~~~~~~~~~~~~~~~
arch/arm/mm/alignment.c:87:1: note: in expansion of macro 'core_param'
87 | core_param(alignment, ai_usermode, int, 0600);
| ^~~~~~~~~~
./include/linux/moduleparam.h:294:13: note: (near initialization for '__param_alignment.perm')
294 | VERIFY_OCTAL_PERMISSIONS(perm), level, flags, { arg } }
| ^~~~~~~~~~~~~~~~~~~~~~~~
./include/linux/moduleparam.h:330:9: note: in expansion of macro '__module_param_call'
330 | __module_param_call("", name, ¶m_ops_##type, &var, perm, -1, 0)
| ^~~~~~~~~~~~~~~~~~~
arch/arm/mm/alignment.c:87:1: note: in expansion of macro 'core_param'
87 | core_param(alignment, ai_usermode, int, 0600);
| ^~~~~~~~~~cc1: all warnings being treated as errors
make[2]: *** [scripts/Makefile.build:271: arch/arm/mm/alignment.o] Error 1 make[1]: *** [scripts/Makefile.build:500: arch/arm/mm] Error 2
make: *** [Makefile:1839: arch/arm] Error 2
Quoted 6 lines · Andrew Morton
Quoted 2 lines · On Fri, 3 Jun 2022 20:21:01 +0300 Andy Shevchenko…
As stated in the comment of
VERIFY_OCTAL_PERMISSIONS()it's related to sysfs. Move it to the corresponding header.arm allmodconfig:
Thanks
x86 builds :(
I will look into it later on.
Signature · 2 lines
With Best Regards, Andy Shevchenko
kernel test robot
build botI love your patch! Yet something to improve:
Hi Andy,
I love your patch! Yet something to improve:
[auto build test ERROR on akpm-mm/mm-everything]
[also build test ERROR on linus/master v5.18 next-20220603] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]
url: https://github.com/intel-lab-lkp/linux/commits/Andy-Shevchenko/kernel-h-Move-sysfs-related-macro-to-sysfs-h/20220606-004344 base: https://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm.git mm-everything config: arm-at91_dt_defconfig (https://download.01.org/0day-ci/archive/20220606/[email protected]/config) compiler: arm-linux-gnueabi-gcc (GCC) 11.3.0
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# https://github.com/intel-lab-lkp/linux/commit/0fad3ce70c6f6736d3913e3238642a056f70b123
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review Andy-Shevchenko/kernel-h-Move-sysfs-related-macro-to-sysfs-h/20220606-004344 git checkout 0fad3ce70c6f6736d3913e3238642a056f70b123
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.3.0 make.cross W=1 O=build_dir ARCH=arm SHELL=/bin/bash
If you fix the issue, kindly add following tag where applicable
All errors (new ones prefixed by >>):
In file included from arch/arm/mm/alignment.c:11:
>> include/linux/moduleparam.h:294:13: error: implicit declaration of function 'VERIFY_OCTAL_PERMISSIONS' [-Werror=implicit-function-declaration]
294 | VERIFY_OCTAL_PERMISSIONS(perm), level, flags, { arg } }
| ^~~~~~~~~~~~~~~~~~~~~~~~
include/linux/moduleparam.h:330:9: note: in expansion of macro '__module_param_call'
330 | __module_param_call("", name, ¶m_ops_##type, &var, perm, -1, 0)
| ^~~~~~~~~~~~~~~~~~~
arch/arm/mm/alignment.c:87:1: note: in expansion of macro 'core_param'
87 | core_param(alignment, ai_usermode, int, 0600);
| ^~~~~~~~~~
>> include/linux/moduleparam.h:294:13: error: initializer element is not constant
294 | VERIFY_OCTAL_PERMISSIONS(perm), level, flags, { arg } }
| ^~~~~~~~~~~~~~~~~~~~~~~~
include/linux/moduleparam.h:330:9: note: in expansion of macro '__module_param_call'
330 | __module_param_call("", name, ¶m_ops_##type, &var, perm, -1, 0)
| ^~~~~~~~~~~~~~~~~~~
arch/arm/mm/alignment.c:87:1: note: in expansion of macro 'core_param'
87 | core_param(alignment, ai_usermode, int, 0600);
| ^~~~~~~~~~
include/linux/moduleparam.h:294:13: note: (near initialization for '__param_alignment.perm')
294 | VERIFY_OCTAL_PERMISSIONS(perm), level, flags, { arg } }
| ^~~~~~~~~~~~~~~~~~~~~~~~
include/linux/moduleparam.h:330:9: note: in expansion of macro '__module_param_call'
330 | __module_param_call("", name, ¶m_ops_##type, &var, perm, -1, 0)
| ^~~~~~~~~~~~~~~~~~~
arch/arm/mm/alignment.c:87:1: note: in expansion of macro 'core_param'
87 | core_param(alignment, ai_usermode, int, 0600);
| ^~~~~~~~~~cc1: some warnings being treated as errors
vim +/VERIFY_OCTAL_PERMISSIONS +294 include/linux/moduleparam.h
91d35dd93e14c3 Ivan Kokshaysky 2008-02-13 284
^1da177e4c3f41 Linus Torvalds 2005-04-16 285 /* This is the fundamental function for registering boot/module
546970bc6afc7f Rusty Russell 2010-08-11 286 parameters. */
91f9d330cc1493 Jani Nikula 2014-08-27 287 #define __module_param_call(prefix, name, ops, arg, perm, level, flags) \
9774a1f54f173a Alexey Dobriyan 2006-12-06 288 /* Default value instead of permissions? */ \
22e48eaf587d04 Jan Beulich 2007-10-16 289 static const char __param_str_##name[] = prefix #name; \
91d35dd93e14c3 Ivan Kokshaysky 2008-02-13 290 static struct kernel_param __moduleparam_const __param_##name \
fe2f4fe139b321 Johan Hovold 2020-11-23 291 __used __section("__param") \
fe2f4fe139b321 Johan Hovold 2020-11-23 292 __aligned(__alignof__(struct kernel_param)) \
b51d23e4e9fea6 Dan Streetman 2015-06-17 293 = { __param_str_##name, THIS_MODULE, ops, \b51d23e4e9fea6 Dan Streetman 2015-06-17 @294 VERIFY_OCTAL_PERMISSIONS(perm), level, flags, { arg } }
^1da177e4c3f41 Linus Torvalds 2005-04-16 295
Signature · 2 lines
0-DAY CI Kernel Test Service https://01.org/lkp
kernel test robot
build botI love your patch! Yet something to improve:
Hi Andy,
I love your patch! Yet something to improve:
[auto build test ERROR on akpm-mm/mm-everything]
[also build test ERROR on linus/master v5.18 next-20220603] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]
url: https://github.com/intel-lab-lkp/linux/commits/Andy-Shevchenko/kernel-h-Move-sysfs-related-macro-to-sysfs-h/20220606-004344 base: https://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm.git mm-everything config: s390-alldefconfig (https://download.01.org/0day-ci/archive/20220606/[email protected]/config) compiler: clang version 15.0.0 (https://github.com/llvm/llvm-project 416a5080d89066029f9889dc23f94de47c2fa895)
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# install s390 cross compiling tool for clang build
# apt-get install binutils-s390x-linux-gnu
# https://github.com/intel-lab-lkp/linux/commit/0fad3ce70c6f6736d3913e3238642a056f70b123
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review Andy-Shevchenko/kernel-h-Move-sysfs-related-macro-to-sysfs-h/20220606-004344 git checkout 0fad3ce70c6f6736d3913e3238642a056f70b123
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=s390 SHELL=/bin/bash arch/s390/crypto/
If you fix the issue, kindly add following tag where applicable
All errors (new ones prefixed by >>):
>> arch/s390/crypto/arch_random.c:145:1: error: call to undeclared function 'VERIFY_OCTAL_PERMISSIONS'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
module_param_named(rndlong_drbg_reseed, rndlong_drbg_reseed, int, 0600);
^
include/linux/moduleparam.h:151:2: note: expanded from macro 'module_param_named'
module_param_cb(name, ¶m_ops_##type, &value, perm); \
^
include/linux/moduleparam.h:176:2: note: expanded from macro 'module_param_cb'
__module_param_call(MODULE_PARAM_PREFIX, name, ops, arg, perm, -1, 0)
^
include/linux/moduleparam.h:294:6: note: expanded from macro '__module_param_call'
VERIFY_OCTAL_PERMISSIONS(perm), level, flags, { arg } }
^
>> arch/s390/crypto/arch_random.c:145:1: error: initializer element is not a compile-time constant
module_param_named(rndlong_drbg_reseed, rndlong_drbg_reseed, int, 0600);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/moduleparam.h:151:2: note: expanded from macro 'module_param_named'
module_param_cb(name, ¶m_ops_##type, &value, perm); \
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/moduleparam.h:176:2: note: expanded from macro 'module_param_cb'
__module_param_call(MODULE_PARAM_PREFIX, name, ops, arg, perm, -1, 0)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/moduleparam.h:294:6: note: expanded from macro '__module_param_call'
VERIFY_OCTAL_PERMISSIONS(perm), level, flags, { arg } }
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~2 errors generated.
vim +/VERIFY_OCTAL_PERMISSIONS +145 arch/s390/crypto/arch_random.c
ff98cc986ae883 Harald Freudenberger 2020-12-03 143
ff98cc986ae883 Harald Freudenberger 2020-12-03 144 static int rndlong_drbg_reseed = 256; ff98cc986ae883 Harald Freudenberger 2020-12-03 @145 module_param_named(rndlong_drbg_reseed, rndlong_drbg_reseed, int, 0600); ff98cc986ae883 Harald Freudenberger 2020-12-03 146 MODULE_PARM_DESC(rndlong_drbg_reseed, "s390 arch_get_random_long() drbg reseed");
ff98cc986ae883 Harald Freudenberger 2020-12-03 147
Signature · 2 lines
0-DAY CI Kernel Test Service https://01.org/lkp
kernel test robot
build botI love your patch! Yet something to improve:
Hi Andy,
I love your patch! Yet something to improve:
[auto build test ERROR on akpm-mm/mm-everything]
[also build test ERROR on linus/master v5.18 next-20220603] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]
url: https://github.com/intel-lab-lkp/linux/commits/Andy-Shevchenko/kernel-h-Move-sysfs-related-macro-to-sysfs-h/20220606-004344 base: https://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm.git mm-everything config: arm-pcm027_defconfig (https://download.01.org/0day-ci/archive/20220606/[email protected]/config) compiler: clang version 15.0.0 (https://github.com/llvm/llvm-project 416a5080d89066029f9889dc23f94de47c2fa895)
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# install arm cross compiling tool for clang build
# apt-get install binutils-arm-linux-gnueabi
# https://github.com/intel-lab-lkp/linux/commit/0fad3ce70c6f6736d3913e3238642a056f70b123
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review Andy-Shevchenko/kernel-h-Move-sysfs-related-macro-to-sysfs-h/20220606-004344 git checkout 0fad3ce70c6f6736d3913e3238642a056f70b123
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=arm SHELL=/bin/bash
If you fix the issue, kindly add following tag where applicable
All errors (new ones prefixed by >>):
>> arch/arm/mm/alignment.c:87:1: error: call to undeclared function 'VERIFY_OCTAL_PERMISSIONS'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
core_param(alignment, ai_usermode, int, 0600);
^
include/linux/moduleparam.h:330:2: note: expanded from macro 'core_param'
__module_param_call("", name, ¶m_ops_##type, &var, perm, -1, 0)
^
include/linux/moduleparam.h:294:6: note: expanded from macro '__module_param_call'
VERIFY_OCTAL_PERMISSIONS(perm), level, flags, { arg } }
^
>> arch/arm/mm/alignment.c:87:1: error: initializer element is not a compile-time constant
core_param(alignment, ai_usermode, int, 0600);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/moduleparam.h:330:2: note: expanded from macro 'core_param'
__module_param_call("", name, ¶m_ops_##type, &var, perm, -1, 0)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/moduleparam.h:294:6: note: expanded from macro '__module_param_call'
VERIFY_OCTAL_PERMISSIONS(perm), level, flags, { arg } }
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~2 errors generated.
vim +/VERIFY_OCTAL_PERMISSIONS +87 arch/arm/mm/alignment.c
^1da177e4c3f41 Linus Torvalds 2005-04-16 86d944d549aa86e0 Russell King 2010-02-20 @87 core_param(alignment, ai_usermode, int, 0600);d944d549aa86e0 Russell King 2010-02-20 88
Signature · 2 lines
0-DAY CI Kernel Test Service https://01.org/lkp