]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
s390/zcrypt: do not retry administrative requests
authorHarald Freudenberger <freude@linux.ibm.com>
Mon, 12 Jun 2023 09:13:39 +0000 (11:13 +0200)
committerRoxana Nicolescu <roxana.nicolescu@canonical.com>
Mon, 2 Oct 2023 15:20:18 +0000 (17:20 +0200)
BugLink: https://bugs.launchpad.net/bugs/2036075
commit af40322e90d4e0093569eceb7d3a28ab635f3e75 upstream.

All kind of administrative requests should not been retried. Some card
firmware detects this and assumes a replay attack. This patch checks
on failure if the low level functions indicate a retry (EAGAIN) and
checks for the ADMIN flag set on the request message.  If this both
are true, the response code for this message is changed to EIO to make
sure the zcrypt API layer does not attempt to retry the request. As of
now the ADMIN flag is set for a request message when
- for EP11 the field 'flags' of the EP11 CPRB struct has the leftmost
  bit set.
- for CCA when the CPRB minor version is 'T3', 'T5', 'T6' or 'T7'.

Please note that the do-not-retry only applies to a request
which has been sent to the card (= has been successfully enqueued) but
the reply indicates some kind of failure and by default it would be
replied. It is totally fine to retry a request if a previous attempt
to enqueue the msg into the firmware queue had some kind of failure
and thus the card has never seen this request.

Reported-by: Frank Uhlig <Frank.Uhlig1@ibm.com>
Signed-off-by: Harald Freudenberger <freude@linux.ibm.com>
Reviewed-by: Holger Dengler <dengler@linux.ibm.com>
Cc: stable@vger.kernel.org
Signed-off-by: Alexander Gordeev <agordeev@linux.ibm.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
drivers/s390/crypto/zcrypt_msgtype6.c

index 5ad25147759311029e555168fdcc2acc7fb2977e..f99a9ef42116f8e18defcd947c78045198c829c0 100644 (file)
@@ -1188,6 +1188,9 @@ static long zcrypt_msgtype6_send_cprb(bool userspace, struct zcrypt_queue *zq,
                ap_cancel_message(zq->queue, ap_msg);
        }
 
+       if (rc == -EAGAIN && ap_msg->flags & AP_MSG_FLAG_ADMIN)
+               rc = -EIO; /* do not retry administrative requests */
+
 out:
        if (rc)
                ZCRYPT_DBF_DBG("%s send cprb at dev=%02x.%04x rc=%d\n",
@@ -1308,6 +1311,9 @@ static long zcrypt_msgtype6_send_ep11_cprb(bool userspace, struct zcrypt_queue *
                ap_cancel_message(zq->queue, ap_msg);
        }
 
+       if (rc == -EAGAIN && ap_msg->flags & AP_MSG_FLAG_ADMIN)
+               rc = -EIO; /* do not retry administrative requests */
+
 out:
        if (rc)
                ZCRYPT_DBF_DBG("%s send cprb at dev=%02x.%04x rc=%d\n",