mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2026-05-22 02:27:36 +03:00
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 <ryao@cs.stonybrook.edu> Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov> Closes #1300
This commit is contained in:
committed by
Brian Behlendorf
parent
c38367c73f
commit
b01615d5ac
+4
-4
@@ -2802,10 +2802,10 @@ arc_read_done(zio_t *zio)
|
||||
if (BP_SHOULD_BYTESWAP(zio->io_bp) && zio->io_error == 0) {
|
||||
dmu_object_byteswap_t bswap =
|
||||
DMU_OT_BYTESWAP(BP_GET_TYPE(zio->io_bp));
|
||||
arc_byteswap_func_t *func = BP_GET_LEVEL(zio->io_bp) > 0 ?
|
||||
byteswap_uint64_array :
|
||||
dmu_ot_byteswap[bswap].ob_func;
|
||||
func(buf->b_data, hdr->b_size);
|
||||
if (BP_GET_LEVEL(zio->io_bp) > 0)
|
||||
byteswap_uint64_array(buf->b_data, hdr->b_size);
|
||||
else
|
||||
dmu_ot_byteswap[bswap].ob_func(buf->b_data, hdr->b_size);
|
||||
}
|
||||
|
||||
arc_cksum_compute(buf, B_FALSE);
|
||||
|
||||
+1
-1
@@ -136,7 +136,7 @@ static int sa_modify_attrs(sa_handle_t *hdl, sa_attr_type_t newattr,
|
||||
sa_data_op_t action, sa_data_locator_t *locator, void *datastart,
|
||||
uint16_t buflen, dmu_tx_t *tx);
|
||||
|
||||
arc_byteswap_func_t *sa_bswap_table[] = {
|
||||
arc_byteswap_func_t sa_bswap_table[] = {
|
||||
byteswap_uint64_array,
|
||||
byteswap_uint32_array,
|
||||
byteswap_uint16_array,
|
||||
|
||||
+22
-22
@@ -910,26 +910,26 @@ zfs_replay_acl(zfs_sb_t *zsb, lr_acl_t *lr, boolean_t byteswap)
|
||||
/*
|
||||
* Callback vectors for replaying records
|
||||
*/
|
||||
zil_replay_func_t *zfs_replay_vector[TX_MAX_TYPE] = {
|
||||
(zil_replay_func_t *)zfs_replay_error, /* no such type */
|
||||
(zil_replay_func_t *)zfs_replay_create, /* TX_CREATE */
|
||||
(zil_replay_func_t *)zfs_replay_create, /* TX_MKDIR */
|
||||
(zil_replay_func_t *)zfs_replay_create, /* TX_MKXATTR */
|
||||
(zil_replay_func_t *)zfs_replay_create, /* TX_SYMLINK */
|
||||
(zil_replay_func_t *)zfs_replay_remove, /* TX_REMOVE */
|
||||
(zil_replay_func_t *)zfs_replay_remove, /* TX_RMDIR */
|
||||
(zil_replay_func_t *)zfs_replay_link, /* TX_LINK */
|
||||
(zil_replay_func_t *)zfs_replay_rename, /* TX_RENAME */
|
||||
(zil_replay_func_t *)zfs_replay_write, /* TX_WRITE */
|
||||
(zil_replay_func_t *)zfs_replay_truncate, /* TX_TRUNCATE */
|
||||
(zil_replay_func_t *)zfs_replay_setattr, /* TX_SETATTR */
|
||||
(zil_replay_func_t *)zfs_replay_acl_v0, /* TX_ACL_V0 */
|
||||
(zil_replay_func_t *)zfs_replay_acl, /* TX_ACL */
|
||||
(zil_replay_func_t *)zfs_replay_create_acl, /* TX_CREATE_ACL */
|
||||
(zil_replay_func_t *)zfs_replay_create, /* TX_CREATE_ATTR */
|
||||
(zil_replay_func_t *)zfs_replay_create_acl, /* TX_CREATE_ACL_ATTR */
|
||||
(zil_replay_func_t *)zfs_replay_create_acl, /* TX_MKDIR_ACL */
|
||||
(zil_replay_func_t *)zfs_replay_create, /* TX_MKDIR_ATTR */
|
||||
(zil_replay_func_t *)zfs_replay_create_acl, /* TX_MKDIR_ACL_ATTR */
|
||||
(zil_replay_func_t *)zfs_replay_write2, /* TX_WRITE2 */
|
||||
zil_replay_func_t zfs_replay_vector[TX_MAX_TYPE] = {
|
||||
(zil_replay_func_t)zfs_replay_error, /* no such type */
|
||||
(zil_replay_func_t)zfs_replay_create, /* TX_CREATE */
|
||||
(zil_replay_func_t)zfs_replay_create, /* TX_MKDIR */
|
||||
(zil_replay_func_t)zfs_replay_create, /* TX_MKXATTR */
|
||||
(zil_replay_func_t)zfs_replay_create, /* TX_SYMLINK */
|
||||
(zil_replay_func_t)zfs_replay_remove, /* TX_REMOVE */
|
||||
(zil_replay_func_t)zfs_replay_remove, /* TX_RMDIR */
|
||||
(zil_replay_func_t)zfs_replay_link, /* TX_LINK */
|
||||
(zil_replay_func_t)zfs_replay_rename, /* TX_RENAME */
|
||||
(zil_replay_func_t)zfs_replay_write, /* TX_WRITE */
|
||||
(zil_replay_func_t)zfs_replay_truncate, /* TX_TRUNCATE */
|
||||
(zil_replay_func_t)zfs_replay_setattr, /* TX_SETATTR */
|
||||
(zil_replay_func_t)zfs_replay_acl_v0, /* TX_ACL_V0 */
|
||||
(zil_replay_func_t)zfs_replay_acl, /* TX_ACL */
|
||||
(zil_replay_func_t)zfs_replay_create_acl, /* TX_CREATE_ACL */
|
||||
(zil_replay_func_t)zfs_replay_create, /* TX_CREATE_ATTR */
|
||||
(zil_replay_func_t)zfs_replay_create_acl, /* TX_CREATE_ACL_ATTR */
|
||||
(zil_replay_func_t)zfs_replay_create_acl, /* TX_MKDIR_ACL */
|
||||
(zil_replay_func_t)zfs_replay_create, /* TX_MKDIR_ATTR */
|
||||
(zil_replay_func_t)zfs_replay_create_acl, /* TX_MKDIR_ACL_ATTR */
|
||||
(zil_replay_func_t)zfs_replay_write2, /* TX_WRITE2 */
|
||||
};
|
||||
|
||||
+2
-2
@@ -1956,7 +1956,7 @@ zil_resume(zilog_t *zilog)
|
||||
}
|
||||
|
||||
typedef struct zil_replay_arg {
|
||||
zil_replay_func_t **zr_replay;
|
||||
zil_replay_func_t *zr_replay;
|
||||
void *zr_arg;
|
||||
boolean_t zr_byteswap;
|
||||
char *zr_lr;
|
||||
@@ -2075,7 +2075,7 @@ zil_incr_blks(zilog_t *zilog, blkptr_t *bp, void *arg, uint64_t claim_txg)
|
||||
* If this dataset has a non-empty intent log, replay it and destroy it.
|
||||
*/
|
||||
void
|
||||
zil_replay(objset_t *os, void *arg, zil_replay_func_t *replay_func[TX_MAX_TYPE])
|
||||
zil_replay(objset_t *os, void *arg, zil_replay_func_t replay_func[TX_MAX_TYPE])
|
||||
{
|
||||
zilog_t *zilog = dmu_objset_zil(os);
|
||||
const zil_header_t *zh = zilog->zl_header;
|
||||
|
||||
+14
-14
@@ -453,20 +453,20 @@ zvol_replay_err(zvol_state_t *zv, lr_t *lr, boolean_t byteswap)
|
||||
* Callback vectors for replaying records.
|
||||
* Only TX_WRITE is needed for zvol.
|
||||
*/
|
||||
zil_replay_func_t *zvol_replay_vector[TX_MAX_TYPE] = {
|
||||
(zil_replay_func_t *)zvol_replay_err, /* no such transaction type */
|
||||
(zil_replay_func_t *)zvol_replay_err, /* TX_CREATE */
|
||||
(zil_replay_func_t *)zvol_replay_err, /* TX_MKDIR */
|
||||
(zil_replay_func_t *)zvol_replay_err, /* TX_MKXATTR */
|
||||
(zil_replay_func_t *)zvol_replay_err, /* TX_SYMLINK */
|
||||
(zil_replay_func_t *)zvol_replay_err, /* TX_REMOVE */
|
||||
(zil_replay_func_t *)zvol_replay_err, /* TX_RMDIR */
|
||||
(zil_replay_func_t *)zvol_replay_err, /* TX_LINK */
|
||||
(zil_replay_func_t *)zvol_replay_err, /* TX_RENAME */
|
||||
(zil_replay_func_t *)zvol_replay_write, /* TX_WRITE */
|
||||
(zil_replay_func_t *)zvol_replay_err, /* TX_TRUNCATE */
|
||||
(zil_replay_func_t *)zvol_replay_err, /* TX_SETATTR */
|
||||
(zil_replay_func_t *)zvol_replay_err, /* TX_ACL */
|
||||
zil_replay_func_t zvol_replay_vector[TX_MAX_TYPE] = {
|
||||
(zil_replay_func_t)zvol_replay_err, /* no such transaction type */
|
||||
(zil_replay_func_t)zvol_replay_err, /* TX_CREATE */
|
||||
(zil_replay_func_t)zvol_replay_err, /* TX_MKDIR */
|
||||
(zil_replay_func_t)zvol_replay_err, /* TX_MKXATTR */
|
||||
(zil_replay_func_t)zvol_replay_err, /* TX_SYMLINK */
|
||||
(zil_replay_func_t)zvol_replay_err, /* TX_REMOVE */
|
||||
(zil_replay_func_t)zvol_replay_err, /* TX_RMDIR */
|
||||
(zil_replay_func_t)zvol_replay_err, /* TX_LINK */
|
||||
(zil_replay_func_t)zvol_replay_err, /* TX_RENAME */
|
||||
(zil_replay_func_t)zvol_replay_write, /* TX_WRITE */
|
||||
(zil_replay_func_t)zvol_replay_err, /* TX_TRUNCATE */
|
||||
(zil_replay_func_t)zvol_replay_err, /* TX_SETATTR */
|
||||
(zil_replay_func_t)zvol_replay_err, /* TX_ACL */
|
||||
};
|
||||
|
||||
/*
|
||||
|
||||
Reference in New Issue
Block a user