Skip to content

Commit

Permalink
icp: add no_const for PaX Compat
Browse files Browse the repository at this point in the history
The constify plugin will automatically constify a class of types that contain
only function pointers. The icp structs fail to build if this is enabled with
the following error. The no_const attribute makes the plugin skip those
structs.

module/icp/spi/kcf_spi.c: In function ‘copy_ops_vector_v1’:
module/icp/spi/kcf_spi.c:61:16: error: assignment of read-only location ‘*dst_ops->cou.cou_v1.co_control_ops’
  *((dst)->ops) = *((src)->ops);
                ^
module/icp/spi/kcf_spi.c:74:2: note: in expansion of macro ‘KCF_SPI_COPY_OPS’
  KCF_SPI_COPY_OPS(src_ops, dst_ops, co_control_ops);
  ^

Signed-off-by: Jason Zaman <[email protected]>
Signed-off-by: Brian Behlendorf <[email protected]>
Closes openzfs#4947
Closes openzfs#4962
  • Loading branch information
perfinion authored and behlendorf committed Aug 12, 2016
1 parent 6eb73b0 commit a9947ce
Showing 1 changed file with 21 additions and 16 deletions.
37 changes: 21 additions & 16 deletions module/icp/include/sys/crypto/spi.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@
extern "C" {
#endif

#ifdef CONSTIFY_PLUGIN
#define __no_const __attribute__((no_const))
#else
#define __no_const
#endif /* CONSTIFY_PLUGIN */

#define CRYPTO_SPI_VERSION_1 1
#define CRYPTO_SPI_VERSION_2 2
Expand Down Expand Up @@ -122,7 +127,7 @@ typedef struct crypto_ctx {
*/
typedef struct crypto_control_ops {
void (*provider_status)(crypto_provider_handle_t, uint_t *);
} crypto_control_ops_t;
} __no_const crypto_control_ops_t;

/*
* The crypto_ctx_ops structure contains points to context and context
Expand All @@ -135,7 +140,7 @@ typedef struct crypto_ctx_ops {
crypto_mechanism_t *, crypto_key_t *,
crypto_spi_ctx_template_t *, size_t *, crypto_req_handle_t);
int (*free_context)(crypto_ctx_t *);
} crypto_ctx_ops_t;
} __no_const crypto_ctx_ops_t;

/*
* The crypto_digest_ops structure contains pointers to digest
Expand All @@ -156,7 +161,7 @@ typedef struct crypto_digest_ops {
int (*digest_atomic)(crypto_provider_handle_t, crypto_session_id_t,
crypto_mechanism_t *, crypto_data_t *,
crypto_data_t *, crypto_req_handle_t);
} crypto_digest_ops_t;
} __no_const crypto_digest_ops_t;

/*
* The crypto_cipher_ops structure contains pointers to encryption
Expand Down Expand Up @@ -190,7 +195,7 @@ typedef struct crypto_cipher_ops {
int (*decrypt_atomic)(crypto_provider_handle_t, crypto_session_id_t,
crypto_mechanism_t *, crypto_key_t *, crypto_data_t *,
crypto_data_t *, crypto_spi_ctx_template_t, crypto_req_handle_t);
} crypto_cipher_ops_t;
} __no_const crypto_cipher_ops_t;

/*
* The crypto_mac_ops structure contains pointers to MAC
Expand All @@ -216,7 +221,7 @@ typedef struct crypto_mac_ops {
crypto_mechanism_t *, crypto_key_t *, crypto_data_t *,
crypto_data_t *, crypto_spi_ctx_template_t,
crypto_req_handle_t);
} crypto_mac_ops_t;
} __no_const crypto_mac_ops_t;

/*
* The crypto_sign_ops structure contains pointers to signing
Expand Down Expand Up @@ -247,7 +252,7 @@ typedef struct crypto_sign_ops {
crypto_session_id_t, crypto_mechanism_t *, crypto_key_t *,
crypto_data_t *, crypto_data_t *, crypto_spi_ctx_template_t,
crypto_req_handle_t);
} crypto_sign_ops_t;
} __no_const crypto_sign_ops_t;

/*
* The crypto_verify_ops structure contains pointers to verify
Expand Down Expand Up @@ -278,7 +283,7 @@ typedef struct crypto_verify_ops {
crypto_session_id_t, crypto_mechanism_t *, crypto_key_t *,
crypto_data_t *, crypto_data_t *, crypto_spi_ctx_template_t,
crypto_req_handle_t);
} crypto_verify_ops_t;
} __no_const crypto_verify_ops_t;

/*
* The crypto_dual_ops structure contains pointers to dual
Expand All @@ -300,7 +305,7 @@ typedef struct crypto_dual_ops {
int (*decrypt_verify_update)(
crypto_ctx_t *, crypto_ctx_t *, crypto_data_t *,
crypto_data_t *, crypto_req_handle_t);
} crypto_dual_ops_t;
} __no_const crypto_dual_ops_t;

/*
* The crypto_dual_cipher_mac_ops structure contains pointers to dual
Expand Down Expand Up @@ -348,7 +353,7 @@ typedef struct crypto_dual_cipher_mac_ops {
crypto_mechanism_t *, crypto_key_t *, crypto_dual_data_t *,
crypto_data_t *, crypto_data_t *, crypto_spi_ctx_template_t,
crypto_spi_ctx_template_t, crypto_req_handle_t);
} crypto_dual_cipher_mac_ops_t;
} __no_const crypto_dual_cipher_mac_ops_t;

/*
* The crypto_random_number_ops structure contains pointers to random
Expand All @@ -361,7 +366,7 @@ typedef struct crypto_random_number_ops {
uchar_t *, size_t, uint_t, uint32_t, crypto_req_handle_t);
int (*generate_random)(crypto_provider_handle_t, crypto_session_id_t,
uchar_t *, size_t, crypto_req_handle_t);
} crypto_random_number_ops_t;
} __no_const crypto_random_number_ops_t;

/*
* Flag values for seed_random.
Expand All @@ -383,7 +388,7 @@ typedef struct crypto_session_ops {
crypto_user_type_t, char *, size_t, crypto_req_handle_t);
int (*session_logout)(crypto_provider_handle_t, crypto_session_id_t,
crypto_req_handle_t);
} crypto_session_ops_t;
} __no_const crypto_session_ops_t;

/*
* The crypto_object_ops structure contains pointers to object
Expand Down Expand Up @@ -415,7 +420,7 @@ typedef struct crypto_object_ops {
crypto_object_id_t *, uint_t, uint_t *, crypto_req_handle_t);
int (*object_find_final)(crypto_provider_handle_t, void *,
crypto_req_handle_t);
} crypto_object_ops_t;
} __no_const crypto_object_ops_t;

/*
* The crypto_key_ops structure contains pointers to key
Expand Down Expand Up @@ -443,7 +448,7 @@ typedef struct crypto_key_ops {
uint_t, crypto_object_id_t *, crypto_req_handle_t);
int (*key_check)(crypto_provider_handle_t, crypto_mechanism_t *,
crypto_key_t *);
} crypto_key_ops_t;
} __no_const crypto_key_ops_t;

/*
* The crypto_provider_management_ops structure contains pointers
Expand All @@ -460,15 +465,15 @@ typedef struct crypto_provider_management_ops {
char *, size_t, crypto_req_handle_t);
int (*set_pin)(crypto_provider_handle_t, crypto_session_id_t,
char *, size_t, char *, size_t, crypto_req_handle_t);
} crypto_provider_management_ops_t;
} __no_const crypto_provider_management_ops_t;

typedef struct crypto_mech_ops {
int (*copyin_mechanism)(crypto_provider_handle_t,
crypto_mechanism_t *, crypto_mechanism_t *, int *, int);
int (*copyout_mechanism)(crypto_provider_handle_t,
crypto_mechanism_t *, crypto_mechanism_t *, int *, int);
int (*free_mechanism)(crypto_provider_handle_t, crypto_mechanism_t *);
} crypto_mech_ops_t;
} __no_const crypto_mech_ops_t;

typedef struct crypto_nostore_key_ops {
int (*nostore_key_generate)(crypto_provider_handle_t,
Expand All @@ -483,7 +488,7 @@ typedef struct crypto_nostore_key_ops {
int (*nostore_key_derive)(crypto_provider_handle_t, crypto_session_id_t,
crypto_mechanism_t *, crypto_key_t *, crypto_object_attribute_t *,
uint_t, crypto_object_attribute_t *, uint_t, crypto_req_handle_t);
} crypto_nostore_key_ops_t;
} __no_const crypto_nostore_key_ops_t;

/*
* The crypto_ops(9S) structure contains the structures containing
Expand Down

0 comments on commit a9947ce

Please sign in to comment.