From 389ef1b3d413ca533b95f518054631c874510ac2 Mon Sep 17 00:00:00 2001 From: Richard Yao Date: Sat, 8 Oct 2022 21:29:54 -0400 Subject: [PATCH] Linux: Remove ZFS_AC_KERNEL_SRC_MODULE_PARAM_CALL_CONST autotools check On older kernels, the definition for `module_param_call()` typecasts function pointers to `(void *)`, which triggers -Werror, causing the check to return false when it should return true. Fixing this breaks the build process on some older kernels because they define a `__check_old_set_param()` function in their headers that checks for a non-constified `->set()`. We workaround that through the c preprocessor by defining `__check_old_set_param(set)` to `(set)`, which prevents the build failures. However, it is now apparent that all kernels that we support have adopted the GRSecurity change, so there is no need to have an explicit autotools check for it anymore. We therefore remove the autotools check, while adding the workaround to our headers for the build time non-constified `->set()` check done by older kernel headers. Reviewed-by: Brian Behlendorf Reviewed-by: Jorgen Lundman Reviewed-by: Ryan Moeller Reviewed-by: Alexander Motin Signed-off-by: Richard Yao Closes #13984 Closes #14004 --- config/kernel-mod-param.m4 | 33 ---------------------- config/kernel.m4 | 2 -- include/os/linux/kernel/linux/mod_compat.h | 14 +++++---- 3 files changed, 9 insertions(+), 40 deletions(-) delete mode 100644 config/kernel-mod-param.m4 diff --git a/config/kernel-mod-param.m4 b/config/kernel-mod-param.m4 deleted file mode 100644 index e00f19d61e7d..000000000000 --- a/config/kernel-mod-param.m4 +++ /dev/null @@ -1,33 +0,0 @@ -dnl # -dnl # Grsecurity kernel API change -dnl # constified parameters of module_param_call() methods -dnl # -AC_DEFUN([ZFS_AC_KERNEL_SRC_MODULE_PARAM_CALL_CONST], [ - ZFS_LINUX_TEST_SRC([module_param_call], [ - #include - #include - - int param_get(char *b, const struct kernel_param *kp) - { - return (0); - } - - int param_set(const char *b, const struct kernel_param *kp) - { - return (0); - } - - module_param_call(p, param_set, param_get, NULL, 0644); - ],[]) -]) - -AC_DEFUN([ZFS_AC_KERNEL_MODULE_PARAM_CALL_CONST], [ - AC_MSG_CHECKING([whether module_param_call() is hardened]) - ZFS_LINUX_TEST_RESULT([module_param_call], [ - AC_MSG_RESULT(yes) - AC_DEFINE(MODULE_PARAM_CALL_CONST, 1, - [hardened module_param_call]) - ],[ - AC_MSG_RESULT(no) - ]) -]) diff --git a/config/kernel.m4 b/config/kernel.m4 index 6aad2cf88e02..8a5c9296ad7b 100644 --- a/config/kernel.m4 +++ b/config/kernel.m4 @@ -122,7 +122,6 @@ AC_DEFUN([ZFS_AC_KERNEL_TEST_SRC], [ ZFS_AC_KERNEL_SRC_FMODE_T ZFS_AC_KERNEL_SRC_KUIDGID_T ZFS_AC_KERNEL_SRC_KUID_HELPERS - ZFS_AC_KERNEL_SRC_MODULE_PARAM_CALL_CONST ZFS_AC_KERNEL_SRC_RENAME ZFS_AC_KERNEL_SRC_CURRENT_TIME ZFS_AC_KERNEL_SRC_USERNS_CAPABILITIES @@ -243,7 +242,6 @@ AC_DEFUN([ZFS_AC_KERNEL_TEST_RESULT], [ ZFS_AC_KERNEL_FMODE_T ZFS_AC_KERNEL_KUIDGID_T ZFS_AC_KERNEL_KUID_HELPERS - ZFS_AC_KERNEL_MODULE_PARAM_CALL_CONST ZFS_AC_KERNEL_RENAME ZFS_AC_KERNEL_CURRENT_TIME ZFS_AC_KERNEL_USERNS_CAPABILITIES diff --git a/include/os/linux/kernel/linux/mod_compat.h b/include/os/linux/kernel/linux/mod_compat.h index 963cb54e7542..cef27f4cd010 100644 --- a/include/os/linux/kernel/linux/mod_compat.h +++ b/include/os/linux/kernel/linux/mod_compat.h @@ -30,12 +30,16 @@ #include #include -/* Grsecurity kernel API change */ -#ifdef MODULE_PARAM_CALL_CONST +/* + * Despite constifying struct kernel_param_ops, some older kernels define a + * `__check_old_set_param()` function in their headers that checks for a + * non-constified `->set()`. This has long been fixed in Linux mainline, but + * since we support older kernels, we workaround it by using a preprocessor + * definition to disable it. + */ +#define __check_old_set_param(_) (0) + typedef const struct kernel_param zfs_kernel_param_t; -#else -typedef struct kernel_param zfs_kernel_param_t; -#endif #define ZMOD_RW 0644 #define ZMOD_RD 0444