Commit 74ecbef7 authored by Harald Freudenberger's avatar Harald Freudenberger Committed by Heiko Carstens

s390/zcrypt: code beautification and struct field renames

Some beautifications related to the internal only used
struct ap_message and related code. Instead of one int carrying
only the special flag now a u32 flags field is used.

At struct CPRBX the pointers to additional data are now marked
with __user. This caused some changes needed on code, where
these structs are also used within the zcrypt misc functions.

The ica_rsa_* structs now use the generic types __u8, __u32, ...
instead of char, unsigned int.

zcrypt_msg6 and zcrypt_msg50 use min_t() instead of min().
Signed-off-by: default avatarHarald Freudenberger <freude@linux.ibm.com>
Signed-off-by: default avatarHeiko Carstens <heiko.carstens@de.ibm.com>
parent 47c07bff
...@@ -36,12 +36,12 @@ ...@@ -36,12 +36,12 @@
* - length(n_modulus) = inputdatalength * - length(n_modulus) = inputdatalength
*/ */
struct ica_rsa_modexpo { struct ica_rsa_modexpo {
char __user *inputdata; __u8 __user *inputdata;
unsigned int inputdatalength; __u32 inputdatalength;
char __user *outputdata; __u8 __user *outputdata;
unsigned int outputdatalength; __u32 outputdatalength;
char __user *b_key; __u8 __user *b_key;
char __user *n_modulus; __u8 __user *n_modulus;
}; };
/** /**
...@@ -59,15 +59,15 @@ struct ica_rsa_modexpo { ...@@ -59,15 +59,15 @@ struct ica_rsa_modexpo {
* - length(u_mult_inv) = inputdatalength/2 + 8 * - length(u_mult_inv) = inputdatalength/2 + 8
*/ */
struct ica_rsa_modexpo_crt { struct ica_rsa_modexpo_crt {
char __user *inputdata; __u8 __user *inputdata;
unsigned int inputdatalength; __u32 inputdatalength;
char __user *outputdata; __u8 __user *outputdata;
unsigned int outputdatalength; __u32 outputdatalength;
char __user *bp_key; __u8 __user *bp_key;
char __user *bq_key; __u8 __user *bq_key;
char __user *np_prime; __u8 __user *np_prime;
char __user *nq_prime; __u8 __user *nq_prime;
char __user *u_mult_inv; __u8 __user *u_mult_inv;
}; };
/** /**
...@@ -83,67 +83,67 @@ struct ica_rsa_modexpo_crt { ...@@ -83,67 +83,67 @@ struct ica_rsa_modexpo_crt {
* key block * key block
*/ */
struct CPRBX { struct CPRBX {
unsigned short cprb_len; /* CPRB length 220 */ __u16 cprb_len; /* CPRB length 220 */
unsigned char cprb_ver_id; /* CPRB version id. 0x02 */ __u8 cprb_ver_id; /* CPRB version id. 0x02 */
unsigned char pad_000[3]; /* Alignment pad bytes */ __u8 pad_000[3]; /* Alignment pad bytes */
unsigned char func_id[2]; /* function id 0x5432 */ __u8 func_id[2]; /* function id 0x5432 */
unsigned char cprb_flags[4]; /* Flags */ __u8 cprb_flags[4]; /* Flags */
unsigned int req_parml; /* request parameter buffer len */ __u32 req_parml; /* request parameter buffer len */
unsigned int req_datal; /* request data buffer */ __u32 req_datal; /* request data buffer */
unsigned int rpl_msgbl; /* reply message block length */ __u32 rpl_msgbl; /* reply message block length */
unsigned int rpld_parml; /* replied parameter block len */ __u32 rpld_parml; /* replied parameter block len */
unsigned int rpl_datal; /* reply data block len */ __u32 rpl_datal; /* reply data block len */
unsigned int rpld_datal; /* replied data block len */ __u32 rpld_datal; /* replied data block len */
unsigned int req_extbl; /* request extension block len */ __u32 req_extbl; /* request extension block len */
unsigned char pad_001[4]; /* reserved */ __u8 pad_001[4]; /* reserved */
unsigned int rpld_extbl; /* replied extension block len */ __u32 rpld_extbl; /* replied extension block len */
unsigned char padx000[16 - sizeof(char *)]; __u8 padx000[16 - sizeof(__u8 *)];
unsigned char *req_parmb; /* request parm block 'address' */ __u8 __user *req_parmb; /* request parm block 'address' */
unsigned char padx001[16 - sizeof(char *)]; __u8 padx001[16 - sizeof(__u8 *)];
unsigned char *req_datab; /* request data block 'address' */ __u8 __user *req_datab; /* request data block 'address' */
unsigned char padx002[16 - sizeof(char *)]; __u8 padx002[16 - sizeof(__u8 *)];
unsigned char *rpl_parmb; /* reply parm block 'address' */ __u8 __user *rpl_parmb; /* reply parm block 'address' */
unsigned char padx003[16 - sizeof(char *)]; __u8 padx003[16 - sizeof(__u8 *)];
unsigned char *rpl_datab; /* reply data block 'address' */ __u8 __user *rpl_datab; /* reply data block 'address' */
unsigned char padx004[16 - sizeof(char *)]; __u8 padx004[16 - sizeof(__u8 *)];
unsigned char *req_extb; /* request extension block 'addr'*/ __u8 __user *req_extb; /* request extension block 'addr'*/
unsigned char padx005[16 - sizeof(char *)]; __u8 padx005[16 - sizeof(__u8 *)];
unsigned char *rpl_extb; /* reply extension block 'address'*/ __u8 __user *rpl_extb; /* reply extension block 'address'*/
unsigned short ccp_rtcode; /* server return code */ __u16 ccp_rtcode; /* server return code */
unsigned short ccp_rscode; /* server reason code */ __u16 ccp_rscode; /* server reason code */
unsigned int mac_data_len; /* Mac Data Length */ __u32 mac_data_len; /* Mac Data Length */
unsigned char logon_id[8]; /* Logon Identifier */ __u8 logon_id[8]; /* Logon Identifier */
unsigned char mac_value[8]; /* Mac Value */ __u8 mac_value[8]; /* Mac Value */
unsigned char mac_content_flgs;/* Mac content flag byte */ __u8 mac_content_flgs; /* Mac content flag byte */
unsigned char pad_002; /* Alignment */ __u8 pad_002; /* Alignment */
unsigned short domain; /* Domain */ __u16 domain; /* Domain */
unsigned char usage_domain[4];/* Usage domain */ __u8 usage_domain[4]; /* Usage domain */
unsigned char cntrl_domain[4];/* Control domain */ __u8 cntrl_domain[4]; /* Control domain */
unsigned char S390enf_mask[4];/* S/390 enforcement mask */ __u8 S390enf_mask[4]; /* S/390 enforcement mask */
unsigned char pad_004[36]; /* reserved */ __u8 pad_004[36]; /* reserved */
} __attribute__((packed)); } __attribute__((packed));
/** /**
* xcRB * xcRB
*/ */
struct ica_xcRB { struct ica_xcRB {
unsigned short agent_ID; __u16 agent_ID;
unsigned int user_defined; __u32 user_defined;
unsigned short request_ID; __u16 request_ID;
unsigned int request_control_blk_length; __u32 request_control_blk_length;
unsigned char padding1[16 - sizeof(char *)]; __u8 _padding1[16 - sizeof(__u8 *)];
char __user *request_control_blk_addr; __u8 __user *request_control_blk_addr;
unsigned int request_data_length; __u32 request_data_length;
char padding2[16 - sizeof(char *)]; __u8 _padding2[16 - sizeof(__u8 *)];
char __user *request_data_address; __u8 __user *request_data_address;
unsigned int reply_control_blk_length; __u32 reply_control_blk_length;
char padding3[16 - sizeof(char *)]; __u8 _padding3[16 - sizeof(__u8 *)];
char __user *reply_control_blk_addr; __u8 __user *reply_control_blk_addr;
unsigned int reply_data_length; __u32 reply_data_length;
char padding4[16 - sizeof(char *)]; __u8 __padding4[16 - sizeof(__u8 *)];
char __user *reply_data_addr; __u8 __user *reply_data_addr;
unsigned short priority_window; __u16 priority_window;
unsigned int status; __u32 status;
} __attribute__((packed)); } __attribute__((packed));
/** /**
......
...@@ -190,17 +190,18 @@ typedef enum ap_wait (ap_func_t)(struct ap_queue *queue); ...@@ -190,17 +190,18 @@ typedef enum ap_wait (ap_func_t)(struct ap_queue *queue);
struct ap_message { struct ap_message {
struct list_head list; /* Request queueing. */ struct list_head list; /* Request queueing. */
unsigned long long psmid; /* Message id. */ unsigned long long psmid; /* Message id. */
void *message; /* Pointer to message buffer. */ void *msg; /* Pointer to message buffer. */
size_t length; /* Message length. */ unsigned int len; /* Message length. */
u32 flags; /* Flags, see AP_MSG_FLAG_xxx */
int rc; /* Return code for this message */ int rc; /* Return code for this message */
void *private; /* ap driver private pointer. */ void *private; /* ap driver private pointer. */
unsigned int special:1; /* Used for special commands. */
/* receive is called from tasklet context */ /* receive is called from tasklet context */
void (*receive)(struct ap_queue *, struct ap_message *, void (*receive)(struct ap_queue *, struct ap_message *,
struct ap_message *); struct ap_message *);
}; };
#define AP_MSG_FLAG_SPECIAL (1 << 16) /* flag msg as 'special' with NQAP */
/** /**
* ap_init_message() - Initialize ap_message. * ap_init_message() - Initialize ap_message.
* Initialize a message before using. Otherwise this might result in * Initialize a message before using. Otherwise this might result in
...@@ -218,7 +219,7 @@ static inline void ap_init_message(struct ap_message *ap_msg) ...@@ -218,7 +219,7 @@ static inline void ap_init_message(struct ap_message *ap_msg)
*/ */
static inline void ap_release_message(struct ap_message *ap_msg) static inline void ap_release_message(struct ap_message *ap_msg)
{ {
kzfree(ap_msg->message); kzfree(ap_msg->msg);
kzfree(ap_msg->private); kzfree(ap_msg->private);
} }
......
...@@ -69,9 +69,9 @@ static int ap_queue_enable_interruption(struct ap_queue *aq, void *ind) ...@@ -69,9 +69,9 @@ static int ap_queue_enable_interruption(struct ap_queue *aq, void *ind)
*/ */
static inline struct ap_queue_status static inline struct ap_queue_status
__ap_send(ap_qid_t qid, unsigned long long psmid, void *msg, size_t length, __ap_send(ap_qid_t qid, unsigned long long psmid, void *msg, size_t length,
unsigned int special) int special)
{ {
if (special == 1) if (special)
qid |= 0x400000UL; qid |= 0x400000UL;
return ap_nqap(qid, psmid, msg, length); return ap_nqap(qid, psmid, msg, length);
} }
...@@ -137,7 +137,7 @@ static struct ap_queue_status ap_sm_recv(struct ap_queue *aq) ...@@ -137,7 +137,7 @@ static struct ap_queue_status ap_sm_recv(struct ap_queue *aq)
struct ap_message *ap_msg; struct ap_message *ap_msg;
status = ap_dqap(aq->qid, &aq->reply->psmid, status = ap_dqap(aq->qid, &aq->reply->psmid,
aq->reply->message, aq->reply->length); aq->reply->msg, aq->reply->len);
switch (status.response_code) { switch (status.response_code) {
case AP_RESPONSE_NORMAL: case AP_RESPONSE_NORMAL:
aq->queue_count--; aq->queue_count--;
...@@ -216,7 +216,8 @@ static enum ap_wait ap_sm_write(struct ap_queue *aq) ...@@ -216,7 +216,8 @@ static enum ap_wait ap_sm_write(struct ap_queue *aq)
/* Start the next request on the queue. */ /* Start the next request on the queue. */
ap_msg = list_entry(aq->requestq.next, struct ap_message, list); ap_msg = list_entry(aq->requestq.next, struct ap_message, list);
status = __ap_send(aq->qid, ap_msg->psmid, status = __ap_send(aq->qid, ap_msg->psmid,
ap_msg->message, ap_msg->length, ap_msg->special); ap_msg->msg, ap_msg->len,
ap_msg->flags & AP_MSG_FLAG_SPECIAL);
switch (status.response_code) { switch (status.response_code) {
case AP_RESPONSE_NORMAL: case AP_RESPONSE_NORMAL:
aq->queue_count++; aq->queue_count++;
......
...@@ -205,9 +205,9 @@ static int alloc_and_prep_cprbmem(size_t paramblen, ...@@ -205,9 +205,9 @@ static int alloc_and_prep_cprbmem(size_t paramblen,
preqcblk->rpl_msgbl = cprbplusparamblen; preqcblk->rpl_msgbl = cprbplusparamblen;
if (paramblen) { if (paramblen) {
preqcblk->req_parmb = preqcblk->req_parmb =
((u8 *) preqcblk) + sizeof(struct CPRBX); ((u8 __user *) preqcblk) + sizeof(struct CPRBX);
preqcblk->rpl_parmb = preqcblk->rpl_parmb =
((u8 *) prepcblk) + sizeof(struct CPRBX); ((u8 __user *) prepcblk) + sizeof(struct CPRBX);
} }
*pcprbmem = cprbmem; *pcprbmem = cprbmem;
...@@ -274,7 +274,7 @@ int cca_genseckey(u16 cardnr, u16 domain, ...@@ -274,7 +274,7 @@ int cca_genseckey(u16 cardnr, u16 domain,
{ {
int i, rc, keysize; int i, rc, keysize;
int seckeysize; int seckeysize;
u8 *mem; u8 *mem, *ptr;
struct CPRBX *preqcblk, *prepcblk; struct CPRBX *preqcblk, *prepcblk;
struct ica_xcRB xcrb; struct ica_xcRB xcrb;
struct kgreqparm { struct kgreqparm {
...@@ -320,7 +320,7 @@ int cca_genseckey(u16 cardnr, u16 domain, ...@@ -320,7 +320,7 @@ int cca_genseckey(u16 cardnr, u16 domain,
preqcblk->domain = domain; preqcblk->domain = domain;
/* fill request cprb param block with KG request */ /* fill request cprb param block with KG request */
preqparm = (struct kgreqparm *) preqcblk->req_parmb; preqparm = (struct kgreqparm __force *) preqcblk->req_parmb;
memcpy(preqparm->subfunc_code, "KG", 2); memcpy(preqparm->subfunc_code, "KG", 2);
preqparm->rule_array_len = sizeof(preqparm->rule_array_len); preqparm->rule_array_len = sizeof(preqparm->rule_array_len);
preqparm->lv1.len = sizeof(struct lv1); preqparm->lv1.len = sizeof(struct lv1);
...@@ -377,8 +377,9 @@ int cca_genseckey(u16 cardnr, u16 domain, ...@@ -377,8 +377,9 @@ int cca_genseckey(u16 cardnr, u16 domain,
} }
/* process response cprb param block */ /* process response cprb param block */
prepcblk->rpl_parmb = ((u8 *) prepcblk) + sizeof(struct CPRBX); ptr = ((u8 *) prepcblk) + sizeof(struct CPRBX);
prepparm = (struct kgrepparm *) prepcblk->rpl_parmb; prepcblk->rpl_parmb = (u8 __user *) ptr;
prepparm = (struct kgrepparm *) ptr;
/* check length of the returned secure key token */ /* check length of the returned secure key token */
seckeysize = prepparm->lv3.keyblock.toklen seckeysize = prepparm->lv3.keyblock.toklen
...@@ -415,7 +416,7 @@ int cca_clr2seckey(u16 cardnr, u16 domain, u32 keybitsize, ...@@ -415,7 +416,7 @@ int cca_clr2seckey(u16 cardnr, u16 domain, u32 keybitsize,
const u8 *clrkey, u8 seckey[SECKEYBLOBSIZE]) const u8 *clrkey, u8 seckey[SECKEYBLOBSIZE])
{ {
int rc, keysize, seckeysize; int rc, keysize, seckeysize;
u8 *mem; u8 *mem, *ptr;
struct CPRBX *preqcblk, *prepcblk; struct CPRBX *preqcblk, *prepcblk;
struct ica_xcRB xcrb; struct ica_xcRB xcrb;
struct cmreqparm { struct cmreqparm {
...@@ -460,7 +461,7 @@ int cca_clr2seckey(u16 cardnr, u16 domain, u32 keybitsize, ...@@ -460,7 +461,7 @@ int cca_clr2seckey(u16 cardnr, u16 domain, u32 keybitsize,
preqcblk->domain = domain; preqcblk->domain = domain;
/* fill request cprb param block with CM request */ /* fill request cprb param block with CM request */
preqparm = (struct cmreqparm *) preqcblk->req_parmb; preqparm = (struct cmreqparm __force *) preqcblk->req_parmb;
memcpy(preqparm->subfunc_code, "CM", 2); memcpy(preqparm->subfunc_code, "CM", 2);
memcpy(preqparm->rule_array, "AES ", 8); memcpy(preqparm->rule_array, "AES ", 8);
preqparm->rule_array_len = preqparm->rule_array_len =
...@@ -514,8 +515,9 @@ int cca_clr2seckey(u16 cardnr, u16 domain, u32 keybitsize, ...@@ -514,8 +515,9 @@ int cca_clr2seckey(u16 cardnr, u16 domain, u32 keybitsize,
} }
/* process response cprb param block */ /* process response cprb param block */
prepcblk->rpl_parmb = ((u8 *) prepcblk) + sizeof(struct CPRBX); ptr = ((u8 *) prepcblk) + sizeof(struct CPRBX);
prepparm = (struct cmrepparm *) prepcblk->rpl_parmb; prepcblk->rpl_parmb = (u8 __user *) ptr;
prepparm = (struct cmrepparm *) ptr;
/* check length of the returned secure key token */ /* check length of the returned secure key token */
seckeysize = prepparm->lv3.keyblock.toklen seckeysize = prepparm->lv3.keyblock.toklen
...@@ -554,7 +556,7 @@ int cca_sec2protkey(u16 cardnr, u16 domain, ...@@ -554,7 +556,7 @@ int cca_sec2protkey(u16 cardnr, u16 domain,
u8 *protkey, u32 *protkeylen, u32 *protkeytype) u8 *protkey, u32 *protkeylen, u32 *protkeytype)
{ {
int rc; int rc;
u8 *mem; u8 *mem, *ptr;
struct CPRBX *preqcblk, *prepcblk; struct CPRBX *preqcblk, *prepcblk;
struct ica_xcRB xcrb; struct ica_xcRB xcrb;
struct uskreqparm { struct uskreqparm {
...@@ -605,7 +607,7 @@ int cca_sec2protkey(u16 cardnr, u16 domain, ...@@ -605,7 +607,7 @@ int cca_sec2protkey(u16 cardnr, u16 domain,
preqcblk->domain = domain; preqcblk->domain = domain;
/* fill request cprb param block with USK request */ /* fill request cprb param block with USK request */
preqparm = (struct uskreqparm *) preqcblk->req_parmb; preqparm = (struct uskreqparm __force *) preqcblk->req_parmb;
memcpy(preqparm->subfunc_code, "US", 2); memcpy(preqparm->subfunc_code, "US", 2);
preqparm->rule_array_len = sizeof(preqparm->rule_array_len); preqparm->rule_array_len = sizeof(preqparm->rule_array_len);
preqparm->lv1.len = sizeof(struct lv1); preqparm->lv1.len = sizeof(struct lv1);
...@@ -646,8 +648,9 @@ int cca_sec2protkey(u16 cardnr, u16 domain, ...@@ -646,8 +648,9 @@ int cca_sec2protkey(u16 cardnr, u16 domain,
} }
/* process response cprb param block */ /* process response cprb param block */
prepcblk->rpl_parmb = ((u8 *) prepcblk) + sizeof(struct CPRBX); ptr = ((u8 *) prepcblk) + sizeof(struct CPRBX);
prepparm = (struct uskrepparm *) prepcblk->rpl_parmb; prepcblk->rpl_parmb = (u8 __user *) ptr;
prepparm = (struct uskrepparm *) ptr;
/* check the returned keyblock */ /* check the returned keyblock */
if (prepparm->lv3.ckb.version != 0x01 && if (prepparm->lv3.ckb.version != 0x01 &&
...@@ -714,7 +717,7 @@ int cca_gencipherkey(u16 cardnr, u16 domain, u32 keybitsize, u32 keygenflags, ...@@ -714,7 +717,7 @@ int cca_gencipherkey(u16 cardnr, u16 domain, u32 keybitsize, u32 keygenflags,
u8 *keybuf, size_t *keybufsize) u8 *keybuf, size_t *keybufsize)
{ {
int rc; int rc;
u8 *mem; u8 *mem, *ptr;
struct CPRBX *preqcblk, *prepcblk; struct CPRBX *preqcblk, *prepcblk;
struct ica_xcRB xcrb; struct ica_xcRB xcrb;
struct gkreqparm { struct gkreqparm {
...@@ -796,7 +799,7 @@ int cca_gencipherkey(u16 cardnr, u16 domain, u32 keybitsize, u32 keygenflags, ...@@ -796,7 +799,7 @@ int cca_gencipherkey(u16 cardnr, u16 domain, u32 keybitsize, u32 keygenflags,
preqcblk->req_parml = sizeof(struct gkreqparm); preqcblk->req_parml = sizeof(struct gkreqparm);
/* prepare request param block with GK request */ /* prepare request param block with GK request */
preqparm = (struct gkreqparm *) preqcblk->req_parmb; preqparm = (struct gkreqparm __force *) preqcblk->req_parmb;
memcpy(preqparm->subfunc_code, "GK", 2); memcpy(preqparm->subfunc_code, "GK", 2);
preqparm->rule_array_len = sizeof(uint16_t) + 2 * 8; preqparm->rule_array_len = sizeof(uint16_t) + 2 * 8;
memcpy(preqparm->rule_array, "AES OP ", 2*8); memcpy(preqparm->rule_array, "AES OP ", 2*8);
...@@ -867,8 +870,9 @@ int cca_gencipherkey(u16 cardnr, u16 domain, u32 keybitsize, u32 keygenflags, ...@@ -867,8 +870,9 @@ int cca_gencipherkey(u16 cardnr, u16 domain, u32 keybitsize, u32 keygenflags,
} }
/* process response cprb param block */ /* process response cprb param block */
prepcblk->rpl_parmb = ((u8 *) prepcblk) + sizeof(struct CPRBX); ptr = ((u8 *) prepcblk) + sizeof(struct CPRBX);
prepparm = (struct gkrepparm *) prepcblk->rpl_parmb; prepcblk->rpl_parmb = (u8 __user *) ptr;
prepparm = (struct gkrepparm *) ptr;
/* do some plausibility checks on the key block */ /* do some plausibility checks on the key block */
if (prepparm->kb.len < 120 + 5 * sizeof(uint16_t) || if (prepparm->kb.len < 120 + 5 * sizeof(uint16_t) ||
...@@ -917,7 +921,7 @@ static int _ip_cprb_helper(u16 cardnr, u16 domain, ...@@ -917,7 +921,7 @@ static int _ip_cprb_helper(u16 cardnr, u16 domain,
int *key_token_size) int *key_token_size)
{ {
int rc, n; int rc, n;
u8 *mem; u8 *mem, *ptr;
struct CPRBX *preqcblk, *prepcblk; struct CPRBX *preqcblk, *prepcblk;
struct ica_xcRB xcrb; struct ica_xcRB xcrb;
struct rule_array_block { struct rule_array_block {
...@@ -974,7 +978,7 @@ static int _ip_cprb_helper(u16 cardnr, u16 domain, ...@@ -974,7 +978,7 @@ static int _ip_cprb_helper(u16 cardnr, u16 domain,
preqcblk->req_parml = 0; preqcblk->req_parml = 0;
/* prepare request param block with IP request */ /* prepare request param block with IP request */
preq_ra_block = (struct rule_array_block *) preqcblk->req_parmb; preq_ra_block = (struct rule_array_block __force *) preqcblk->req_parmb;
memcpy(preq_ra_block->subfunc_code, "IP", 2); memcpy(preq_ra_block->subfunc_code, "IP", 2);
preq_ra_block->rule_array_len = sizeof(uint16_t) + 2 * 8; preq_ra_block->rule_array_len = sizeof(uint16_t) + 2 * 8;
memcpy(preq_ra_block->rule_array, rule_array_1, 8); memcpy(preq_ra_block->rule_array, rule_array_1, 8);
...@@ -987,7 +991,7 @@ static int _ip_cprb_helper(u16 cardnr, u16 domain, ...@@ -987,7 +991,7 @@ static int _ip_cprb_helper(u16 cardnr, u16 domain,
} }
/* prepare vud block */ /* prepare vud block */
preq_vud_block = (struct vud_block *) preq_vud_block = (struct vud_block __force *)
(preqcblk->req_parmb + preqcblk->req_parml); (preqcblk->req_parmb + preqcblk->req_parml);
n = complete ? 0 : (clr_key_bit_size + 7) / 8; n = complete ? 0 : (clr_key_bit_size + 7) / 8;
preq_vud_block->len = sizeof(struct vud_block) + n; preq_vud_block->len = sizeof(struct vud_block) + n;
...@@ -1001,7 +1005,7 @@ static int _ip_cprb_helper(u16 cardnr, u16 domain, ...@@ -1001,7 +1005,7 @@ static int _ip_cprb_helper(u16 cardnr, u16 domain,
preqcblk->req_parml += preq_vud_block->len; preqcblk->req_parml += preq_vud_block->len;
/* prepare key block */ /* prepare key block */
preq_key_block = (struct key_block *) preq_key_block = (struct key_block __force *)
(preqcblk->req_parmb + preqcblk->req_parml); (preqcblk->req_parmb + preqcblk->req_parml);
n = *key_token_size; n = *key_token_size;
preq_key_block->len = sizeof(struct key_block) + n; preq_key_block->len = sizeof(struct key_block) + n;
...@@ -1034,8 +1038,9 @@ static int _ip_cprb_helper(u16 cardnr, u16 domain, ...@@ -1034,8 +1038,9 @@ static int _ip_cprb_helper(u16 cardnr, u16 domain,
} }
/* process response cprb param block */ /* process response cprb param block */
prepcblk->rpl_parmb = ((u8 *) prepcblk) + sizeof(struct CPRBX); ptr = ((u8 *) prepcblk) + sizeof(struct CPRBX);
prepparm = (struct iprepparm *) prepcblk->rpl_parmb; prepcblk->rpl_parmb = (u8 __user *) ptr;
prepparm = (struct iprepparm *) ptr;
/* do some plausibility checks on the key block */ /* do some plausibility checks on the key block */
if (prepparm->kb.len < 120 + 3 * sizeof(uint16_t) || if (prepparm->kb.len < 120 + 3 * sizeof(uint16_t) ||
...@@ -1151,7 +1156,7 @@ int cca_cipher2protkey(u16 cardnr, u16 domain, const u8 *ckey, ...@@ -1151,7 +1156,7 @@ int cca_cipher2protkey(u16 cardnr, u16 domain, const u8 *ckey,
u8 *protkey, u32 *protkeylen, u32 *protkeytype) u8 *protkey, u32 *protkeylen, u32 *protkeytype)
{ {
int rc; int rc;
u8 *mem; u8 *mem, *ptr;
struct CPRBX *preqcblk, *prepcblk; struct CPRBX *preqcblk, *prepcblk;
struct ica_xcRB xcrb; struct ica_xcRB xcrb;
struct aureqparm { struct aureqparm {
...@@ -1208,7 +1213,7 @@ int cca_cipher2protkey(u16 cardnr, u16 domain, const u8 *ckey, ...@@ -1208,7 +1213,7 @@ int cca_cipher2protkey(u16 cardnr, u16 domain, const u8 *ckey,
preqcblk->domain = domain; preqcblk->domain = domain;
/* fill request cprb param block with AU request */ /* fill request cprb param block with AU request */
preqparm = (struct aureqparm *) preqcblk->req_parmb; preqparm = (struct aureqparm __force *) preqcblk->req_parmb;
memcpy(preqparm->subfunc_code, "AU", 2); memcpy(preqparm->subfunc_code, "AU", 2);
preqparm->rule_array_len = preqparm->rule_array_len =
sizeof(preqparm->rule_array_len) sizeof(preqparm->rule_array_len)
...@@ -1257,8 +1262,9 @@ int cca_cipher2protkey(u16 cardnr, u16 domain, const u8 *ckey, ...@@ -1257,8 +1262,9 @@ int cca_cipher2protkey(u16 cardnr, u16 domain, const u8 *ckey,
} }
/* process response cprb param block */ /* process response cprb param block */
prepcblk->rpl_parmb = ((u8 *) prepcblk) + sizeof(struct CPRBX); ptr = ((u8 *) prepcblk) + sizeof(struct CPRBX);
prepparm = (struct aurepparm *) prepcblk->rpl_parmb; prepcblk->rpl_parmb = (u8 __user *) ptr;
prepparm = (struct aurepparm *) ptr;
/* check the returned keyblock */ /* check the returned keyblock */
if (prepparm->vud.ckb.version != 0x01 && if (prepparm->vud.ckb.version != 0x01 &&
...@@ -1347,7 +1353,7 @@ int cca_query_crypto_facility(u16 cardnr, u16 domain, ...@@ -1347,7 +1353,7 @@ int cca_query_crypto_facility(u16 cardnr, u16 domain,
preqcblk->domain = domain; preqcblk->domain = domain;
/* fill request cprb param block with FQ request */ /* fill request cprb param block with FQ request */
preqparm = (struct fqreqparm *) preqcblk->req_parmb; preqparm = (struct fqreqparm __force *) preqcblk->req_parmb;
memcpy(preqparm->subfunc_code, "FQ", 2); memcpy(preqparm->subfunc_code, "FQ", 2);
memcpy(preqparm->rule_array, keyword, sizeof(preqparm->rule_array)); memcpy(preqparm->rule_array, keyword, sizeof(preqparm->rule_array));
preqparm->rule_array_len = preqparm->rule_array_len =
...@@ -1378,8 +1384,9 @@ int cca_query_crypto_facility(u16 cardnr, u16 domain, ...@@ -1378,8 +1384,9 @@ int cca_query_crypto_facility(u16 cardnr, u16 domain,
} }
/* process response cprb param block */ /* process response cprb param block */
prepcblk->rpl_parmb = ((u8 *) prepcblk) + sizeof(struct CPRBX); ptr = ((u8 *) prepcblk) + sizeof(struct CPRBX);
prepparm = (struct fqrepparm *) prepcblk->rpl_parmb; prepcblk->rpl_parmb = (u8 __user *) ptr;
prepparm = (struct fqrepparm *) ptr;
ptr = prepparm->lvdata; ptr = prepparm->lvdata;
/* check and possibly copy reply rule array */ /* check and possibly copy reply rule array */
......
...@@ -87,24 +87,23 @@ static int zcrypt_cex2c_rng_supported(struct ap_queue *aq) ...@@ -87,24 +87,23 @@ static int zcrypt_cex2c_rng_supported(struct ap_queue *aq)
int rc, i; int rc, i;
ap_init_message(&ap_msg); ap_init_message(&ap_msg);
ap_msg.message = (void *) get_zeroed_page(GFP_KERNEL); ap_msg.msg = (void *) get_zeroed_page(GFP_KERNEL);
if (!ap_msg.message) if (!ap_msg.msg)
return -ENOMEM; return -ENOMEM;
rng_type6CPRB_msgX(&ap_msg, 4, &domain); rng_type6CPRB_msgX(&ap_msg, 4, &domain);
msg = ap_msg.message; msg = ap_msg.msg;
msg->cprbx.domain = AP_QID_QUEUE(aq->qid); msg->cprbx.domain = AP_QID_QUEUE(aq->qid);
rc = ap_send(aq->qid, 0x0102030405060708ULL, ap_msg.message, rc = ap_send(aq->qid, 0x0102030405060708ULL, ap_msg.msg, ap_msg.len);
ap_msg.length);
if (rc) if (rc)
goto out_free; goto out_free;
/* Wait for the test message to complete. */ /* Wait for the test message to complete. */
for (i = 0; i < 2 * HZ; i++) { for (i = 0; i < 2 * HZ; i++) {
msleep(1000 / HZ); msleep(1000 / HZ);
rc = ap_recv(aq->qid, &psmid, ap_msg.message, 4096); rc = ap_recv(aq->qid, &psmid, ap_msg.msg, 4096);
if (rc == 0 && psmid == 0x0102030405060708ULL) if (rc == 0 && psmid == 0x0102030405060708ULL)
break; break;
} }
...@@ -115,13 +114,13 @@ static int zcrypt_cex2c_rng_supported(struct ap_queue *aq) ...@@ -115,13 +114,13 @@ static int zcrypt_cex2c_rng_supported(struct ap_queue *aq)
goto out_free; goto out_free;
} }
reply = ap_msg.message; reply = ap_msg.msg;
if (reply->cprbx.ccp_rtcode == 0 && reply->cprbx.ccp_rscode == 0) if (reply->cprbx.ccp_rtcode == 0 && reply->cprbx.ccp_rscode == 0)
rc = 1; rc = 1;
else else
rc = 0; rc = 0;
out_free: out_free:
free_page((unsigned long) ap_msg.message); free_page((unsigned long) ap_msg.msg);
return rc; return rc;
} }
......
...@@ -80,7 +80,7 @@ struct error_hdr { ...@@ -80,7 +80,7 @@ struct error_hdr {
static inline int convert_error(struct zcrypt_queue *zq, static inline int convert_error(struct zcrypt_queue *zq,
struct ap_message *reply) struct ap_message *reply)
{ {
struct error_hdr *ehdr = reply->message; struct error_hdr *ehdr = reply->msg;
int card = AP_QID_CARD(zq->queue->qid); int card = AP_QID_CARD(zq->queue->qid);
int queue = AP_QID_QUEUE(zq->queue->qid); int queue = AP_QID_QUEUE(zq->queue->qid);
...@@ -127,7 +127,7 @@ static inline int convert_error(struct zcrypt_queue *zq, ...@@ -127,7 +127,7 @@ static inline int convert_error(struct zcrypt_queue *zq,
struct { struct {
struct type86_hdr hdr; struct type86_hdr hdr;
struct type86_fmt2_ext fmt2; struct type86_fmt2_ext fmt2;
} __packed * head = reply->message; } __packed * head = reply->msg;
unsigned int apfs = *((u32 *)head->fmt2.apfs); unsigned int apfs = *((u32 *)head->fmt2.apfs);
ZCRYPT_DBF(DBF_ERR, ZCRYPT_DBF(DBF_ERR,
......
...@@ -207,10 +207,10 @@ static int ICAMEX_msg_to_type50MEX_msg(struct zcrypt_queue *zq, ...@@ -207,10 +207,10 @@ static int ICAMEX_msg_to_type50MEX_msg(struct zcrypt_queue *zq,
mod_len = mex->inputdatalength; mod_len = mex->inputdatalength;
if (mod_len <= 128) { if (mod_len <= 128) {
struct type50_meb1_msg *meb1 = ap_msg->message; struct type50_meb1_msg *meb1 = ap_msg->msg;
memset(meb1, 0, sizeof(*meb1)); memset(meb1, 0, sizeof(*meb1));
ap_msg->length = sizeof(*meb1); ap_msg->len = sizeof(*meb1);
meb1->header.msg_type_code = TYPE50_TYPE_CODE; meb1->header.msg_type_code = TYPE50_TYPE_CODE;
meb1->header.msg_len = sizeof(*meb1); meb1->header.msg_len = sizeof(*meb1);
meb1->keyblock_type = TYPE50_MEB1_FMT; meb1->keyblock_type = TYPE50_MEB1_FMT;
...@@ -218,10 +218,10 @@ static int ICAMEX_msg_to_type50MEX_msg(struct zcrypt_queue *zq, ...@@ -218,10 +218,10 @@ static int ICAMEX_msg_to_type50MEX_msg(struct zcrypt_queue *zq,
exp = meb1->exponent + sizeof(meb1->exponent) - mod_len; exp = meb1->exponent + sizeof(meb1->exponent) - mod_len;
inp = meb1->message + sizeof(meb1->message) - mod_len; inp = meb1->message + sizeof(meb1->message) - mod_len;
} else if (mod_len <= 256) { } else if (mod_len <= 256) {
struct type50_meb2_msg *meb2 = ap_msg->message; struct type50_meb2_msg *meb2 = ap_msg->msg;
memset(meb2, 0, sizeof(*meb2)); memset(meb2, 0, sizeof(*meb2));
ap_msg->length = sizeof(*meb2); ap_msg->len = sizeof(*meb2);
meb2->header.msg_type_code = TYPE50_TYPE_CODE; meb2->header.msg_type_code = TYPE50_TYPE_CODE;
meb2->header.msg_len = sizeof(*meb2); meb2->header.msg_len = sizeof(*meb2);
meb2->keyblock_type = TYPE50_MEB2_FMT; meb2->keyblock_type = TYPE50_MEB2_FMT;
...@@ -229,10 +229,10 @@ static int ICAMEX_msg_to_type50MEX_msg(struct zcrypt_queue *zq, ...@@ -229,10 +229,10 @@ static int ICAMEX_msg_to_type50MEX_msg(struct zcrypt_queue *zq,
exp = meb2->exponent + sizeof(meb2->exponent) - mod_len; exp = meb2->exponent + sizeof(meb2->exponent) - mod_len;
inp = meb2->message + sizeof(meb2->message) - mod_len; inp = meb2->message + sizeof(meb2->message) - mod_len;
} else if (mod_len <= 512) { } else if (mod_len <= 512) {
struct type50_meb3_msg *meb3 = ap_msg->message; struct type50_meb3_msg *meb3 = ap_msg->msg;
memset(meb3, 0, sizeof(*meb3)); memset(meb3, 0, sizeof(*meb3));
ap_msg->length = sizeof(*meb3); ap_msg->len = sizeof(*meb3);
meb3->header.msg_type_code = TYPE50_TYPE_CODE; meb3->header.msg_type_code = TYPE50_TYPE_CODE;
meb3->header.msg_len = sizeof(*meb3); meb3->header.msg_len = sizeof(*meb3);
meb3->keyblock_type = TYPE50_MEB3_FMT; meb3->keyblock_type = TYPE50_MEB3_FMT;
...@@ -275,10 +275,10 @@ static int ICACRT_msg_to_type50CRT_msg(struct zcrypt_queue *zq, ...@@ -275,10 +275,10 @@ static int ICACRT_msg_to_type50CRT_msg(struct zcrypt_queue *zq,
* 512 byte modulus (4k keys). * 512 byte modulus (4k keys).
*/ */
if (mod_len <= 128) { /* up to 1024 bit key size */ if (mod_len <= 128) { /* up to 1024 bit key size */
struct type50_crb1_msg *crb1 = ap_msg->message; struct type50_crb1_msg *crb1 = ap_msg->msg;
memset(crb1, 0, sizeof(*crb1)); memset(crb1, 0, sizeof(*crb1));
ap_msg->length = sizeof(*crb1); ap_msg->len = sizeof(*crb1);
crb1->header.msg_type_code = TYPE50_TYPE_CODE; crb1->header.msg_type_code = TYPE50_TYPE_CODE;
crb1->header.msg_len = sizeof(*crb1); crb1->header.msg_len = sizeof(*crb1);
crb1->keyblock_type = TYPE50_CRB1_FMT; crb1->keyblock_type = TYPE50_CRB1_FMT;
...@@ -289,10 +289,10 @@ static int ICACRT_msg_to_type50CRT_msg(struct zcrypt_queue *zq, ...@@ -289,10 +289,10 @@ static int ICACRT_msg_to_type50CRT_msg(struct zcrypt_queue *zq,
u = crb1->u + sizeof(crb1->u) - short_len; u = crb1->u + sizeof(crb1->u) - short_len;
inp = crb1->message + sizeof(crb1->message) - mod_len; inp = crb1->message + sizeof(crb1->message) - mod_len;
} else if (mod_len <= 256) { /* up to 2048 bit key size */ } else if (mod_len <= 256) { /* up to 2048 bit key size */
struct type50_crb2_msg *crb2 = ap_msg->message; struct type50_crb2_msg *crb2 = ap_msg->msg;
memset(crb2, 0, sizeof(*crb2)); memset(crb2, 0, sizeof(*crb2));
ap_msg->length = sizeof(*crb2); ap_msg->len = sizeof(*crb2);
crb2->header.msg_type_code = TYPE50_TYPE_CODE; crb2->header.msg_type_code = TYPE50_TYPE_CODE;
crb2->header.msg_len = sizeof(*crb2); crb2->header.msg_len = sizeof(*crb2);
crb2->keyblock_type = TYPE50_CRB2_FMT; crb2->keyblock_type = TYPE50_CRB2_FMT;
...@@ -304,10 +304,10 @@ static int ICACRT_msg_to_type50CRT_msg(struct zcrypt_queue *zq, ...@@ -304,10 +304,10 @@ static int ICACRT_msg_to_type50CRT_msg(struct zcrypt_queue *zq,
inp = crb2->message + sizeof(crb2->message) - mod_len; inp = crb2->message + sizeof(crb2->message) - mod_len;
} else if ((mod_len <= 512) && /* up to 4096 bit key size */ } else if ((mod_len <= 512) && /* up to 4096 bit key size */
(zq->zcard->max_mod_size == CEX3A_MAX_MOD_SIZE)) { (zq->zcard->max_mod_size == CEX3A_MAX_MOD_SIZE)) {
struct type50_crb3_msg *crb3 = ap_msg->message; struct type50_crb3_msg *crb3 = ap_msg->msg;
memset(crb3, 0, sizeof(*crb3)); memset(crb3, 0, sizeof(*crb3));
ap_msg->length = sizeof(*crb3); ap_msg->len = sizeof(*crb3);
crb3->header.msg_type_code = TYPE50_TYPE_CODE; crb3->header.msg_type_code = TYPE50_TYPE_CODE;
crb3->header.msg_len = sizeof(*crb3); crb3->header.msg_len = sizeof(*crb3);
crb3->keyblock_type = TYPE50_CRB3_FMT; crb3->keyblock_type = TYPE50_CRB3_FMT;
...@@ -350,7 +350,7 @@ static int convert_type80(struct zcrypt_queue *zq, ...@@ -350,7 +350,7 @@ static int convert_type80(struct zcrypt_queue *zq,
char __user *outputdata, char __user *outputdata,
unsigned int outputdatalength) unsigned int outputdatalength)
{ {
struct type80_hdr *t80h = reply->message; struct type80_hdr *t80h = reply->msg;
unsigned char *data; unsigned char *data;
if (t80h->len < sizeof(*t80h) + outputdatalength) { if (t80h->len < sizeof(*t80h) + outputdatalength) {
...@@ -370,7 +370,7 @@ static int convert_type80(struct zcrypt_queue *zq, ...@@ -370,7 +370,7 @@ static int convert_type80(struct zcrypt_queue *zq,
BUG_ON(t80h->len > CEX2A_MAX_RESPONSE_SIZE); BUG_ON(t80h->len > CEX2A_MAX_RESPONSE_SIZE);
else else
BUG_ON(t80h->len > CEX3A_MAX_RESPONSE_SIZE); BUG_ON(t80h->len > CEX3A_MAX_RESPONSE_SIZE);
data = reply->message + t80h->len - outputdatalength; data = reply->msg + t80h->len - outputdatalength;
if (copy_to_user(outputdata, data, outputdatalength)) if (copy_to_user(outputdata, data, outputdatalength))
return -EFAULT; return -EFAULT;
return 0; return 0;
...@@ -382,7 +382,7 @@ static int convert_response(struct zcrypt_queue *zq, ...@@ -382,7 +382,7 @@ static int convert_response(struct zcrypt_queue *zq,
unsigned int outputdatalength) unsigned int outputdatalength)
{ {
/* Response type byte is the second byte in the response. */ /* Response type byte is the second byte in the response. */
unsigned char rtype = ((unsigned char *) reply->message)[1]; unsigned char rtype = ((unsigned char *) reply->msg)[1];
switch (rtype) { switch (rtype) {
case TYPE82_RSP_CODE: case TYPE82_RSP_CODE:
...@@ -422,22 +422,20 @@ static void zcrypt_cex2a_receive(struct ap_queue *aq, ...@@ -422,22 +422,20 @@ static void zcrypt_cex2a_receive(struct ap_queue *aq,
.reply_code = REP82_ERROR_MACHINE_FAILURE, .reply_code = REP82_ERROR_MACHINE_FAILURE,
}; };
struct type80_hdr *t80h; struct type80_hdr *t80h;
int length; int len;
/* Copy the reply message to the request message buffer. */ /* Copy the reply message to the request message buffer. */
if (!reply) if (!reply)
goto out; /* ap_msg->rc indicates the error */ goto out; /* ap_msg->rc indicates the error */
t80h = reply->message; t80h = reply->msg;
if (t80h->type == TYPE80_RSP_CODE) { if (t80h->type == TYPE80_RSP_CODE) {
if (aq->ap_dev.device_type == AP_DEVICE_TYPE_CEX2A) if (aq->ap_dev.device_type == AP_DEVICE_TYPE_CEX2A)
length = min_t(int, len = min_t(int, CEX2A_MAX_RESPONSE_SIZE, t80h->len);
CEX2A_MAX_RESPONSE_SIZE, t80h->len);
else else
length = min_t(int, len = min_t(int, CEX3A_MAX_RESPONSE_SIZE, t80h->len);
CEX3A_MAX_RESPONSE_SIZE, t80h->len); memcpy(msg->msg, reply->msg, len);
memcpy(msg->message, reply->message, length);
} else } else
memcpy(msg->message, reply->message, sizeof(error_reply)); memcpy(msg->msg, reply->msg, sizeof(error_reply));
out: out:
complete((struct completion *) msg->private); complete((struct completion *) msg->private);
} }
...@@ -460,12 +458,10 @@ static long zcrypt_cex2a_modexpo(struct zcrypt_queue *zq, ...@@ -460,12 +458,10 @@ static long zcrypt_cex2a_modexpo(struct zcrypt_queue *zq,
ap_init_message(&ap_msg); ap_init_message(&ap_msg);
if (zq->zcard->user_space_type == ZCRYPT_CEX2A) if (zq->zcard->user_space_type == ZCRYPT_CEX2A)
ap_msg.message = kmalloc(MSGTYPE50_CRB2_MAX_MSG_SIZE, ap_msg.msg = kmalloc(MSGTYPE50_CRB2_MAX_MSG_SIZE, GFP_KERNEL);
GFP_KERNEL);
else else
ap_msg.message = kmalloc(MSGTYPE50_CRB3_MAX_MSG_SIZE, ap_msg.msg = kmalloc(MSGTYPE50_CRB3_MAX_MSG_SIZE, GFP_KERNEL);
GFP_KERNEL); if (!ap_msg.msg)
if (!ap_msg.message)
return -ENOMEM; return -ENOMEM;
ap_msg.receive = zcrypt_cex2a_receive; ap_msg.receive = zcrypt_cex2a_receive;
ap_msg.psmid = (((unsigned long long) current->pid) << 32) + ap_msg.psmid = (((unsigned long long) current->pid) << 32) +
...@@ -486,7 +482,7 @@ static long zcrypt_cex2a_modexpo(struct zcrypt_queue *zq, ...@@ -486,7 +482,7 @@ static long zcrypt_cex2a_modexpo(struct zcrypt_queue *zq,
/* Signal pending. */ /* Signal pending. */
ap_cancel_message(zq->queue, &ap_msg); ap_cancel_message(zq->queue, &ap_msg);
out_free: out_free:
kfree(ap_msg.message); kfree(ap_msg.msg);
return rc; return rc;
} }
...@@ -506,12 +502,10 @@ static long zcrypt_cex2a_modexpo_crt(struct zcrypt_queue *zq, ...@@ -506,12 +502,10 @@ static long zcrypt_cex2a_modexpo_crt(struct zcrypt_queue *zq,
ap_init_message(&ap_msg); ap_init_message(&ap_msg);
if (zq->zcard->user_space_type == ZCRYPT_CEX2A) if (zq->zcard->user_space_type == ZCRYPT_CEX2A)
ap_msg.message = kmalloc(MSGTYPE50_CRB2_MAX_MSG_SIZE, ap_msg.msg = kmalloc(MSGTYPE50_CRB2_MAX_MSG_SIZE, GFP_KERNEL);
GFP_KERNEL);
else else
ap_msg.message = kmalloc(MSGTYPE50_CRB3_MAX_MSG_SIZE, ap_msg.msg = kmalloc(MSGTYPE50_CRB3_MAX_MSG_SIZE, GFP_KERNEL);
GFP_KERNEL); if (!ap_msg.msg)
if (!ap_msg.message)
return -ENOMEM; return -ENOMEM;
ap_msg.receive = zcrypt_cex2a_receive; ap_msg.receive = zcrypt_cex2a_receive;
ap_msg.psmid = (((unsigned long long) current->pid) << 32) + ap_msg.psmid = (((unsigned long long) current->pid) << 32) +
...@@ -532,7 +526,7 @@ static long zcrypt_cex2a_modexpo_crt(struct zcrypt_queue *zq, ...@@ -532,7 +526,7 @@ static long zcrypt_cex2a_modexpo_crt(struct zcrypt_queue *zq,
/* Signal pending. */ /* Signal pending. */
ap_cancel_message(zq->queue, &ap_msg); ap_cancel_message(zq->queue, &ap_msg);
out_free: out_free:
kfree(ap_msg.message); kfree(ap_msg.msg);
return rc; return rc;
} }
......
...@@ -266,7 +266,7 @@ static int ICAMEX_msg_to_type6MEX_msgX(struct zcrypt_queue *zq, ...@@ -266,7 +266,7 @@ static int ICAMEX_msg_to_type6MEX_msgX(struct zcrypt_queue *zq,
struct function_and_rules_block fr; struct function_and_rules_block fr;
unsigned short length; unsigned short length;
char text[0]; char text[0];
} __packed * msg = ap_msg->message; } __packed * msg = ap_msg->msg;
int size; int size;
/* /*
...@@ -301,7 +301,7 @@ static int ICAMEX_msg_to_type6MEX_msgX(struct zcrypt_queue *zq, ...@@ -301,7 +301,7 @@ static int ICAMEX_msg_to_type6MEX_msgX(struct zcrypt_queue *zq,
msg->cprbx.req_parml = size - sizeof(msg->hdr) - sizeof(msg->cprbx); msg->cprbx.req_parml = size - sizeof(msg->hdr) - sizeof(msg->cprbx);
ap_msg->length = size; ap_msg->len = size;
return 0; return 0;
} }
...@@ -336,7 +336,7 @@ static int ICACRT_msg_to_type6CRT_msgX(struct zcrypt_queue *zq, ...@@ -336,7 +336,7 @@ static int ICACRT_msg_to_type6CRT_msgX(struct zcrypt_queue *zq,
struct function_and_rules_block fr; struct function_and_rules_block fr;
unsigned short length; unsigned short length;
char text[0]; char text[0];
} __packed * msg = ap_msg->message; } __packed * msg = ap_msg->msg;
int size; int size;
/* /*
...@@ -370,7 +370,7 @@ static int ICACRT_msg_to_type6CRT_msgX(struct zcrypt_queue *zq, ...@@ -370,7 +370,7 @@ static int ICACRT_msg_to_type6CRT_msgX(struct zcrypt_queue *zq,
msg->fr = static_pkd_fnr; msg->fr = static_pkd_fnr;
ap_msg->length = size; ap_msg->len = size;
return 0; return 0;
} }
...@@ -400,11 +400,11 @@ static int XCRB_msg_to_type6CPRB_msgX(struct ap_message *ap_msg, ...@@ -400,11 +400,11 @@ static int XCRB_msg_to_type6CPRB_msgX(struct ap_message *ap_msg,
struct { struct {
struct type6_hdr hdr; struct type6_hdr hdr;
struct CPRBX cprbx; struct CPRBX cprbx;
} __packed * msg = ap_msg->message; } __packed * msg = ap_msg->msg;
int rcblen = CEIL4(xcRB->request_control_blk_length); int rcblen = CEIL4(xcRB->request_control_blk_length);
int replylen, req_sumlen, resp_sumlen; int replylen, req_sumlen, resp_sumlen;
char *req_data = ap_msg->message + sizeof(struct type6_hdr) + rcblen; char *req_data = ap_msg->msg + sizeof(struct type6_hdr) + rcblen;
char *function_code; char *function_code;
if (CEIL4(xcRB->request_control_blk_length) < if (CEIL4(xcRB->request_control_blk_length) <
...@@ -412,10 +412,10 @@ static int XCRB_msg_to_type6CPRB_msgX(struct ap_message *ap_msg, ...@@ -412,10 +412,10 @@ static int XCRB_msg_to_type6CPRB_msgX(struct ap_message *ap_msg,
return -EINVAL; /* overflow after alignment*/ return -EINVAL; /* overflow after alignment*/
/* length checks */ /* length checks */
ap_msg->length = sizeof(struct type6_hdr) + ap_msg->len = sizeof(struct type6_hdr) +
CEIL4(xcRB->request_control_blk_length) + CEIL4(xcRB->request_control_blk_length) +
xcRB->request_data_length; xcRB->request_data_length;
if (ap_msg->length > MSGTYPE06_MAX_MSG_SIZE) if (ap_msg->len > MSGTYPE06_MAX_MSG_SIZE)
return -EINVAL; return -EINVAL;
/* /*
...@@ -480,9 +480,7 @@ static int XCRB_msg_to_type6CPRB_msgX(struct ap_message *ap_msg, ...@@ -480,9 +480,7 @@ static int XCRB_msg_to_type6CPRB_msgX(struct ap_message *ap_msg,
if (memcmp(function_code, "US", 2) == 0 if (memcmp(function_code, "US", 2) == 0
|| memcmp(function_code, "AU", 2) == 0) || memcmp(function_code, "AU", 2) == 0)
ap_msg->special = 1; ap_msg->flags |= AP_MSG_FLAG_SPECIAL;
else
ap_msg->special = 0;
/* copy data block */ /* copy data block */
if (xcRB->request_data_length && if (xcRB->request_data_length &&
...@@ -512,7 +510,7 @@ static int xcrb_msg_to_type6_ep11cprb_msgx(struct ap_message *ap_msg, ...@@ -512,7 +510,7 @@ static int xcrb_msg_to_type6_ep11cprb_msgx(struct ap_message *ap_msg,
struct ep11_cprb cprbx; struct ep11_cprb cprbx;
unsigned char pld_tag; /* fixed value 0x30 */ unsigned char pld_tag; /* fixed value 0x30 */
unsigned char pld_lenfmt; /* payload length format */ unsigned char pld_lenfmt; /* payload length format */
} __packed * msg = ap_msg->message; } __packed * msg = ap_msg->msg;
struct pld_hdr { struct pld_hdr {
unsigned char func_tag; /* fixed value 0x4 */ unsigned char func_tag; /* fixed value 0x4 */
...@@ -527,7 +525,7 @@ static int xcrb_msg_to_type6_ep11cprb_msgx(struct ap_message *ap_msg, ...@@ -527,7 +525,7 @@ static int xcrb_msg_to_type6_ep11cprb_msgx(struct ap_message *ap_msg,
return -EINVAL; /* overflow after alignment*/ return -EINVAL; /* overflow after alignment*/
/* length checks */ /* length checks */
ap_msg->length = sizeof(struct type6_hdr) + xcRB->req_len; ap_msg->len = sizeof(struct type6_hdr) + xcRB->req_len;
if (CEIL4(xcRB->req_len) > MSGTYPE06_MAX_MSG_SIZE - if (CEIL4(xcRB->req_len) > MSGTYPE06_MAX_MSG_SIZE -
(sizeof(struct type6_hdr))) (sizeof(struct type6_hdr)))
return -EINVAL; return -EINVAL;
...@@ -569,7 +567,7 @@ static int xcrb_msg_to_type6_ep11cprb_msgx(struct ap_message *ap_msg, ...@@ -569,7 +567,7 @@ static int xcrb_msg_to_type6_ep11cprb_msgx(struct ap_message *ap_msg,
/* enable special processing based on the cprbs flags special bit */ /* enable special processing based on the cprbs flags special bit */
if (msg->cprbx.flags & 0x20) if (msg->cprbx.flags & 0x20)
ap_msg->special = 1; ap_msg->flags |= AP_MSG_FLAG_SPECIAL;
return 0; return 0;
} }
...@@ -639,7 +637,7 @@ static int convert_type86_ica(struct zcrypt_queue *zq, ...@@ -639,7 +637,7 @@ static int convert_type86_ica(struct zcrypt_queue *zq,
0x35, 0x9D, 0xD3, 0xD3, 0xA7, 0x9D, 0x5D, 0x41, 0x35, 0x9D, 0xD3, 0xD3, 0xA7, 0x9D, 0x5D, 0x41,
0x6F, 0x65, 0x1B, 0xCF, 0xA9, 0x87, 0x91, 0x09 0x6F, 0x65, 0x1B, 0xCF, 0xA9, 0x87, 0x91, 0x09
}; };
struct type86x_reply *msg = reply->message; struct type86x_reply *msg = reply->msg;
unsigned short service_rc, service_rs; unsigned short service_rc, service_rs;
unsigned int reply_len, pad_len; unsigned int reply_len, pad_len;
char *data; char *data;
...@@ -713,8 +711,8 @@ static int convert_type86_xcrb(struct zcrypt_queue *zq, ...@@ -713,8 +711,8 @@ static int convert_type86_xcrb(struct zcrypt_queue *zq,
struct ap_message *reply, struct ap_message *reply,
struct ica_xcRB *xcRB) struct ica_xcRB *xcRB)
{ {
struct type86_fmt2_msg *msg = reply->message; struct type86_fmt2_msg *msg = reply->msg;
char *data = reply->message; char *data = reply->msg;
/* Copy CPRB to user */ /* Copy CPRB to user */
if (copy_to_user(xcRB->reply_control_blk_addr, if (copy_to_user(xcRB->reply_control_blk_addr,
...@@ -744,8 +742,8 @@ static int convert_type86_ep11_xcrb(struct zcrypt_queue *zq, ...@@ -744,8 +742,8 @@ static int convert_type86_ep11_xcrb(struct zcrypt_queue *zq,
struct ap_message *reply, struct ap_message *reply,
struct ep11_urb *xcRB) struct ep11_urb *xcRB)
{ {
struct type86_fmt2_msg *msg = reply->message; struct type86_fmt2_msg *msg = reply->msg;
char *data = reply->message; char *data = reply->msg;
if (xcRB->resp_len < msg->fmt2.count1) if (xcRB->resp_len < msg->fmt2.count1)
return -EINVAL; return -EINVAL;
...@@ -766,8 +764,8 @@ static int convert_type86_rng(struct zcrypt_queue *zq, ...@@ -766,8 +764,8 @@ static int convert_type86_rng(struct zcrypt_queue *zq,
struct type86_hdr hdr; struct type86_hdr hdr;
struct type86_fmt2_ext fmt2; struct type86_fmt2_ext fmt2;
struct CPRBX cprbx; struct CPRBX cprbx;
} __packed * msg = reply->message; } __packed * msg = reply->msg;
char *data = reply->message; char *data = reply->msg;
if (msg->cprbx.ccp_rtcode != 0 || msg->cprbx.ccp_rscode != 0) if (msg->cprbx.ccp_rtcode != 0 || msg->cprbx.ccp_rscode != 0)
return -EINVAL; return -EINVAL;
...@@ -780,7 +778,7 @@ static int convert_response_ica(struct zcrypt_queue *zq, ...@@ -780,7 +778,7 @@ static int convert_response_ica(struct zcrypt_queue *zq,
char __user *outputdata, char __user *outputdata,
unsigned int outputdatalength) unsigned int outputdatalength)
{ {
struct type86x_reply *msg = reply->message; struct type86x_reply *msg = reply->msg;
switch (msg->hdr.type) { switch (msg->hdr.type) {
case TYPE82_RSP_CODE: case TYPE82_RSP_CODE:
...@@ -820,7 +818,7 @@ static int convert_response_xcrb(struct zcrypt_queue *zq, ...@@ -820,7 +818,7 @@ static int convert_response_xcrb(struct zcrypt_queue *zq,
struct ap_message *reply, struct ap_message *reply,
struct ica_xcRB *xcRB) struct ica_xcRB *xcRB)
{ {
struct type86x_reply *msg = reply->message; struct type86x_reply *msg = reply->msg;
switch (msg->hdr.type) { switch (msg->hdr.type) {
case TYPE82_RSP_CODE: case TYPE82_RSP_CODE:
...@@ -853,7 +851,7 @@ static int convert_response_xcrb(struct zcrypt_queue *zq, ...@@ -853,7 +851,7 @@ static int convert_response_xcrb(struct zcrypt_queue *zq,
static int convert_response_ep11_xcrb(struct zcrypt_queue *zq, static int convert_response_ep11_xcrb(struct zcrypt_queue *zq,
struct ap_message *reply, struct ep11_urb *xcRB) struct ap_message *reply, struct ep11_urb *xcRB)
{ {
struct type86_ep11_reply *msg = reply->message; struct type86_ep11_reply *msg = reply->msg;
switch (msg->hdr.type) { switch (msg->hdr.type) {
case TYPE82_RSP_CODE: case TYPE82_RSP_CODE:
...@@ -883,7 +881,7 @@ static int convert_response_rng(struct zcrypt_queue *zq, ...@@ -883,7 +881,7 @@ static int convert_response_rng(struct zcrypt_queue *zq,
struct ap_message *reply, struct ap_message *reply,
char *data) char *data)
{ {
struct type86x_reply *msg = reply->message; struct type86x_reply *msg = reply->msg;
switch (msg->hdr.type) { switch (msg->hdr.type) {
case TYPE82_RSP_CODE: case TYPE82_RSP_CODE:
...@@ -928,32 +926,30 @@ static void zcrypt_msgtype6_receive(struct ap_queue *aq, ...@@ -928,32 +926,30 @@ static void zcrypt_msgtype6_receive(struct ap_queue *aq,
struct response_type *resp_type = struct response_type *resp_type =
(struct response_type *) msg->private; (struct response_type *) msg->private;
struct type86x_reply *t86r; struct type86x_reply *t86r;
int length; int len;
/* Copy the reply message to the request message buffer. */ /* Copy the reply message to the request message buffer. */
if (!reply) if (!reply)
goto out; /* ap_msg->rc indicates the error */ goto out; /* ap_msg->rc indicates the error */
t86r = reply->message; t86r = reply->msg;
if (t86r->hdr.type == TYPE86_RSP_CODE && if (t86r->hdr.type == TYPE86_RSP_CODE &&
t86r->cprbx.cprb_ver_id == 0x02) { t86r->cprbx.cprb_ver_id == 0x02) {
switch (resp_type->type) { switch (resp_type->type) {
case CEXXC_RESPONSE_TYPE_ICA: case CEXXC_RESPONSE_TYPE_ICA:
length = sizeof(struct type86x_reply) len = sizeof(struct type86x_reply) + t86r->length - 2;
+ t86r->length - 2; len = min_t(int, CEXXC_MAX_ICA_RESPONSE_SIZE, len);
length = min(CEXXC_MAX_ICA_RESPONSE_SIZE, length); memcpy(msg->msg, reply->msg, len);
memcpy(msg->message, reply->message, length);
break; break;
case CEXXC_RESPONSE_TYPE_XCRB: case CEXXC_RESPONSE_TYPE_XCRB:
length = t86r->fmt2.offset2 + t86r->fmt2.count2; len = t86r->fmt2.offset2 + t86r->fmt2.count2;
length = min(MSGTYPE06_MAX_MSG_SIZE, length); len = min_t(int, MSGTYPE06_MAX_MSG_SIZE, len);
memcpy(msg->message, reply->message, length); memcpy(msg->msg, reply->msg, len);
break; break;
default: default:
memcpy(msg->message, &error_reply, memcpy(msg->msg, &error_reply, sizeof(error_reply));
sizeof(error_reply));
} }
} else } else
memcpy(msg->message, reply->message, sizeof(error_reply)); memcpy(msg->msg, reply->msg, sizeof(error_reply));
out: out:
complete(&(resp_type->work)); complete(&(resp_type->work));
} }
...@@ -977,25 +973,25 @@ static void zcrypt_msgtype6_receive_ep11(struct ap_queue *aq, ...@@ -977,25 +973,25 @@ static void zcrypt_msgtype6_receive_ep11(struct ap_queue *aq,
struct response_type *resp_type = struct response_type *resp_type =
(struct response_type *)msg->private; (struct response_type *)msg->private;
struct type86_ep11_reply *t86r; struct type86_ep11_reply *t86r;
int length; int len;
/* Copy the reply message to the request message buffer. */ /* Copy the reply message to the request message buffer. */
if (!reply) if (!reply)
goto out; /* ap_msg->rc indicates the error */ goto out; /* ap_msg->rc indicates the error */
t86r = reply->message; t86r = reply->msg;
if (t86r->hdr.type == TYPE86_RSP_CODE && if (t86r->hdr.type == TYPE86_RSP_CODE &&
t86r->cprbx.cprb_ver_id == 0x04) { t86r->cprbx.cprb_ver_id == 0x04) {
switch (resp_type->type) { switch (resp_type->type) {
case CEXXC_RESPONSE_TYPE_EP11: case CEXXC_RESPONSE_TYPE_EP11:
length = t86r->fmt2.offset1 + t86r->fmt2.count1; len = t86r->fmt2.offset1 + t86r->fmt2.count1;
length = min(MSGTYPE06_MAX_MSG_SIZE, length); len = min_t(int, MSGTYPE06_MAX_MSG_SIZE, len);
memcpy(msg->message, reply->message, length); memcpy(msg->msg, reply->msg, len);
break; break;
default: default:
memcpy(msg->message, &error_reply, sizeof(error_reply)); memcpy(msg->msg, &error_reply, sizeof(error_reply));
} }
} else { } else {
memcpy(msg->message, reply->message, sizeof(error_reply)); memcpy(msg->msg, reply->msg, sizeof(error_reply));
} }
out: out:
complete(&(resp_type->work)); complete(&(resp_type->work));
...@@ -1020,8 +1016,8 @@ static long zcrypt_msgtype6_modexpo(struct zcrypt_queue *zq, ...@@ -1020,8 +1016,8 @@ static long zcrypt_msgtype6_modexpo(struct zcrypt_queue *zq,
int rc; int rc;
ap_init_message(&ap_msg); ap_init_message(&ap_msg);
ap_msg.message = (void *) get_zeroed_page(GFP_KERNEL); ap_msg.msg = (void *) get_zeroed_page(GFP_KERNEL);
if (!ap_msg.message) if (!ap_msg.msg)
return -ENOMEM; return -ENOMEM;
ap_msg.receive = zcrypt_msgtype6_receive; ap_msg.receive = zcrypt_msgtype6_receive;
ap_msg.psmid = (((unsigned long long) current->pid) << 32) + ap_msg.psmid = (((unsigned long long) current->pid) << 32) +
...@@ -1043,7 +1039,7 @@ static long zcrypt_msgtype6_modexpo(struct zcrypt_queue *zq, ...@@ -1043,7 +1039,7 @@ static long zcrypt_msgtype6_modexpo(struct zcrypt_queue *zq,
/* Signal pending. */ /* Signal pending. */
ap_cancel_message(zq->queue, &ap_msg); ap_cancel_message(zq->queue, &ap_msg);
out_free: out_free:
free_page((unsigned long) ap_msg.message); free_page((unsigned long) ap_msg.msg);
return rc; return rc;
} }
...@@ -1064,8 +1060,8 @@ static long zcrypt_msgtype6_modexpo_crt(struct zcrypt_queue *zq, ...@@ -1064,8 +1060,8 @@ static long zcrypt_msgtype6_modexpo_crt(struct zcrypt_queue *zq,
int rc; int rc;
ap_init_message(&ap_msg); ap_init_message(&ap_msg);
ap_msg.message = (void *) get_zeroed_page(GFP_KERNEL); ap_msg.msg = (void *) get_zeroed_page(GFP_KERNEL);
if (!ap_msg.message) if (!ap_msg.msg)
return -ENOMEM; return -ENOMEM;
ap_msg.receive = zcrypt_msgtype6_receive; ap_msg.receive = zcrypt_msgtype6_receive;
ap_msg.psmid = (((unsigned long long) current->pid) << 32) + ap_msg.psmid = (((unsigned long long) current->pid) << 32) +
...@@ -1088,7 +1084,7 @@ static long zcrypt_msgtype6_modexpo_crt(struct zcrypt_queue *zq, ...@@ -1088,7 +1084,7 @@ static long zcrypt_msgtype6_modexpo_crt(struct zcrypt_queue *zq,
ap_cancel_message(zq->queue, &ap_msg); ap_cancel_message(zq->queue, &ap_msg);
} }
out_free: out_free:
free_page((unsigned long) ap_msg.message); free_page((unsigned long) ap_msg.msg);
return rc; return rc;
} }
...@@ -1107,8 +1103,8 @@ unsigned int get_cprb_fc(struct ica_xcRB *xcRB, ...@@ -1107,8 +1103,8 @@ unsigned int get_cprb_fc(struct ica_xcRB *xcRB,
.type = CEXXC_RESPONSE_TYPE_XCRB, .type = CEXXC_RESPONSE_TYPE_XCRB,
}; };
ap_msg->message = kmalloc(MSGTYPE06_MAX_MSG_SIZE, GFP_KERNEL); ap_msg->msg = kmalloc(MSGTYPE06_MAX_MSG_SIZE, GFP_KERNEL);
if (!ap_msg->message) if (!ap_msg->msg)
return -ENOMEM; return -ENOMEM;
ap_msg->receive = zcrypt_msgtype6_receive; ap_msg->receive = zcrypt_msgtype6_receive;
ap_msg->psmid = (((unsigned long long) current->pid) << 32) + ap_msg->psmid = (((unsigned long long) current->pid) << 32) +
...@@ -1162,8 +1158,8 @@ unsigned int get_ep11cprb_fc(struct ep11_urb *xcrb, ...@@ -1162,8 +1158,8 @@ unsigned int get_ep11cprb_fc(struct ep11_urb *xcrb,
.type = CEXXC_RESPONSE_TYPE_EP11, .type = CEXXC_RESPONSE_TYPE_EP11,
}; };
ap_msg->message = kmalloc(MSGTYPE06_MAX_MSG_SIZE, GFP_KERNEL); ap_msg->msg = kmalloc(MSGTYPE06_MAX_MSG_SIZE, GFP_KERNEL);
if (!ap_msg->message) if (!ap_msg->msg)
return -ENOMEM; return -ENOMEM;
ap_msg->receive = zcrypt_msgtype6_receive_ep11; ap_msg->receive = zcrypt_msgtype6_receive_ep11;
ap_msg->psmid = (((unsigned long long) current->pid) << 32) + ap_msg->psmid = (((unsigned long long) current->pid) << 32) +
...@@ -1193,7 +1189,7 @@ static long zcrypt_msgtype6_send_ep11_cprb(struct zcrypt_queue *zq, ...@@ -1193,7 +1189,7 @@ static long zcrypt_msgtype6_send_ep11_cprb(struct zcrypt_queue *zq,
struct ep11_cprb cprbx; struct ep11_cprb cprbx;
unsigned char pld_tag; /* fixed value 0x30 */ unsigned char pld_tag; /* fixed value 0x30 */
unsigned char pld_lenfmt; /* payload length format */ unsigned char pld_lenfmt; /* payload length format */
} __packed * msg = ap_msg->message; } __packed * msg = ap_msg->msg;
struct pld_hdr { struct pld_hdr {
unsigned char func_tag; /* fixed value 0x4 */ unsigned char func_tag; /* fixed value 0x4 */
unsigned char func_len; /* fixed value 0x4 */ unsigned char func_len; /* fixed value 0x4 */
...@@ -1256,8 +1252,8 @@ unsigned int get_rng_fc(struct ap_message *ap_msg, int *func_code, ...@@ -1256,8 +1252,8 @@ unsigned int get_rng_fc(struct ap_message *ap_msg, int *func_code,
.type = CEXXC_RESPONSE_TYPE_XCRB, .type = CEXXC_RESPONSE_TYPE_XCRB,
}; };
ap_msg->message = kmalloc(MSGTYPE06_MAX_MSG_SIZE, GFP_KERNEL); ap_msg->msg = kmalloc(MSGTYPE06_MAX_MSG_SIZE, GFP_KERNEL);
if (!ap_msg->message) if (!ap_msg->msg)
return -ENOMEM; return -ENOMEM;
ap_msg->receive = zcrypt_msgtype6_receive; ap_msg->receive = zcrypt_msgtype6_receive;
ap_msg->psmid = (((unsigned long long) current->pid) << 32) + ap_msg->psmid = (((unsigned long long) current->pid) << 32) +
...@@ -1290,7 +1286,7 @@ static long zcrypt_msgtype6_rng(struct zcrypt_queue *zq, ...@@ -1290,7 +1286,7 @@ static long zcrypt_msgtype6_rng(struct zcrypt_queue *zq,
char rule[8]; char rule[8];
short int verb_length; short int verb_length;
short int key_length; short int key_length;
} __packed * msg = ap_msg->message; } __packed * msg = ap_msg->msg;
struct response_type *rtype = (struct response_type *)(ap_msg->private); struct response_type *rtype = (struct response_type *)(ap_msg->private);
int rc; int rc;
......
...@@ -127,7 +127,7 @@ static inline void rng_type6CPRB_msgX(struct ap_message *ap_msg, ...@@ -127,7 +127,7 @@ static inline void rng_type6CPRB_msgX(struct ap_message *ap_msg,
char rule[8]; char rule[8];
short int verb_length; short int verb_length;
short int key_length; short int key_length;
} __packed * msg = ap_msg->message; } __packed * msg = ap_msg->msg;
static struct type6_hdr static_type6_hdrX = { static struct type6_hdr static_type6_hdrX = {
.type = 0x06, .type = 0x06,
.offset1 = 0x00000058, .offset1 = 0x00000058,
...@@ -154,7 +154,7 @@ static inline void rng_type6CPRB_msgX(struct ap_message *ap_msg, ...@@ -154,7 +154,7 @@ static inline void rng_type6CPRB_msgX(struct ap_message *ap_msg,
memcpy(msg->rule, "RANDOM ", 8); memcpy(msg->rule, "RANDOM ", 8);
msg->verb_length = 0x02; msg->verb_length = 0x02;
msg->key_length = 0x02; msg->key_length = 0x02;
ap_msg->length = sizeof(*msg); ap_msg->len = sizeof(*msg);
*domain = (unsigned short)msg->cprbx.domain; *domain = (unsigned short)msg->cprbx.domain;
} }
......
...@@ -107,10 +107,10 @@ struct zcrypt_queue *zcrypt_queue_alloc(size_t max_response_size) ...@@ -107,10 +107,10 @@ struct zcrypt_queue *zcrypt_queue_alloc(size_t max_response_size)
zq = kzalloc(sizeof(struct zcrypt_queue), GFP_KERNEL); zq = kzalloc(sizeof(struct zcrypt_queue), GFP_KERNEL);
if (!zq) if (!zq)
return NULL; return NULL;
zq->reply.message = kmalloc(max_response_size, GFP_KERNEL); zq->reply.msg = kmalloc(max_response_size, GFP_KERNEL);
if (!zq->reply.message) if (!zq->reply.msg)
goto out_free; goto out_free;
zq->reply.length = max_response_size; zq->reply.len = max_response_size;
INIT_LIST_HEAD(&zq->list); INIT_LIST_HEAD(&zq->list);
kref_init(&zq->refcount); kref_init(&zq->refcount);
return zq; return zq;
...@@ -123,7 +123,7 @@ EXPORT_SYMBOL(zcrypt_queue_alloc); ...@@ -123,7 +123,7 @@ EXPORT_SYMBOL(zcrypt_queue_alloc);
void zcrypt_queue_free(struct zcrypt_queue *zq) void zcrypt_queue_free(struct zcrypt_queue *zq)
{ {
kfree(zq->reply.message); kfree(zq->reply.msg);
kfree(zq); kfree(zq);
} }
EXPORT_SYMBOL(zcrypt_queue_free); EXPORT_SYMBOL(zcrypt_queue_free);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment