]> git.proxmox.com Git - mirror_ubuntu-focal-kernel.git/commitdiff
s390/zcrypt: ep11 structs rework, export zcrypt_send_ep11_cprb
authorHarald Freudenberger <freude@linux.ibm.com>
Mon, 17 Feb 2020 17:37:11 +0000 (18:37 +0100)
committerSeth Forshee <seth.forshee@canonical.com>
Thu, 20 Feb 2020 13:58:10 +0000 (07:58 -0600)
BugLink: https://bugs.launchpad.net/bugs/1853303
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>
(cherry picked from commit a7367997abb64b5e5a4f6fe6091629440b10da40)
Signed-off-by: Frank Heimes <frank.heimes@canonical.com>
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
arch/s390/include/uapi/asm/zcrypt.h
drivers/s390/crypto/zcrypt_api.c
drivers/s390/crypto/zcrypt_api.h

index 7f179a30beb19a010d208b8fdd0a12b09a563210..5a2177e96e887de622dc6f729d2f7e8d260100e6 100644 (file)
@@ -161,17 +161,17 @@ struct ica_xcRB {
  * @payload_len:       Payload length
  */
 struct ep11_cprb {
-       __u16           cprb_len;
-       unsigned char   cprb_ver_id;
-       unsigned char   pad_000[2];
-       unsigned char   flags;
-       unsigned char   func_id[2];
-       __u32           source_id;
-       __u32           target_id;
-       __u32           ret_code;
-       __u32           reserved1;
-       __u32           reserved2;
-       __u32           payload_len;
+       __u16   cprb_len;
+       __u8    cprb_ver_id;
+       __u8    pad_000[2];
+       __u8    flags;
+       __u8    func_id[2];
+       __u32   source_id;
+       __u32   target_id;
+       __u32   ret_code;
+       __u32   reserved1;
+       __u32   reserved2;
+       __u32   payload_len;
 } __attribute__((packed));
 
 /**
@@ -197,13 +197,13 @@ struct ep11_target_dev {
  */
 struct ep11_urb {
        __u16           targets_num;
-       __u64           targets;
+       __u8 __user    *targets;
        __u64           weight;
        __u64           req_no;
        __u64           req_len;
-       __u64           req;
+       __u8 __user    *req;
        __u64           resp_len;
-       __u64           resp;
+       __u8 __user    *resp;
 } __attribute__((packed));
 
 /**
index 6244380ce75230cf43430ba84b84cbe0070e9dd2..0ea7c71bfaa0b6098d935ba3ae65dc5518ae39c0 100644 (file)
@@ -923,8 +923,8 @@ static bool is_desired_ep11_queue(unsigned int dev_qid,
        return false;
 }
 
-static long zcrypt_send_ep11_cprb(struct ap_perms *perms,
-                                 struct ep11_urb *xcrb)
+static long _zcrypt_send_ep11_cprb(struct ap_perms *perms,
+                                  struct ep11_urb *xcrb)
 {
        struct zcrypt_card *zc, *pref_zc;
        struct zcrypt_queue *zq, *pref_zq;
@@ -1029,6 +1029,12 @@ out:
        return rc;
 }
 
+long zcrypt_send_ep11_cprb(struct ep11_urb *xcrb)
+{
+       return _zcrypt_send_ep11_cprb(&ap_perms, xcrb);
+}
+EXPORT_SYMBOL(zcrypt_send_ep11_cprb);
+
 static long zcrypt_rng(char *buffer)
 {
        struct zcrypt_card *zc, *pref_zc;
@@ -1369,12 +1375,12 @@ static long zcrypt_unlocked_ioctl(struct file *filp, unsigned int cmd,
                if (copy_from_user(&xcrb, uxcrb, sizeof(xcrb)))
                        return -EFAULT;
                do {
-                       rc = zcrypt_send_ep11_cprb(perms, &xcrb);
+                       rc = _zcrypt_send_ep11_cprb(perms, &xcrb);
                } while (rc == -EAGAIN);
                /* on failure: retry once again after a requested rescan */
                if ((rc == -ENODEV) && (zcrypt_process_rescan()))
                        do {
-                               rc = zcrypt_send_ep11_cprb(perms, &xcrb);
+                               rc = _zcrypt_send_ep11_cprb(perms, &xcrb);
                        } while (rc == -EAGAIN);
                if (rc)
                        ZCRYPT_DBF(DBF_DEBUG, "ioctl ZSENDEP11CPRB rc=%d\n", rc);
index d464618cd84f50274dfdc5eed3f69498dfc29448..599e68bf53f7a82680a4fc158f39aa400a27f391 100644 (file)
@@ -140,6 +140,7 @@ struct zcrypt_ops *zcrypt_msgtype(unsigned char *, int);
 int zcrypt_api_init(void);
 void zcrypt_api_exit(void);
 long zcrypt_send_cprb(struct ica_xcRB *xcRB);
+long zcrypt_send_ep11_cprb(struct ep11_urb *urb);
 void zcrypt_device_status_mask_ext(struct zcrypt_device_status_ext *devstatus);
 int zcrypt_device_status_ext(int card, int queue,
                             struct zcrypt_device_status_ext *devstatus);