Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

s390/zcrypt: ep11 structs rework, export zcrypt_send_ep11_cprb

Minor rework for struct ep11_cprb and struct ep11_urb. Use of u8, u16,
u32 instead of unsigned char. Declare pointers to mem from userspace
with __user to give sparse a chance to check.

Export zcrypt_send_ep11_cprb() function as this function will be
called by code in progress which will build ep11 cprbs within the
zcrypt device driver zoo and send them to EP11 crypto cards.

Signed-off-by: Harald Freudenberger <freude@linux.ibm.com>
Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>

authored by

Harald Freudenberger and committed by
Vasily Gorbik
a7367997 8f291ebf

+25 -18
+14 -14
arch/s390/include/uapi/asm/zcrypt.h
··· 161 161 * @payload_len: Payload length 162 162 */ 163 163 struct ep11_cprb { 164 - __u16 cprb_len; 165 - unsigned char cprb_ver_id; 166 - unsigned char pad_000[2]; 167 - unsigned char flags; 168 - unsigned char func_id[2]; 169 - __u32 source_id; 170 - __u32 target_id; 171 - __u32 ret_code; 172 - __u32 reserved1; 173 - __u32 reserved2; 174 - __u32 payload_len; 164 + __u16 cprb_len; 165 + __u8 cprb_ver_id; 166 + __u8 pad_000[2]; 167 + __u8 flags; 168 + __u8 func_id[2]; 169 + __u32 source_id; 170 + __u32 target_id; 171 + __u32 ret_code; 172 + __u32 reserved1; 173 + __u32 reserved2; 174 + __u32 payload_len; 175 175 } __attribute__((packed)); 176 176 177 177 /** ··· 197 197 */ 198 198 struct ep11_urb { 199 199 __u16 targets_num; 200 - __u64 targets; 200 + __u8 __user *targets; 201 201 __u64 weight; 202 202 __u64 req_no; 203 203 __u64 req_len; 204 - __u64 req; 204 + __u8 __user *req; 205 205 __u64 resp_len; 206 - __u64 resp; 206 + __u8 __user *resp; 207 207 } __attribute__((packed)); 208 208 209 209 /**
+10 -4
drivers/s390/crypto/zcrypt_api.c
··· 923 923 return false; 924 924 } 925 925 926 - static long zcrypt_send_ep11_cprb(struct ap_perms *perms, 927 - struct ep11_urb *xcrb) 926 + static long _zcrypt_send_ep11_cprb(struct ap_perms *perms, 927 + struct ep11_urb *xcrb) 928 928 { 929 929 struct zcrypt_card *zc, *pref_zc; 930 930 struct zcrypt_queue *zq, *pref_zq; ··· 1028 1028 AP_QID_CARD(qid), AP_QID_QUEUE(qid)); 1029 1029 return rc; 1030 1030 } 1031 + 1032 + long zcrypt_send_ep11_cprb(struct ep11_urb *xcrb) 1033 + { 1034 + return _zcrypt_send_ep11_cprb(&ap_perms, xcrb); 1035 + } 1036 + EXPORT_SYMBOL(zcrypt_send_ep11_cprb); 1031 1037 1032 1038 static long zcrypt_rng(char *buffer) 1033 1039 { ··· 1375 1369 if (copy_from_user(&xcrb, uxcrb, sizeof(xcrb))) 1376 1370 return -EFAULT; 1377 1371 do { 1378 - rc = zcrypt_send_ep11_cprb(perms, &xcrb); 1372 + rc = _zcrypt_send_ep11_cprb(perms, &xcrb); 1379 1373 } while (rc == -EAGAIN); 1380 1374 /* on failure: retry once again after a requested rescan */ 1381 1375 if ((rc == -ENODEV) && (zcrypt_process_rescan())) 1382 1376 do { 1383 - rc = zcrypt_send_ep11_cprb(perms, &xcrb); 1377 + rc = _zcrypt_send_ep11_cprb(perms, &xcrb); 1384 1378 } while (rc == -EAGAIN); 1385 1379 if (rc) 1386 1380 ZCRYPT_DBF(DBF_DEBUG, "ioctl ZSENDEP11CPRB rc=%d\n", rc);
+1
drivers/s390/crypto/zcrypt_api.h
··· 140 140 int zcrypt_api_init(void); 141 141 void zcrypt_api_exit(void); 142 142 long zcrypt_send_cprb(struct ica_xcRB *xcRB); 143 + long zcrypt_send_ep11_cprb(struct ep11_urb *urb); 143 144 void zcrypt_device_status_mask_ext(struct zcrypt_device_status_ext *devstatus); 144 145 int zcrypt_device_status_ext(int card, int queue, 145 146 struct zcrypt_device_status_ext *devstatus);