]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
s390/zcrypt: Close speculative mem read possibility
authorHarald Freudenberger <freude@linux.ibm.com>
Thu, 23 Jul 2026 09:54:53 +0000 (11:54 +0200)
committerVasily Gorbik <gor@linux.ibm.com>
Fri, 31 Jul 2026 11:31:19 +0000 (13:31 +0200)
The domain value is extracted from a given CCA or EP11 ioctl struct
when a CPRB is about to be sent. Thus this is a user controlled value.
Under some special conditions (custom device node used, administrative
load) this value is used as an array index after bounds checking, but
without speculation barrier.

Add the missing array_index_nospec() call to prevent speculative
execution where this domain value is used.

Fixes: cfd68b33094e ("s390/zcrypt: Filter admin CPRBs on custom devices")
Cc: stable@vger.kernel.org
Reported-by: Christian Borntraeger <borntraeger@linux.ibm.com>
Reviewed-by: Finn Callies <fcallies@linux.ibm.com>
Signed-off-by: Harald Freudenberger <freude@linux.ibm.com>
Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
drivers/s390/crypto/zcrypt_api.c

index 81eefdeae248599b3819e636547525381f6b0a93..ec6a4c2f9f04a77977aa9f987c1e7c10f8f8e418 100644 (file)
@@ -879,6 +879,7 @@ static long _zcrypt_send_cprb(u32 xflags, struct ap_perms *perms,
 
        if (perms != &ap_perms && domain < AP_DOMAINS) {
                if (ap_msg.flags & AP_MSG_FLAG_ADMIN) {
+                       domain = array_index_nospec(domain, AP_DOMAINS);
                        if (!test_bit_inv(domain, perms->adm)) {
                                rc = -ENODEV;
                                goto out;
@@ -1079,6 +1080,7 @@ static long _zcrypt_send_ep11_cprb(u32 xflags, struct ap_perms *perms,
 
        if (perms != &ap_perms && domain < AP_DOMAINS) {
                if (ap_msg.flags & AP_MSG_FLAG_ADMIN) {
+                       domain = array_index_nospec(domain, AP_DOMAINS);
                        if (!test_bit_inv(domain, perms->adm)) {
                                rc = -ENODEV;
                                goto out;