From b01615d5ac86913da1e092d0378bfb8f0e72af30 Mon Sep 17 00:00:00 2001 From: Richard Yao Date: Thu, 14 Feb 2013 23:37:43 -0500 Subject: Constify structures containing function pointers The PaX team modified the kernel's modpost to report writeable function pointers as section mismatches because they are potential exploit targets. We could ignore the warnings, but their presence can obscure actual issues. Proper const correctness can also catch programming mistakes. Building the kernel modules against a PaX/GrSecurity patched Linux 3.4.2 kernel reports 133 section mismatches prior to this patch. This patch eliminates 130 of them. The quantity of writeable function pointers eliminated by constifying each structure is as follows: vdev_opts_t 52 zil_replay_func_t 24 zio_compress_info_t 24 zio_checksum_info_t 9 space_map_ops_t 7 arc_byteswap_func_t 5 The remaining 3 writeable function pointers cannot be addressed by this patch. 2 of them are in zpl_fs_type. The kernel's sget function requires that this be non-const. The final writeable function pointer is created by SPL_SHRINKER_DECLARE. The kernel's set_shrinker() and remove_shrinker() functions also require that this be non-const. Signed-off-by: Richard Yao Signed-off-by: Brian Behlendorf Closes #1300 --- include/sys/vdev_impl.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include/sys/vdev_impl.h') diff --git a/include/sys/vdev_impl.h b/include/sys/vdev_impl.h index 4133f2cf3..964ee2407 100644 --- a/include/sys/vdev_impl.h +++ b/include/sys/vdev_impl.h @@ -67,7 +67,7 @@ typedef void vdev_state_change_func_t(vdev_t *vd, int, int); typedef void vdev_hold_func_t(vdev_t *vd); typedef void vdev_rele_func_t(vdev_t *vd); -typedef struct vdev_ops { +typedef const struct vdev_ops { vdev_open_func_t *vdev_op_open; vdev_close_func_t *vdev_op_close; vdev_asize_func_t *vdev_op_asize; -- cgit v1.2.3