Skip to content

Commit 96ae3d8

Browse files
petrpavlugregkh
authored andcommitted
module: Restore the moduleparam prefix length check
[ Upstream commit bdc877b ] The moduleparam code allows modules to provide their own definition of MODULE_PARAM_PREFIX, instead of using the default KBUILD_MODNAME ".". Commit 730b69d ("module: check kernel param length at compile time, not runtime") added a check to ensure the prefix doesn't exceed MODULE_NAME_LEN, as this is what param_sysfs_builtin() expects. Later, commit 58f86cc ("VERIFY_OCTAL_PERMISSIONS: stricter checking for sysfs perms.") removed this check, but there is no indication this was intentional. Since the check is still useful for param_sysfs_builtin() to function properly, reintroduce it in __module_param_call(), but in a modernized form using static_assert(). While here, clean up the __module_param_call() comments. In particular, remove the comment "Default value instead of permissions?", which comes from commit 9774a1f ("[PATCH] Compile-time check re world-writeable module params"). This comment was related to the test variable __param_perm_check_##name, which was removed in the previously mentioned commit 58f86cc. Fixes: 58f86cc ("VERIFY_OCTAL_PERMISSIONS: stricter checking for sysfs perms.") Signed-off-by: Petr Pavlu <[email protected]> Reviewed-by: Daniel Gomez <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Daniel Gomez <[email protected]> Signed-off-by: Sasha Levin <[email protected]>
1 parent b4e37ee commit 96ae3d8

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

include/linux/moduleparam.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -282,10 +282,9 @@ struct kparam_array
282282
#define __moduleparam_const const
283283
#endif
284284

285-
/* This is the fundamental function for registering boot/module
286-
parameters. */
285+
/* This is the fundamental function for registering boot/module parameters. */
287286
#define __module_param_call(prefix, name, ops, arg, perm, level, flags) \
288-
/* Default value instead of permissions? */ \
287+
static_assert(sizeof(""prefix) - 1 <= MAX_PARAM_PREFIX_LEN); \
289288
static const char __param_str_##name[] = prefix #name; \
290289
static struct kernel_param __moduleparam_const __param_##name \
291290
__used __section("__param") \

0 commit comments

Comments
 (0)