2023-10-11 07:46:22

by Joey Jiao

[permalink] [raw]
Subject: [PATCH v2] module: Add CONFIG_MODULE_LOAD_IN_SEQUENCE option

When modprobe cmds are executed one by one, the final loaded modules
are not in fixed sequence as expected.

Add the option to make sure modules are in fixed sequence across reboot.

Signed-off-by: Joey Jiao <[email protected]>
---
kernel/module/Kconfig | 11 +++++++++++
kernel/module/main.c | 3 ++-
2 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/kernel/module/Kconfig b/kernel/module/Kconfig
index 33a2e991f608..b45a45f31d6d 100644
--- a/kernel/module/Kconfig
+++ b/kernel/module/Kconfig
@@ -389,4 +389,15 @@ config MODULES_TREE_LOOKUP
def_bool y
depends on PERF_EVENTS || TRACING || CFI_CLANG

+config MODULE_LOAD_IN_SEQUENCE
+ bool "Load module in sequence"
+ default n
+ help
+ By default, modules are loaded in random sequence depending on when modprobe
+ is executed.
+
+ This option allows modules to be loaded in sequence if modprobe cmds are
+ executed one by one in sequence. This option is helpful during syzkaller fuzzing
+ to make sure module is loaded into fixed address across device reboot.
+
endif # MODULES
diff --git a/kernel/module/main.c b/kernel/module/main.c
index 98fedfdb8db5..e238a31d09eb 100644
--- a/kernel/module/main.c
+++ b/kernel/module/main.c
@@ -2594,7 +2594,8 @@ static noinline int do_init_module(struct module *mod)
* rcu_barrier()
*/
if (llist_add(&freeinit->node, &init_free_list))
- schedule_work(&init_free_wq);
+ if (!IS_ENABLED(CONFIG_MODULE_LOAD_IN_SEQUENCE)) {
+ schedule_work(&init_free_wq);

mutex_unlock(&module_mutex);
wake_up_all(&module_wq);
--
2.42.0


2023-10-11 11:02:26

by kernel test robot

[permalink] [raw]
Subject: Re: [PATCH v2] module: Add CONFIG_MODULE_LOAD_IN_SEQUENCE option

Hi Joey,

kernel test robot noticed the following build warnings:

[auto build test WARNING on mcgrof/modules-next]
[also build test WARNING on linus/master v6.6-rc5 next-20231011]
[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#_base_tree_information]

url: https://github.com/intel-lab-lkp/linux/commits/Joey-Jiao/module-Add-CONFIG_MODULE_LOAD_IN_SEQUENCE-option/20231011-154640
base: https://git.kernel.org/pub/scm/linux/kernel/git/mcgrof/linux.git modules-next
patch link: https://lore.kernel.org/r/20231011074438.6098-1-quic_jiangenj%40quicinc.com
patch subject: [PATCH v2] module: Add CONFIG_MODULE_LOAD_IN_SEQUENCE option
config: m68k-allyesconfig (https://download.01.org/0day-ci/archive/20231011/[email protected]/config)
compiler: m68k-linux-gcc (GCC) 13.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20231011/[email protected]/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 <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All warnings (new ones prefixed by >>):

kernel/module/main.c: In function 'do_init_module':
kernel/module/main.c:2627:12: error: invalid storage class for function 'may_init_module'
2627 | static int may_init_module(void)
| ^~~~~~~~~~~~~~~
kernel/module/main.c:2636:13: error: invalid storage class for function 'finished_loading'
2636 | static bool finished_loading(const char *name)
| ^~~~~~~~~~~~~~~~
kernel/module/main.c:2657:12: error: invalid storage class for function 'module_patient_check_exists'
2657 | static int module_patient_check_exists(const char *name,
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~
kernel/module/main.c:2701:12: error: invalid storage class for function 'add_unformed_module'
2701 | static int add_unformed_module(struct module *mod)
| ^~~~~~~~~~~~~~~~~~~
kernel/module/main.c:2722:12: error: invalid storage class for function 'complete_formation'
2722 | static int complete_formation(struct module *mod, struct load_info *info)
| ^~~~~~~~~~~~~~~~~~
kernel/module/main.c:2755:12: error: invalid storage class for function 'prepare_coming_module'
2755 | static int prepare_coming_module(struct module *mod)
| ^~~~~~~~~~~~~~~~~~~~~
kernel/module/main.c:2773:12: error: invalid storage class for function 'unknown_module_param_cb'
2773 | static int unknown_module_param_cb(char *param, char *val, const char *modname,
| ^~~~~~~~~~~~~~~~~~~~~~~
kernel/module/main.c:2793:12: error: invalid storage class for function 'early_mod_check'
2793 | static int early_mod_check(struct load_info *info, int flags)
| ^~~~~~~~~~~~~~~
kernel/module/main.c:2829:12: error: invalid storage class for function 'load_module'
2829 | static int load_module(struct load_info *info, const char __user *uargs,
| ^~~~~~~~~~~
In file included from include/linux/compiler_types.h:125,
from <command-line>:
>> include/linux/compiler-gcc.h:132:33: warning: 'alias' attribute ignored [-Wattributes]
132 | #define __diag(s) _Pragma(__diag_str(GCC diagnostic s))
| ^~~~~~~
include/linux/compiler-gcc.h:135:33: note: in expansion of macro '__diag'
135 | #define __diag_GCC_8(s) __diag(s)
| ^~~~~~
include/linux/compiler-gcc.h:123:9: note: in expansion of macro '__diag_GCC_8'
123 | __diag_GCC_ ## version(__diag_GCC_ ## severity s)
| ^~~~~~~~~~~
include/linux/compiler_types.h:416:9: note: in expansion of macro '__diag_GCC'
416 | __diag_ ## compiler(version, ignore, option)
| ^~~~~~~
include/linux/syscalls.h:242:9: note: in expansion of macro '__diag_ignore'
242 | __diag_ignore(GCC, 8, "-Wattribute-alias", \
| ^~~~~~~~~~~~~
include/linux/syscalls.h:230:9: note: in expansion of macro '__SYSCALL_DEFINEx'
230 | __SYSCALL_DEFINEx(x, sname, __VA_ARGS__)
| ^~~~~~~~~~~~~~~~~
include/linux/syscalls.h:221:36: note: in expansion of macro 'SYSCALL_DEFINEx'
221 | #define SYSCALL_DEFINE3(name, ...) SYSCALL_DEFINEx(3, _##name, __VA_ARGS__)
| ^~~~~~~~~~~~~~~
kernel/module/main.c:3039:1: note: in expansion of macro 'SYSCALL_DEFINE3'
3039 | SYSCALL_DEFINE3(init_module, void __user *, umod,
| ^~~~~~~~~~~~~~~
In file included from kernel/module/main.c:26:
include/linux/syscalls.h:247:28: error: invalid storage class for function '__do_sys_init_module'
247 | static inline long __do_sys##name(__MAP(x,__SC_DECL,__VA_ARGS__));\
| ^~~~~~~~
include/linux/syscalls.h:230:9: note: in expansion of macro '__SYSCALL_DEFINEx'
230 | __SYSCALL_DEFINEx(x, sname, __VA_ARGS__)
| ^~~~~~~~~~~~~~~~~
include/linux/syscalls.h:221:36: note: in expansion of macro 'SYSCALL_DEFINEx'
221 | #define SYSCALL_DEFINE3(name, ...) SYSCALL_DEFINEx(3, _##name, __VA_ARGS__)
| ^~~~~~~~~~~~~~~
kernel/module/main.c:3039:1: note: in expansion of macro 'SYSCALL_DEFINE3'
3039 | SYSCALL_DEFINE3(init_module, void __user *, umod,
| ^~~~~~~~~~~~~~~
include/linux/syscalls.h:249:25: error: static declaration of '__se_sys_init_module' follows non-static declaration
249 | asmlinkage long __se_sys##name(__MAP(x,__SC_LONG,__VA_ARGS__)) \
| ^~~~~~~~
include/linux/syscalls.h:230:9: note: in expansion of macro '__SYSCALL_DEFINEx'
230 | __SYSCALL_DEFINEx(x, sname, __VA_ARGS__)
| ^~~~~~~~~~~~~~~~~
include/linux/syscalls.h:221:36: note: in expansion of macro 'SYSCALL_DEFINEx'
221 | #define SYSCALL_DEFINE3(name, ...) SYSCALL_DEFINEx(3, _##name, __VA_ARGS__)
| ^~~~~~~~~~~~~~~
kernel/module/main.c:3039:1: note: in expansion of macro 'SYSCALL_DEFINE3'
3039 | SYSCALL_DEFINE3(init_module, void __user *, umod,
| ^~~~~~~~~~~~~~~
include/linux/syscalls.h:248:25: note: previous declaration of '__se_sys_init_module' with type 'long int(long int, long int, long int)'
248 | asmlinkage long __se_sys##name(__MAP(x,__SC_LONG,__VA_ARGS__)); \
| ^~~~~~~~
include/linux/syscalls.h:230:9: note: in expansion of macro '__SYSCALL_DEFINEx'
230 | __SYSCALL_DEFINEx(x, sname, __VA_ARGS__)
| ^~~~~~~~~~~~~~~~~
include/linux/syscalls.h:221:36: note: in expansion of macro 'SYSCALL_DEFINEx'
221 | #define SYSCALL_DEFINE3(name, ...) SYSCALL_DEFINEx(3, _##name, __VA_ARGS__)
| ^~~~~~~~~~~~~~~
kernel/module/main.c:3039:1: note: in expansion of macro 'SYSCALL_DEFINE3'
3039 | SYSCALL_DEFINE3(init_module, void __user *, umod,
| ^~~~~~~~~~~~~~~
kernel/module/main.c: In function '__se_sys_init_module':
include/linux/syscalls.h:251:28: error: implicit declaration of function '__do_sys_init_module'; did you mean '__se_sys_init_module'? [-Werror=implicit-function-declaration]
251 | long ret = __do_sys##name(__MAP(x,__SC_CAST,__VA_ARGS__));\
| ^~~~~~~~
include/linux/syscalls.h:230:9: note: in expansion of macro '__SYSCALL_DEFINEx'
230 | __SYSCALL_DEFINEx(x, sname, __VA_ARGS__)
| ^~~~~~~~~~~~~~~~~
include/linux/syscalls.h:221:36: note: in expansion of macro 'SYSCALL_DEFINEx'
221 | #define SYSCALL_DEFINE3(name, ...) SYSCALL_DEFINEx(3, _##name, __VA_ARGS__)
| ^~~~~~~~~~~~~~~
kernel/module/main.c:3039:1: note: in expansion of macro 'SYSCALL_DEFINE3'
3039 | SYSCALL_DEFINE3(init_module, void __user *, umod,
| ^~~~~~~~~~~~~~~
kernel/module/main.c: In function 'do_init_module':
include/linux/syscalls.h:257:28: error: invalid storage class for function '__do_sys_init_module'
257 | static inline long __do_sys##name(__MAP(x,__SC_DECL,__VA_ARGS__))
| ^~~~~~~~
include/linux/syscalls.h:230:9: note: in expansion of macro '__SYSCALL_DEFINEx'
230 | __SYSCALL_DEFINEx(x, sname, __VA_ARGS__)
| ^~~~~~~~~~~~~~~~~
include/linux/syscalls.h:221:36: note: in expansion of macro 'SYSCALL_DEFINEx'
221 | #define SYSCALL_DEFINE3(name, ...) SYSCALL_DEFINEx(3, _##name, __VA_ARGS__)
| ^~~~~~~~~~~~~~~
kernel/module/main.c:3039:1: note: in expansion of macro 'SYSCALL_DEFINE3'
3039 | SYSCALL_DEFINE3(init_module, void __user *, umod,
| ^~~~~~~~~~~~~~~
kernel/module/main.c:3073:13: error: invalid storage class for function 'idempotent'
3073 | static bool idempotent(struct idempotent *u, const void *cookie)
| ^~~~~~~~~~
kernel/module/main.c:3104:12: error: invalid storage class for function 'idempotent_complete'
3104 | static int idempotent_complete(struct idempotent *u, int ret)
| ^~~~~~~~~~~~~~~~~~~
kernel/module/main.c:3124:12: error: invalid storage class for function 'init_module_from_file'
3124 | static int init_module_from_file(struct file *f, const char __user * uargs, int flags)
| ^~~~~~~~~~~~~~~~~~~~~
kernel/module/main.c:3152:12: error: invalid storage class for function 'idempotent_init_module'
3152 | static int idempotent_init_module(struct file *f, const char __user * uargs, int flags)
| ^~~~~~~~~~~~~~~~~~~~~~
>> include/linux/compiler-gcc.h:132:33: warning: 'alias' attribute ignored [-Wattributes]
132 | #define __diag(s) _Pragma(__diag_str(GCC diagnostic s))
| ^~~~~~~
include/linux/compiler-gcc.h:135:33: note: in expansion of macro '__diag'
135 | #define __diag_GCC_8(s) __diag(s)
| ^~~~~~
include/linux/compiler-gcc.h:123:9: note: in expansion of macro '__diag_GCC_8'
123 | __diag_GCC_ ## version(__diag_GCC_ ## severity s)
| ^~~~~~~~~~~
include/linux/compiler_types.h:416:9: note: in expansion of macro '__diag_GCC'
416 | __diag_ ## compiler(version, ignore, option)
| ^~~~~~~
include/linux/syscalls.h:242:9: note: in expansion of macro '__diag_ignore'
242 | __diag_ignore(GCC, 8, "-Wattribute-alias", \
| ^~~~~~~~~~~~~
include/linux/syscalls.h:230:9: note: in expansion of macro '__SYSCALL_DEFINEx'
230 | __SYSCALL_DEFINEx(x, sname, __VA_ARGS__)
| ^~~~~~~~~~~~~~~~~
include/linux/syscalls.h:221:36: note: in expansion of macro 'SYSCALL_DEFINEx'
221 | #define SYSCALL_DEFINE3(name, ...) SYSCALL_DEFINEx(3, _##name, __VA_ARGS__)
| ^~~~~~~~~~~~~~~
kernel/module/main.c:3170:1: note: in expansion of macro 'SYSCALL_DEFINE3'
3170 | SYSCALL_DEFINE3(finit_module, int, fd, const char __user *, uargs, int, flags)
| ^~~~~~~~~~~~~~~
include/linux/syscalls.h:247:28: error: invalid storage class for function '__do_sys_finit_module'
247 | static inline long __do_sys##name(__MAP(x,__SC_DECL,__VA_ARGS__));\
| ^~~~~~~~
include/linux/syscalls.h:230:9: note: in expansion of macro '__SYSCALL_DEFINEx'
230 | __SYSCALL_DEFINEx(x, sname, __VA_ARGS__)
| ^~~~~~~~~~~~~~~~~
include/linux/syscalls.h:221:36: note: in expansion of macro 'SYSCALL_DEFINEx'
221 | #define SYSCALL_DEFINE3(name, ...) SYSCALL_DEFINEx(3, _##name, __VA_ARGS__)
| ^~~~~~~~~~~~~~~
kernel/module/main.c:3170:1: note: in expansion of macro 'SYSCALL_DEFINE3'
3170 | SYSCALL_DEFINE3(finit_module, int, fd, const char __user *, uargs, int, flags)
| ^~~~~~~~~~~~~~~
include/linux/syscalls.h:249:25: error: static declaration of '__se_sys_finit_module' follows non-static declaration
249 | asmlinkage long __se_sys##name(__MAP(x,__SC_LONG,__VA_ARGS__)) \
| ^~~~~~~~
include/linux/syscalls.h:230:9: note: in expansion of macro '__SYSCALL_DEFINEx'
230 | __SYSCALL_DEFINEx(x, sname, __VA_ARGS__)
| ^~~~~~~~~~~~~~~~~
include/linux/syscalls.h:221:36: note: in expansion of macro 'SYSCALL_DEFINEx'
221 | #define SYSCALL_DEFINE3(name, ...) SYSCALL_DEFINEx(3, _##name, __VA_ARGS__)
| ^~~~~~~~~~~~~~~
kernel/module/main.c:3170:1: note: in expansion of macro 'SYSCALL_DEFINE3'
3170 | SYSCALL_DEFINE3(finit_module, int, fd, const char __user *, uargs, int, flags)
| ^~~~~~~~~~~~~~~
include/linux/syscalls.h:248:25: note: previous declaration of '__se_sys_finit_module' with type 'long int(long int, long int, long int)'
248 | asmlinkage long __se_sys##name(__MAP(x,__SC_LONG,__VA_ARGS__)); \
| ^~~~~~~~
include/linux/syscalls.h:230:9: note: in expansion of macro '__SYSCALL_DEFINEx'
230 | __SYSCALL_DEFINEx(x, sname, __VA_ARGS__)
| ^~~~~~~~~~~~~~~~~
include/linux/syscalls.h:221:36: note: in expansion of macro 'SYSCALL_DEFINEx'
221 | #define SYSCALL_DEFINE3(name, ...) SYSCALL_DEFINEx(3, _##name, __VA_ARGS__)
| ^~~~~~~~~~~~~~~
kernel/module/main.c:3170:1: note: in expansion of macro 'SYSCALL_DEFINE3'
3170 | SYSCALL_DEFINE3(finit_module, int, fd, const char __user *, uargs, int, flags)
| ^~~~~~~~~~~~~~~
kernel/module/main.c: In function '__se_sys_finit_module':
include/linux/syscalls.h:251:28: error: implicit declaration of function '__do_sys_finit_module'; did you mean '__do_sys_init_module'? [-Werror=implicit-function-declaration]
251 | long ret = __do_sys##name(__MAP(x,__SC_CAST,__VA_ARGS__));\
| ^~~~~~~~
include/linux/syscalls.h:230:9: note: in expansion of macro '__SYSCALL_DEFINEx'
230 | __SYSCALL_DEFINEx(x, sname, __VA_ARGS__)
| ^~~~~~~~~~~~~~~~~
include/linux/syscalls.h:221:36: note: in expansion of macro 'SYSCALL_DEFINEx'
221 | #define SYSCALL_DEFINE3(name, ...) SYSCALL_DEFINEx(3, _##name, __VA_ARGS__)
| ^~~~~~~~~~~~~~~
kernel/module/main.c:3170:1: note: in expansion of macro 'SYSCALL_DEFINE3'
3170 | SYSCALL_DEFINE3(finit_module, int, fd, const char __user *, uargs, int, flags)
| ^~~~~~~~~~~~~~~
kernel/module/main.c: In function 'do_init_module':
include/linux/syscalls.h:257:28: error: invalid storage class for function '__do_sys_finit_module'
257 | static inline long __do_sys##name(__MAP(x,__SC_DECL,__VA_ARGS__))
| ^~~~~~~~
include/linux/syscalls.h:230:9: note: in expansion of macro '__SYSCALL_DEFINEx'
230 | __SYSCALL_DEFINEx(x, sname, __VA_ARGS__)
| ^~~~~~~~~~~~~~~~~
include/linux/syscalls.h:221:36: note: in expansion of macro 'SYSCALL_DEFINEx'
221 | #define SYSCALL_DEFINE3(name, ...) SYSCALL_DEFINEx(3, _##name, __VA_ARGS__)
| ^~~~~~~~~~~~~~~
kernel/module/main.c:3170:1: note: in expansion of macro 'SYSCALL_DEFINE3'
3170 | SYSCALL_DEFINE3(finit_module, int, fd, const char __user *, uargs, int, flags)
| ^~~~~~~~~~~~~~~
kernel/module/main.c:3361:12: error: invalid storage class for function 'module_debugfs_init'
3361 | static int module_debugfs_init(void)
| ^~~~~~~~~~~~~~~~~~~
In file included from include/linux/printk.h:6,
from include/asm-generic/bug.h:22,
from arch/m68k/include/asm/bug.h:32,
from include/linux/bug.h:5,
from include/linux/thread_info.h:13,
from include/asm-generic/preempt.h:5,
from ./arch/m68k/include/generated/asm/preempt.h:1,
from include/linux/preempt.h:79,
from arch/m68k/include/asm/irqflags.h:6,
from include/linux/irqflags.h:17,
from arch/m68k/include/asm/atomic.h:6,
from include/linux/atomic.h:7,
from include/linux/mm_types_task.h:13,
from include/linux/mm_types.h:5,
from include/linux/buildid.h:5,
from include/linux/module.h:14,
from include/linux/moduleloader.h:6,
from kernel/module/main.c:12:
kernel/module/main.c:3366:13: error: initializer element is not constant
3366 | module_init(module_debugfs_init);
| ^~~~~~~~~~~~~~~~~~~
include/linux/init.h:270:55: note: in definition of macro '____define_initcall'
270 | __attribute__((__section__(__sec))) = fn;
| ^~
include/linux/init.h:280:9: note: in expansion of macro '__unique_initcall'
280 | __unique_initcall(fn, id, __sec, __initcall_id(fn))
| ^~~~~~~~~~~~~~~~~
include/linux/init.h:282:35: note: in expansion of macro '___define_initcall'
282 | #define __define_initcall(fn, id) ___define_initcall(fn, id, .initcall##id)
| ^~~~~~~~~~~~~~~~~~
include/linux/init.h:311:41: note: in expansion of macro '__define_initcall'
311 | #define device_initcall(fn) __define_initcall(fn, 6)
| ^~~~~~~~~~~~~~~~~
include/linux/init.h:316:24: note: in expansion of macro 'device_initcall'
316 | #define __initcall(fn) device_initcall(fn)
| ^~~~~~~~~~~~~~~
include/linux/module.h:88:25: note: in expansion of macro '__initcall'
88 | #define module_init(x) __initcall(x);
| ^~~~~~~~~~
kernel/module/main.c:3366:1: note: in expansion of macro 'module_init'
3366 | module_init(module_debugfs_init);
| ^~~~~~~~~~~
kernel/module/main.c:3366:1: error: expected declaration or statement at end of input
>> kernel/module/main.c:3359:16: warning: variable 'mod_debugfs_root' set but not used [-Wunused-but-set-variable]
3359 | struct dentry *mod_debugfs_root;
| ^~~~~~~~~~~~~~~~
kernel/module/main.c: At top level:
>> kernel/module/main.c:3336:6: warning: 'print_modules' defined but not used [-Wunused-function]
3336 | void print_modules(void)
| ^~~~~~~~~~~~~
>> kernel/module/main.c:3323:16: warning: '__module_text_address' defined but not used [-Wunused-function]
3323 | struct module *__module_text_address(unsigned long addr)
| ^~~~~~~~~~~~~~~~~~~~~
>> kernel/module/main.c:3305:6: warning: 'is_module_text_address' defined but not used [-Wunused-function]
3305 | bool is_module_text_address(unsigned long addr)
| ^~~~~~~~~~~~~~~~~~~~~~
>> kernel/module/main.c:3253:6: warning: 'is_module_address' defined but not used [-Wunused-function]
3253 | bool is_module_address(unsigned long addr)
| ^~~~~~~~~~~~~~~~~
>> kernel/module/main.c:3220:37: warning: 'search_module_extables' defined but not used [-Wunused-function]
3220 | const struct exception_table_entry *search_module_extables(unsigned long addr)
| ^~~~~~~~~~~~~~~~~~~~~~
>> include/linux/syscalls.h:249:25: warning: '__se_sys_finit_module' defined but not used [-Wunused-function]
249 | asmlinkage long __se_sys##name(__MAP(x,__SC_LONG,__VA_ARGS__)) \
| ^~~~~~~~
include/linux/syscalls.h:230:9: note: in expansion of macro '__SYSCALL_DEFINEx'
230 | __SYSCALL_DEFINEx(x, sname, __VA_ARGS__)
| ^~~~~~~~~~~~~~~~~
include/linux/syscalls.h:221:36: note: in expansion of macro 'SYSCALL_DEFINEx'
221 | #define SYSCALL_DEFINE3(name, ...) SYSCALL_DEFINEx(3, _##name, __VA_ARGS__)
| ^~~~~~~~~~~~~~~
kernel/module/main.c:3170:1: note: in expansion of macro 'SYSCALL_DEFINE3'
3170 | SYSCALL_DEFINE3(finit_module, int, fd, const char __user *, uargs, int, flags)
| ^~~~~~~~~~~~~~~
>> include/linux/syscalls.h:249:25: warning: '__se_sys_init_module' defined but not used [-Wunused-function]
249 | asmlinkage long __se_sys##name(__MAP(x,__SC_LONG,__VA_ARGS__)) \
| ^~~~~~~~
include/linux/syscalls.h:230:9: note: in expansion of macro '__SYSCALL_DEFINEx'
230 | __SYSCALL_DEFINEx(x, sname, __VA_ARGS__)
| ^~~~~~~~~~~~~~~~~
include/linux/syscalls.h:221:36: note: in expansion of macro 'SYSCALL_DEFINEx'
221 | #define SYSCALL_DEFINE3(name, ...) SYSCALL_DEFINEx(3, _##name, __VA_ARGS__)
| ^~~~~~~~~~~~~~~
kernel/module/main.c:3039:1: note: in expansion of macro 'SYSCALL_DEFINE3'
3039 | SYSCALL_DEFINE3(init_module, void __user *, umod,
| ^~~~~~~~~~~~~~~
cc1: some warnings being treated as errors


vim +/mod_debugfs_root +3359 kernel/module/main.c

fa3ba2e81ea23416 kernel/module.c Florin Malita 2006-10-11 3218
^1da177e4c3f4152 kernel/module.c Linus Torvalds 2005-04-16 3219 /* Given an address, look for it in the module exception tables. */
^1da177e4c3f4152 kernel/module.c Linus Torvalds 2005-04-16 @3220 const struct exception_table_entry *search_module_extables(unsigned long addr)
^1da177e4c3f4152 kernel/module.c Linus Torvalds 2005-04-16 3221 {
^1da177e4c3f4152 kernel/module.c Linus Torvalds 2005-04-16 3222 const struct exception_table_entry *e = NULL;
^1da177e4c3f4152 kernel/module.c Linus Torvalds 2005-04-16 3223 struct module *mod;
^1da177e4c3f4152 kernel/module.c Linus Torvalds 2005-04-16 3224
24da1cbff9cfce50 kernel/module.c Rusty Russell 2007-07-15 3225 preempt_disable();
5ff22646d246e23b kernel/module.c Peter Zijlstra 2017-02-08 3226 mod = __module_address(addr);
5ff22646d246e23b kernel/module.c Peter Zijlstra 2017-02-08 3227 if (!mod)
5ff22646d246e23b kernel/module.c Peter Zijlstra 2017-02-08 3228 goto out;
5ff22646d246e23b kernel/module.c Peter Zijlstra 2017-02-08 3229
5ff22646d246e23b kernel/module.c Peter Zijlstra 2017-02-08 3230 if (!mod->num_exentries)
5ff22646d246e23b kernel/module.c Peter Zijlstra 2017-02-08 3231 goto out;
^1da177e4c3f4152 kernel/module.c Linus Torvalds 2005-04-16 3232
^1da177e4c3f4152 kernel/module.c Linus Torvalds 2005-04-16 3233 e = search_extable(mod->extable,
a94c33dd1f677d16 kernel/module.c Thomas Meyer 2017-07-10 3234 mod->num_exentries,
^1da177e4c3f4152 kernel/module.c Linus Torvalds 2005-04-16 3235 addr);
5ff22646d246e23b kernel/module.c Peter Zijlstra 2017-02-08 3236 out:
24da1cbff9cfce50 kernel/module.c Rusty Russell 2007-07-15 3237 preempt_enable();
^1da177e4c3f4152 kernel/module.c Linus Torvalds 2005-04-16 3238
5ff22646d246e23b kernel/module.c Peter Zijlstra 2017-02-08 3239 /*
5ff22646d246e23b kernel/module.c Peter Zijlstra 2017-02-08 3240 * Now, if we found one, we are running inside it now, hence
5ff22646d246e23b kernel/module.c Peter Zijlstra 2017-02-08 3241 * we cannot unload the module, hence no refcnt needed.
5ff22646d246e23b kernel/module.c Peter Zijlstra 2017-02-08 3242 */
^1da177e4c3f4152 kernel/module.c Linus Torvalds 2005-04-16 3243 return e;
^1da177e4c3f4152 kernel/module.c Linus Torvalds 2005-04-16 3244 }
^1da177e4c3f4152 kernel/module.c Linus Torvalds 2005-04-16 3245
2541743e99c301f9 kernel/module.c Sergey Shtylyov 2020-11-04 3246 /**
2541743e99c301f9 kernel/module.c Sergey Shtylyov 2020-11-04 3247 * is_module_address() - is this address inside a module?
e610499e2656e619 kernel/module.c Rusty Russell 2009-03-31 3248 * @addr: the address to check.
e610499e2656e619 kernel/module.c Rusty Russell 2009-03-31 3249 *
e610499e2656e619 kernel/module.c Rusty Russell 2009-03-31 3250 * See is_module_text_address() if you simply want to see if the address
e610499e2656e619 kernel/module.c Rusty Russell 2009-03-31 3251 * is code (not data).
4d435f9d8ff01ae7 kernel/module.c Ingo Molnar 2006-07-03 3252 */
e610499e2656e619 kernel/module.c Rusty Russell 2009-03-31 @3253 bool is_module_address(unsigned long addr)
4d435f9d8ff01ae7 kernel/module.c Ingo Molnar 2006-07-03 3254 {
e610499e2656e619 kernel/module.c Rusty Russell 2009-03-31 3255 bool ret;
4d435f9d8ff01ae7 kernel/module.c Ingo Molnar 2006-07-03 3256
24da1cbff9cfce50 kernel/module.c Rusty Russell 2007-07-15 3257 preempt_disable();
e610499e2656e619 kernel/module.c Rusty Russell 2009-03-31 3258 ret = __module_address(addr) != NULL;
24da1cbff9cfce50 kernel/module.c Rusty Russell 2007-07-15 3259 preempt_enable();
4d435f9d8ff01ae7 kernel/module.c Ingo Molnar 2006-07-03 3260
e610499e2656e619 kernel/module.c Rusty Russell 2009-03-31 3261 return ret;
4d435f9d8ff01ae7 kernel/module.c Ingo Molnar 2006-07-03 3262 }
4d435f9d8ff01ae7 kernel/module.c Ingo Molnar 2006-07-03 3263
2541743e99c301f9 kernel/module.c Sergey Shtylyov 2020-11-04 3264 /**
2541743e99c301f9 kernel/module.c Sergey Shtylyov 2020-11-04 3265 * __module_address() - get the module which contains an address.
e610499e2656e619 kernel/module.c Rusty Russell 2009-03-31 3266 * @addr: the address.
e610499e2656e619 kernel/module.c Rusty Russell 2009-03-31 3267 *
e610499e2656e619 kernel/module.c Rusty Russell 2009-03-31 3268 * Must be called with preempt disabled or module mutex held so that
e610499e2656e619 kernel/module.c Rusty Russell 2009-03-31 3269 * module doesn't get freed during this.
e610499e2656e619 kernel/module.c Rusty Russell 2009-03-31 3270 */
714f83d5d9f7c785 kernel/module.c Linus Torvalds 2009-04-05 3271 struct module *__module_address(unsigned long addr)
^1da177e4c3f4152 kernel/module.c Linus Torvalds 2005-04-16 3272 {
^1da177e4c3f4152 kernel/module.c Linus Torvalds 2005-04-16 3273 struct module *mod;
^1da177e4c3f4152 kernel/module.c Linus Torvalds 2005-04-16 3274
01dc0386efb76905 kernel/module/main.c Christophe Leroy 2022-02-23 3275 if (addr >= mod_tree.addr_min && addr <= mod_tree.addr_max)
ac3b432839234409 kernel/module/main.c Song Liu 2023-02-06 3276 goto lookup;
ac3b432839234409 kernel/module/main.c Song Liu 2023-02-06 3277
01dc0386efb76905 kernel/module/main.c Christophe Leroy 2022-02-23 3278 #ifdef CONFIG_ARCH_WANTS_MODULES_DATA_IN_VMALLOC
ac3b432839234409 kernel/module/main.c Song Liu 2023-02-06 3279 if (addr >= mod_tree.data_addr_min && addr <= mod_tree.data_addr_max)
ac3b432839234409 kernel/module/main.c Song Liu 2023-02-06 3280 goto lookup;
01dc0386efb76905 kernel/module/main.c Christophe Leroy 2022-02-23 3281 #endif
ac3b432839234409 kernel/module/main.c Song Liu 2023-02-06 3282
3a642e99babe0617 kernel/module.c Rusty Russell 2008-07-22 3283 return NULL;
3a642e99babe0617 kernel/module.c Rusty Russell 2008-07-22 3284
ac3b432839234409 kernel/module/main.c Song Liu 2023-02-06 3285 lookup:
0be964be0d450842 kernel/module.c Peter Zijlstra 2015-05-27 3286 module_assert_mutex_or_preempt();
0be964be0d450842 kernel/module.c Peter Zijlstra 2015-05-27 3287
ac3b432839234409 kernel/module/main.c Song Liu 2023-02-06 3288 mod = mod_find(addr, &mod_tree);
93c2e105f6bcee23 kernel/module.c Peter Zijlstra 2015-05-27 3289 if (mod) {
93c2e105f6bcee23 kernel/module.c Peter Zijlstra 2015-05-27 3290 BUG_ON(!within_module(addr, mod));
0d21b0e3477395e7 kernel/module.c Rusty Russell 2013-01-12 3291 if (mod->state == MODULE_STATE_UNFORMED)
93c2e105f6bcee23 kernel/module.c Peter Zijlstra 2015-05-27 3292 mod = NULL;
0d21b0e3477395e7 kernel/module.c Rusty Russell 2013-01-12 3293 }
93c2e105f6bcee23 kernel/module.c Peter Zijlstra 2015-05-27 3294 return mod;
^1da177e4c3f4152 kernel/module.c Linus Torvalds 2005-04-16 3295 }
^1da177e4c3f4152 kernel/module.c Linus Torvalds 2005-04-16 3296
2541743e99c301f9 kernel/module.c Sergey Shtylyov 2020-11-04 3297 /**
2541743e99c301f9 kernel/module.c Sergey Shtylyov 2020-11-04 3298 * is_module_text_address() - is this address inside module code?
e610499e2656e619 kernel/module.c Rusty Russell 2009-03-31 3299 * @addr: the address to check.
e610499e2656e619 kernel/module.c Rusty Russell 2009-03-31 3300 *
e610499e2656e619 kernel/module.c Rusty Russell 2009-03-31 3301 * See is_module_address() if you simply want to see if the address is
e610499e2656e619 kernel/module.c Rusty Russell 2009-03-31 3302 * anywhere in a module. See kernel_text_address() for testing if an
e610499e2656e619 kernel/module.c Rusty Russell 2009-03-31 3303 * address corresponds to kernel or module code.
e610499e2656e619 kernel/module.c Rusty Russell 2009-03-31 3304 */
e610499e2656e619 kernel/module.c Rusty Russell 2009-03-31 @3305 bool is_module_text_address(unsigned long addr)
e610499e2656e619 kernel/module.c Rusty Russell 2009-03-31 3306 {
e610499e2656e619 kernel/module.c Rusty Russell 2009-03-31 3307 bool ret;
e610499e2656e619 kernel/module.c Rusty Russell 2009-03-31 3308
e610499e2656e619 kernel/module.c Rusty Russell 2009-03-31 3309 preempt_disable();
e610499e2656e619 kernel/module.c Rusty Russell 2009-03-31 3310 ret = __module_text_address(addr) != NULL;
e610499e2656e619 kernel/module.c Rusty Russell 2009-03-31 3311 preempt_enable();
e610499e2656e619 kernel/module.c Rusty Russell 2009-03-31 3312
e610499e2656e619 kernel/module.c Rusty Russell 2009-03-31 3313 return ret;
e610499e2656e619 kernel/module.c Rusty Russell 2009-03-31 3314 }
e610499e2656e619 kernel/module.c Rusty Russell 2009-03-31 3315
2541743e99c301f9 kernel/module.c Sergey Shtylyov 2020-11-04 3316 /**
2541743e99c301f9 kernel/module.c Sergey Shtylyov 2020-11-04 3317 * __module_text_address() - get the module whose code contains an address.
e610499e2656e619 kernel/module.c Rusty Russell 2009-03-31 3318 * @addr: the address.
e610499e2656e619 kernel/module.c Rusty Russell 2009-03-31 3319 *
e610499e2656e619 kernel/module.c Rusty Russell 2009-03-31 3320 * Must be called with preempt disabled or module mutex held so that
e610499e2656e619 kernel/module.c Rusty Russell 2009-03-31 3321 * module doesn't get freed during this.
e610499e2656e619 kernel/module.c Rusty Russell 2009-03-31 3322 */
e610499e2656e619 kernel/module.c Rusty Russell 2009-03-31 @3323 struct module *__module_text_address(unsigned long addr)
e610499e2656e619 kernel/module.c Rusty Russell 2009-03-31 3324 {
e610499e2656e619 kernel/module.c Rusty Russell 2009-03-31 3325 struct module *mod = __module_address(addr);
e610499e2656e619 kernel/module.c Rusty Russell 2009-03-31 3326 if (mod) {
e610499e2656e619 kernel/module.c Rusty Russell 2009-03-31 3327 /* Make sure it's within the text section. */
ac3b432839234409 kernel/module/main.c Song Liu 2023-02-06 3328 if (!within_module_mem_type(addr, mod, MOD_TEXT) &&
ac3b432839234409 kernel/module/main.c Song Liu 2023-02-06 3329 !within_module_mem_type(addr, mod, MOD_INIT_TEXT))
e610499e2656e619 kernel/module.c Rusty Russell 2009-03-31 3330 mod = NULL;
e610499e2656e619 kernel/module.c Rusty Russell 2009-03-31 3331 }
e610499e2656e619 kernel/module.c Rusty Russell 2009-03-31 3332 return mod;
e610499e2656e619 kernel/module.c Rusty Russell 2009-03-31 3333 }
e610499e2656e619 kernel/module.c Rusty Russell 2009-03-31 3334
^1da177e4c3f4152 kernel/module.c Linus Torvalds 2005-04-16 3335 /* Don't grab lock, we're oopsing. */
^1da177e4c3f4152 kernel/module.c Linus Torvalds 2005-04-16 @3336 void print_modules(void)
^1da177e4c3f4152 kernel/module.c Linus Torvalds 2005-04-16 3337 {
^1da177e4c3f4152 kernel/module.c Linus Torvalds 2005-04-16 3338 struct module *mod;
7fd8329ba502ef76 kernel/module.c Petr Mladek 2016-09-21 3339 char buf[MODULE_FLAGS_BUF_SIZE];
^1da177e4c3f4152 kernel/module.c Linus Torvalds 2005-04-16 3340
b231125af7811a2f kernel/module.c Linus Torvalds 2009-06-16 3341 printk(KERN_DEFAULT "Modules linked in:");
d72b37513cdfbd3f kernel/module.c Andi Kleen 2008-08-30 3342 /* Most callers should already have preempt disabled, but make sure */
d72b37513cdfbd3f kernel/module.c Andi Kleen 2008-08-30 3343 preempt_disable();
0d21b0e3477395e7 kernel/module.c Rusty Russell 2013-01-12 3344 list_for_each_entry_rcu(mod, &modules, list) {
0d21b0e3477395e7 kernel/module.c Rusty Russell 2013-01-12 3345 if (mod->state == MODULE_STATE_UNFORMED)
0d21b0e3477395e7 kernel/module.c Rusty Russell 2013-01-12 3346 continue;
17dd25c29cda98c3 kernel/module/main.c Aaron Tomlin 2022-07-14 3347 pr_cont(" %s%s", mod->name, module_flags(mod, buf, true));
0d21b0e3477395e7 kernel/module.c Rusty Russell 2013-01-12 3348 }
99bd9956551b27cb kernel/module/main.c Aaron Tomlin 2022-05-02 3349
99bd9956551b27cb kernel/module/main.c Aaron Tomlin 2022-05-02 3350 print_unloaded_tainted_modules();
d72b37513cdfbd3f kernel/module.c Andi Kleen 2008-08-30 3351 preempt_enable();
6f1dae1d84b6d085 kernel/module/main.c Aaron Tomlin 2022-07-14 3352 if (last_unloaded_module.name[0])
6f1dae1d84b6d085 kernel/module/main.c Aaron Tomlin 2022-07-14 3353 pr_cont(" [last unloaded: %s%s]", last_unloaded_module.name,
6f1dae1d84b6d085 kernel/module/main.c Aaron Tomlin 2022-07-14 3354 last_unloaded_module.taints);
27bba4d6bb3779a6 kernel/module.c Jiri Slaby 2014-02-03 3355 pr_cont("\n");
^1da177e4c3f4152 kernel/module.c Linus Torvalds 2005-04-16 3356 }
df3e764d8e5cd416 kernel/module/main.c Luis Chamberlain 2023-03-28 3357
df3e764d8e5cd416 kernel/module/main.c Luis Chamberlain 2023-03-28 3358 #ifdef CONFIG_MODULE_DEBUGFS
df3e764d8e5cd416 kernel/module/main.c Luis Chamberlain 2023-03-28 @3359 struct dentry *mod_debugfs_root;
df3e764d8e5cd416 kernel/module/main.c Luis Chamberlain 2023-03-28 3360
df3e764d8e5cd416 kernel/module/main.c Luis Chamberlain 2023-03-28 3361 static int module_debugfs_init(void)
df3e764d8e5cd416 kernel/module/main.c Luis Chamberlain 2023-03-28 3362 {
df3e764d8e5cd416 kernel/module/main.c Luis Chamberlain 2023-03-28 3363 mod_debugfs_root = debugfs_create_dir("modules", NULL);
df3e764d8e5cd416 kernel/module/main.c Luis Chamberlain 2023-03-28 3364 return 0;
df3e764d8e5cd416 kernel/module/main.c Luis Chamberlain 2023-03-28 3365 }
df3e764d8e5cd416 kernel/module/main.c Luis Chamberlain 2023-03-28 @3366 module_init(module_debugfs_init);

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

2023-10-11 19:20:21

by Luis Chamberlain

[permalink] [raw]
Subject: Re: [PATCH v2] module: Add CONFIG_MODULE_LOAD_IN_SEQUENCE option

On Wed, Oct 11, 2023 at 01:14:38PM +0530, Joey Jiao wrote:
> When modprobe cmds are executed one by one, the final loaded modules
> are not in fixed sequence as expected.
>
> Add the option to make sure modules are in fixed sequence across reboot.
>
> Signed-off-by: Joey Jiao <[email protected]>
> ---
> kernel/module/Kconfig | 11 +++++++++++
> kernel/module/main.c | 3 ++-
> 2 files changed, 13 insertions(+), 1 deletion(-)
>
> diff --git a/kernel/module/Kconfig b/kernel/module/Kconfig
> index 33a2e991f608..b45a45f31d6d 100644
> --- a/kernel/module/Kconfig
> +++ b/kernel/module/Kconfig
> @@ -389,4 +389,15 @@ config MODULES_TREE_LOOKUP
> def_bool y
> depends on PERF_EVENTS || TRACING || CFI_CLANG
>
> +config MODULE_LOAD_IN_SEQUENCE
> + bool "Load module in sequence"
> + default n
> + help
> + By default, modules are loaded in random sequence depending on when modprobe
> + is executed.
> +
> + This option allows modules to be loaded in sequence if modprobe cmds are
> + executed one by one in sequence. This option is helpful during syzkaller fuzzing
> + to make sure module is loaded into fixed address across device reboot.
> +
> endif # MODULES
> diff --git a/kernel/module/main.c b/kernel/module/main.c
> index 98fedfdb8db5..e238a31d09eb 100644
> --- a/kernel/module/main.c
> +++ b/kernel/module/main.c
> @@ -2594,7 +2594,8 @@ static noinline int do_init_module(struct module *mod)
> * rcu_barrier()
> */
> if (llist_add(&freeinit->node, &init_free_list))
> - schedule_work(&init_free_wq);
> + if (!IS_ENABLED(CONFIG_MODULE_LOAD_IN_SEQUENCE)) {
> + schedule_work(&init_free_wq);
>

As Christoph suggested the rationale for something like this needs to be
clearly spelled out in the commit log and if so valuable it should be
a default. The commit log and even the Kconfig description do little
to justify any rationale for this.

Luis

2023-10-12 18:25:28

by kernel test robot

[permalink] [raw]
Subject: Re: [PATCH v2] module: Add CONFIG_MODULE_LOAD_IN_SEQUENCE option

Hi Joey,

kernel test robot noticed the following build errors:

[auto build test ERROR on mcgrof/modules-next]
[also build test ERROR on linus/master v6.6-rc5 next-20231012]
[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#_base_tree_information]

url: https://github.com/intel-lab-lkp/linux/commits/Joey-Jiao/module-Add-CONFIG_MODULE_LOAD_IN_SEQUENCE-option/20231011-154640
base: https://git.kernel.org/pub/scm/linux/kernel/git/mcgrof/linux.git modules-next
patch link: https://lore.kernel.org/r/20231011074438.6098-1-quic_jiangenj%40quicinc.com
patch subject: [PATCH v2] module: Add CONFIG_MODULE_LOAD_IN_SEQUENCE option
config: um-allnoconfig (https://download.01.org/0day-ci/archive/20231013/[email protected]/config)
compiler: clang version 17.0.0 (https://github.com/llvm/llvm-project.git 4a5ac14ee968ff0ad5d2cc1ffa0299048db4c88a)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20231013/[email protected]/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 <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All errors (new ones prefixed by >>):

In file included from kernel/module/main.c:14:
In file included from include/linux/trace_events.h:9:
In file included from include/linux/hardirq.h:11:
In file included from arch/um/include/asm/hardirq.h:5:
In file included from include/asm-generic/hardirq.h:17:
In file included from include/linux/irq.h:20:
In file included from include/linux/io.h:13:
In file included from arch/um/include/asm/io.h:24:
include/asm-generic/io.h:547:31: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
547 | val = __raw_readb(PCI_IOBASE + addr);
| ~~~~~~~~~~ ^
include/asm-generic/io.h:560:61: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
560 | val = __le16_to_cpu((__le16 __force)__raw_readw(PCI_IOBASE + addr));
| ~~~~~~~~~~ ^
include/uapi/linux/byteorder/little_endian.h:37:51: note: expanded from macro '__le16_to_cpu'
37 | #define __le16_to_cpu(x) ((__force __u16)(__le16)(x))
| ^
In file included from kernel/module/main.c:14:
In file included from include/linux/trace_events.h:9:
In file included from include/linux/hardirq.h:11:
In file included from arch/um/include/asm/hardirq.h:5:
In file included from include/asm-generic/hardirq.h:17:
In file included from include/linux/irq.h:20:
In file included from include/linux/io.h:13:
In file included from arch/um/include/asm/io.h:24:
include/asm-generic/io.h:573:61: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
573 | val = __le32_to_cpu((__le32 __force)__raw_readl(PCI_IOBASE + addr));
| ~~~~~~~~~~ ^
include/uapi/linux/byteorder/little_endian.h:35:51: note: expanded from macro '__le32_to_cpu'
35 | #define __le32_to_cpu(x) ((__force __u32)(__le32)(x))
| ^
In file included from kernel/module/main.c:14:
In file included from include/linux/trace_events.h:9:
In file included from include/linux/hardirq.h:11:
In file included from arch/um/include/asm/hardirq.h:5:
In file included from include/asm-generic/hardirq.h:17:
In file included from include/linux/irq.h:20:
In file included from include/linux/io.h:13:
In file included from arch/um/include/asm/io.h:24:
include/asm-generic/io.h:584:33: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
584 | __raw_writeb(value, PCI_IOBASE + addr);
| ~~~~~~~~~~ ^
include/asm-generic/io.h:594:59: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
594 | __raw_writew((u16 __force)cpu_to_le16(value), PCI_IOBASE + addr);
| ~~~~~~~~~~ ^
include/asm-generic/io.h:604:59: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
604 | __raw_writel((u32 __force)cpu_to_le32(value), PCI_IOBASE + addr);
| ~~~~~~~~~~ ^
include/asm-generic/io.h:692:20: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
692 | readsb(PCI_IOBASE + addr, buffer, count);
| ~~~~~~~~~~ ^
include/asm-generic/io.h:700:20: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
700 | readsw(PCI_IOBASE + addr, buffer, count);
| ~~~~~~~~~~ ^
include/asm-generic/io.h:708:20: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
708 | readsl(PCI_IOBASE + addr, buffer, count);
| ~~~~~~~~~~ ^
include/asm-generic/io.h:717:21: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
717 | writesb(PCI_IOBASE + addr, buffer, count);
| ~~~~~~~~~~ ^
include/asm-generic/io.h:726:21: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
726 | writesw(PCI_IOBASE + addr, buffer, count);
| ~~~~~~~~~~ ^
include/asm-generic/io.h:735:21: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
735 | writesl(PCI_IOBASE + addr, buffer, count);
| ~~~~~~~~~~ ^
>> kernel/module/main.c:2628:1: error: function definition is not allowed here
2628 | {
| ^
kernel/module/main.c:2637:1: error: function definition is not allowed here
2637 | {
| ^
kernel/module/main.c:2659:1: error: function definition is not allowed here
2659 | {
| ^
kernel/module/main.c:2702:1: error: function definition is not allowed here
2702 | {
| ^
kernel/module/main.c:2723:1: error: function definition is not allowed here
2723 | {
| ^
kernel/module/main.c:2756:1: error: function definition is not allowed here
2756 | {
| ^
kernel/module/main.c:2775:1: error: function definition is not allowed here
2775 | {
| ^
kernel/module/main.c:2794:1: error: function definition is not allowed here
2794 | {
| ^
kernel/module/main.c:2831:1: error: function definition is not allowed here
2831 | {
| ^
>> kernel/module/main.c:3039:1: error: function declared in block scope cannot have 'static' storage class
3039 | SYSCALL_DEFINE3(init_module, void __user *, umod,
| ^
include/linux/syscalls.h:221:36: note: expanded from macro 'SYSCALL_DEFINE3'
221 | #define SYSCALL_DEFINE3(name, ...) SYSCALL_DEFINEx(3, _##name, __VA_ARGS__)
| ^
include/linux/syscalls.h:230:2: note: expanded from macro 'SYSCALL_DEFINEx'
230 | __SYSCALL_DEFINEx(x, sname, __VA_ARGS__)
| ^
include/linux/syscalls.h:247:2: note: expanded from macro '__SYSCALL_DEFINEx'
247 | static inline long __do_sys##name(__MAP(x,__SC_DECL,__VA_ARGS__));\
| ^
kernel/module/main.c:3039:1: error: function definition is not allowed here
include/linux/syscalls.h:221:36: note: expanded from macro 'SYSCALL_DEFINE3'
221 | #define SYSCALL_DEFINE3(name, ...) SYSCALL_DEFINEx(3, _##name, __VA_ARGS__)
| ^
include/linux/syscalls.h:230:2: note: expanded from macro 'SYSCALL_DEFINEx'
230 | __SYSCALL_DEFINEx(x, sname, __VA_ARGS__)
| ^
include/linux/syscalls.h:250:2: note: expanded from macro '__SYSCALL_DEFINEx'
250 | { \
| ^
kernel/module/main.c:3041:1: error: function definition is not allowed here
3041 | {
| ^
kernel/module/main.c:3074:1: error: function definition is not allowed here
3074 | {
| ^
kernel/module/main.c:3105:1: error: function definition is not allowed here
3105 | {
| ^
kernel/module/main.c:3125:1: error: function definition is not allowed here
3125 | {
| ^
kernel/module/main.c:3153:1: error: function definition is not allowed here
3153 | {
| ^
kernel/module/main.c:3170:1: error: function declared in block scope cannot have 'static' storage class
3170 | SYSCALL_DEFINE3(finit_module, int, fd, const char __user *, uargs, int, flags)
| ^
include/linux/syscalls.h:221:36: note: expanded from macro 'SYSCALL_DEFINE3'
221 | #define SYSCALL_DEFINE3(name, ...) SYSCALL_DEFINEx(3, _##name, __VA_ARGS__)
| ^
include/linux/syscalls.h:230:2: note: expanded from macro 'SYSCALL_DEFINEx'
230 | __SYSCALL_DEFINEx(x, sname, __VA_ARGS__)
| ^
include/linux/syscalls.h:247:2: note: expanded from macro '__SYSCALL_DEFINEx'
247 | static inline long __do_sys##name(__MAP(x,__SC_DECL,__VA_ARGS__));\
| ^
kernel/module/main.c:3170:1: error: function definition is not allowed here
include/linux/syscalls.h:221:36: note: expanded from macro 'SYSCALL_DEFINE3'
221 | #define SYSCALL_DEFINE3(name, ...) SYSCALL_DEFINEx(3, _##name, __VA_ARGS__)
| ^
include/linux/syscalls.h:230:2: note: expanded from macro 'SYSCALL_DEFINEx'
230 | __SYSCALL_DEFINEx(x, sname, __VA_ARGS__)
| ^
include/linux/syscalls.h:250:2: note: expanded from macro '__SYSCALL_DEFINEx'
250 | { \
| ^
kernel/module/main.c:3171:1: error: function definition is not allowed here
3171 | {
| ^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
12 warnings and 20 errors generated.


vim +2628 kernel/module/main.c

34e1169d996ab1 kernel/module.c Kees Cook 2012-10-16 2626
34e1169d996ab1 kernel/module.c Kees Cook 2012-10-16 2627 static int may_init_module(void)
34e1169d996ab1 kernel/module.c Kees Cook 2012-10-16 @2628 {
34e1169d996ab1 kernel/module.c Kees Cook 2012-10-16 2629 if (!capable(CAP_SYS_MODULE) || modules_disabled)
34e1169d996ab1 kernel/module.c Kees Cook 2012-10-16 2630 return -EPERM;
34e1169d996ab1 kernel/module.c Kees Cook 2012-10-16 2631
34e1169d996ab1 kernel/module.c Kees Cook 2012-10-16 2632 return 0;
34e1169d996ab1 kernel/module.c Kees Cook 2012-10-16 2633 }
34e1169d996ab1 kernel/module.c Kees Cook 2012-10-16 2634

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

2023-10-12 18:37:09

by kernel test robot

[permalink] [raw]
Subject: Re: [PATCH v2] module: Add CONFIG_MODULE_LOAD_IN_SEQUENCE option

Hi Joey,

kernel test robot noticed the following build warnings:

[auto build test WARNING on mcgrof/modules-next]
[also build test WARNING on linus/master v6.6-rc5 next-20231012]
[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#_base_tree_information]

url: https://github.com/intel-lab-lkp/linux/commits/Joey-Jiao/module-Add-CONFIG_MODULE_LOAD_IN_SEQUENCE-option/20231011-154640
base: https://git.kernel.org/pub/scm/linux/kernel/git/mcgrof/linux.git modules-next
patch link: https://lore.kernel.org/r/20231011074438.6098-1-quic_jiangenj%40quicinc.com
patch subject: [PATCH v2] module: Add CONFIG_MODULE_LOAD_IN_SEQUENCE option
config: um-i386_defconfig (https://download.01.org/0day-ci/archive/20231013/[email protected]/config)
compiler: gcc-7 (Ubuntu 7.5.0-6ubuntu2) 7.5.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20231013/[email protected]/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 <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All warnings (new ones prefixed by >>):

kernel/module/main.c: In function 'do_init_module':
kernel/module/main.c:2627:12: error: invalid storage class for function 'may_init_module'
static int may_init_module(void)
^~~~~~~~~~~~~~~
kernel/module/main.c:2636:13: error: invalid storage class for function 'finished_loading'
static bool finished_loading(const char *name)
^~~~~~~~~~~~~~~~
kernel/module/main.c:2657:12: error: invalid storage class for function 'module_patient_check_exists'
static int module_patient_check_exists(const char *name,
^~~~~~~~~~~~~~~~~~~~~~~~~~~
kernel/module/main.c:2701:12: error: invalid storage class for function 'add_unformed_module'
static int add_unformed_module(struct module *mod)
^~~~~~~~~~~~~~~~~~~
kernel/module/main.c:2722:12: error: invalid storage class for function 'complete_formation'
static int complete_formation(struct module *mod, struct load_info *info)
^~~~~~~~~~~~~~~~~~
kernel/module/main.c:2755:12: error: invalid storage class for function 'prepare_coming_module'
static int prepare_coming_module(struct module *mod)
^~~~~~~~~~~~~~~~~~~~~
kernel/module/main.c:2773:12: error: invalid storage class for function 'unknown_module_param_cb'
static int unknown_module_param_cb(char *param, char *val, const char *modname,
^~~~~~~~~~~~~~~~~~~~~~~
kernel/module/main.c:2793:12: error: invalid storage class for function 'early_mod_check'
static int early_mod_check(struct load_info *info, int flags)
^~~~~~~~~~~~~~~
kernel/module/main.c:2829:12: error: invalid storage class for function 'load_module'
static int load_module(struct load_info *info, const char __user *uargs,
^~~~~~~~~~~
>> kernel/module/main.c:3039:1: warning: 'alias' attribute ignored [-Wattributes]
SYSCALL_DEFINE3(init_module, void __user *, umod,
^~~~~~~~~~~~~~~
In file included from kernel/module/main.c:26:0:
include/linux/syscalls.h:247:21: error: invalid storage class for function '__do_sys_init_module'
static inline long __do_sys##name(__MAP(x,__SC_DECL,__VA_ARGS__));\
^
include/linux/syscalls.h:230:2: note: in expansion of macro '__SYSCALL_DEFINEx'
__SYSCALL_DEFINEx(x, sname, __VA_ARGS__)
^~~~~~~~~~~~~~~~~
include/linux/syscalls.h:221:36: note: in expansion of macro 'SYSCALL_DEFINEx'
#define SYSCALL_DEFINE3(name, ...) SYSCALL_DEFINEx(3, _##name, __VA_ARGS__)
^~~~~~~~~~~~~~~
kernel/module/main.c:3039:1: note: in expansion of macro 'SYSCALL_DEFINE3'
SYSCALL_DEFINE3(init_module, void __user *, umod,
^~~~~~~~~~~~~~~
include/linux/syscalls.h:249:18: error: static declaration of '__se_sys_init_module' follows non-static declaration
asmlinkage long __se_sys##name(__MAP(x,__SC_LONG,__VA_ARGS__)) \
^
include/linux/syscalls.h:230:2: note: in expansion of macro '__SYSCALL_DEFINEx'
__SYSCALL_DEFINEx(x, sname, __VA_ARGS__)
^~~~~~~~~~~~~~~~~
include/linux/syscalls.h:221:36: note: in expansion of macro 'SYSCALL_DEFINEx'
#define SYSCALL_DEFINE3(name, ...) SYSCALL_DEFINEx(3, _##name, __VA_ARGS__)
^~~~~~~~~~~~~~~
kernel/module/main.c:3039:1: note: in expansion of macro 'SYSCALL_DEFINE3'
SYSCALL_DEFINE3(init_module, void __user *, umod,
^~~~~~~~~~~~~~~
include/linux/syscalls.h:248:18: note: previous declaration of '__se_sys_init_module' was here
asmlinkage long __se_sys##name(__MAP(x,__SC_LONG,__VA_ARGS__)); \
^
include/linux/syscalls.h:230:2: note: in expansion of macro '__SYSCALL_DEFINEx'
__SYSCALL_DEFINEx(x, sname, __VA_ARGS__)
^~~~~~~~~~~~~~~~~
include/linux/syscalls.h:221:36: note: in expansion of macro 'SYSCALL_DEFINEx'
#define SYSCALL_DEFINE3(name, ...) SYSCALL_DEFINEx(3, _##name, __VA_ARGS__)
^~~~~~~~~~~~~~~
kernel/module/main.c:3039:1: note: in expansion of macro 'SYSCALL_DEFINE3'
SYSCALL_DEFINE3(init_module, void __user *, umod,
^~~~~~~~~~~~~~~
kernel/module/main.c: In function '__se_sys_init_module':
include/linux/syscalls.h:251:14: error: implicit declaration of function '__do_sys_init_module'; did you mean '__se_sys_init_module'? [-Werror=implicit-function-declaration]
long ret = __do_sys##name(__MAP(x,__SC_CAST,__VA_ARGS__));\
^
include/linux/syscalls.h:230:2: note: in expansion of macro '__SYSCALL_DEFINEx'
__SYSCALL_DEFINEx(x, sname, __VA_ARGS__)
^~~~~~~~~~~~~~~~~
include/linux/syscalls.h:221:36: note: in expansion of macro 'SYSCALL_DEFINEx'
#define SYSCALL_DEFINE3(name, ...) SYSCALL_DEFINEx(3, _##name, __VA_ARGS__)
^~~~~~~~~~~~~~~
kernel/module/main.c:3039:1: note: in expansion of macro 'SYSCALL_DEFINE3'
SYSCALL_DEFINE3(init_module, void __user *, umod,
^~~~~~~~~~~~~~~
kernel/module/main.c: In function 'do_init_module':
include/linux/syscalls.h:257:21: error: invalid storage class for function '__do_sys_init_module'
static inline long __do_sys##name(__MAP(x,__SC_DECL,__VA_ARGS__))
^
include/linux/syscalls.h:230:2: note: in expansion of macro '__SYSCALL_DEFINEx'
__SYSCALL_DEFINEx(x, sname, __VA_ARGS__)
^~~~~~~~~~~~~~~~~
include/linux/syscalls.h:221:36: note: in expansion of macro 'SYSCALL_DEFINEx'
#define SYSCALL_DEFINE3(name, ...) SYSCALL_DEFINEx(3, _##name, __VA_ARGS__)
^~~~~~~~~~~~~~~
kernel/module/main.c:3039:1: note: in expansion of macro 'SYSCALL_DEFINE3'
SYSCALL_DEFINE3(init_module, void __user *, umod,
^~~~~~~~~~~~~~~
kernel/module/main.c:3073:13: error: invalid storage class for function 'idempotent'
static bool idempotent(struct idempotent *u, const void *cookie)
^~~~~~~~~~
kernel/module/main.c:3104:12: error: invalid storage class for function 'idempotent_complete'
static int idempotent_complete(struct idempotent *u, int ret)
^~~~~~~~~~~~~~~~~~~
kernel/module/main.c:3124:12: error: invalid storage class for function 'init_module_from_file'
static int init_module_from_file(struct file *f, const char __user * uargs, int flags)
^~~~~~~~~~~~~~~~~~~~~
kernel/module/main.c:3152:12: error: invalid storage class for function 'idempotent_init_module'
static int idempotent_init_module(struct file *f, const char __user * uargs, int flags)
^~~~~~~~~~~~~~~~~~~~~~
kernel/module/main.c:3170:1: warning: 'alias' attribute ignored [-Wattributes]
SYSCALL_DEFINE3(finit_module, int, fd, const char __user *, uargs, int, flags)
^~~~~~~~~~~~~~~
In file included from kernel/module/main.c:26:0:
include/linux/syscalls.h:247:21: error: invalid storage class for function '__do_sys_finit_module'
static inline long __do_sys##name(__MAP(x,__SC_DECL,__VA_ARGS__));\
^
include/linux/syscalls.h:230:2: note: in expansion of macro '__SYSCALL_DEFINEx'
__SYSCALL_DEFINEx(x, sname, __VA_ARGS__)
^~~~~~~~~~~~~~~~~
include/linux/syscalls.h:221:36: note: in expansion of macro 'SYSCALL_DEFINEx'
#define SYSCALL_DEFINE3(name, ...) SYSCALL_DEFINEx(3, _##name, __VA_ARGS__)
^~~~~~~~~~~~~~~
kernel/module/main.c:3170:1: note: in expansion of macro 'SYSCALL_DEFINE3'
SYSCALL_DEFINE3(finit_module, int, fd, const char __user *, uargs, int, flags)
^~~~~~~~~~~~~~~
include/linux/syscalls.h:249:18: error: static declaration of '__se_sys_finit_module' follows non-static declaration
asmlinkage long __se_sys##name(__MAP(x,__SC_LONG,__VA_ARGS__)) \
^
include/linux/syscalls.h:230:2: note: in expansion of macro '__SYSCALL_DEFINEx'
__SYSCALL_DEFINEx(x, sname, __VA_ARGS__)
^~~~~~~~~~~~~~~~~
include/linux/syscalls.h:221:36: note: in expansion of macro 'SYSCALL_DEFINEx'


vim +/alias +3039 kernel/module/main.c

b99b87f70c7785 kernel/module.c Peter Oberparleiter 2009-06-17 3038
17da2bd90abf42 kernel/module.c Heiko Carstens 2009-01-14 @3039 SYSCALL_DEFINE3(init_module, void __user *, umod,
17da2bd90abf42 kernel/module.c Heiko Carstens 2009-01-14 3040 unsigned long, len, const char __user *, uargs)
^1da177e4c3f41 kernel/module.c Linus Torvalds 2005-04-16 3041 {
34e1169d996ab1 kernel/module.c Kees Cook 2012-10-16 3042 int err;
34e1169d996ab1 kernel/module.c Kees Cook 2012-10-16 3043 struct load_info info = { };
^1da177e4c3f41 kernel/module.c Linus Torvalds 2005-04-16 3044
34e1169d996ab1 kernel/module.c Kees Cook 2012-10-16 3045 err = may_init_module();
34e1169d996ab1 kernel/module.c Kees Cook 2012-10-16 3046 if (err)
34e1169d996ab1 kernel/module.c Kees Cook 2012-10-16 3047 return err;
^1da177e4c3f41 kernel/module.c Linus Torvalds 2005-04-16 3048
34e1169d996ab1 kernel/module.c Kees Cook 2012-10-16 3049 pr_debug("init_module: umod=%p, len=%lu, uargs=%p\n",
34e1169d996ab1 kernel/module.c Kees Cook 2012-10-16 3050 umod, len, uargs);
^1da177e4c3f41 kernel/module.c Linus Torvalds 2005-04-16 3051
34e1169d996ab1 kernel/module.c Kees Cook 2012-10-16 3052 err = copy_module_from_user(umod, len, &info);
df3e764d8e5cd4 kernel/module/main.c Luis Chamberlain 2023-03-28 3053 if (err) {
df3e764d8e5cd4 kernel/module/main.c Luis Chamberlain 2023-03-28 3054 mod_stat_inc(&failed_kreads);
df3e764d8e5cd4 kernel/module/main.c Luis Chamberlain 2023-03-28 3055 mod_stat_add_long(len, &invalid_kread_bytes);
34e1169d996ab1 kernel/module.c Kees Cook 2012-10-16 3056 return err;
df3e764d8e5cd4 kernel/module/main.c Luis Chamberlain 2023-03-28 3057 }
^1da177e4c3f41 kernel/module.c Linus Torvalds 2005-04-16 3058
2f3238aebedb24 kernel/module.c Rusty Russell 2012-10-22 3059 return load_module(&info, uargs, 0);
e24e2e64c468c8 kernel/module.c Alexey Dobriyan 2008-03-10 3060 }
94462ad3b14739 kernel/module.c Steven Rostedt 2010-11-29 3061

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