]> git.baikalelectronics.ru Git - kernel.git/commitdiff
s390/zcrypt: Fix ZCRYPT_PERDEV_REQCNT ioctl
authorChristian Borntraeger <borntraeger@de.ibm.com>
Mon, 21 Sep 2020 10:48:36 +0000 (12:48 +0200)
committerVasily Gorbik <gor@linux.ibm.com>
Thu, 24 Sep 2020 07:57:24 +0000 (09:57 +0200)
reqcnt is an u32 pointer but we do copy sizeof(reqcnt) which is the
size of the pointer. This means we only copy 8 byte. Let us copy
the full monty.

Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
Cc: Harald Freudenberger <freude@linux.ibm.com>
Cc: stable@vger.kernel.org
Fixes: 9c549e36892a ("s390/zcrypt: Support up to 256 crypto adapters.")
Reviewed-by: Harald Freudenberger <freude@linux.ibm.com>
Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
drivers/s390/crypto/zcrypt_api.c

index 4dbbfd88262cde0fbf71eaf6655103519368faed..f314936b54622d1c3b2228de56ead3f1453e2545 100644 (file)
@@ -1449,7 +1449,8 @@ static long zcrypt_unlocked_ioctl(struct file *filp, unsigned int cmd,
                if (!reqcnt)
                        return -ENOMEM;
                zcrypt_perdev_reqcnt(reqcnt, AP_DEVICES);
-               if (copy_to_user((int __user *) arg, reqcnt, sizeof(reqcnt)))
+               if (copy_to_user((int __user *) arg, reqcnt,
+                                sizeof(u32) * AP_DEVICES))
                        rc = -EFAULT;
                kfree(reqcnt);
                return rc;