android_kernel_samsung_sm8650/drivers/s390/crypto
Harald Freudenberger 25cb64ecc3 s390/zcrypt: do not retry administrative requests
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>
2023-07-23 13:49:35 +02:00
..
ap_bus.c s390/ap: fix memory leak in ap_init_qci_info() 2022-11-23 16:26:21 +01:00
ap_bus.h s390/ap: fix crash on older machines based on QCI info missing 2022-08-15 17:19:52 +02:00
ap_card.c
ap_debug.h
ap_queue.c vfio/ap: Pass in physical address of ind to ap_aqic() 2022-07-23 07:29:10 -06:00
Makefile
pkey_api.c s390/pkey: zeroize key blobs 2023-06-09 10:34:13 +02:00
vfio_ap_debug.h
vfio_ap_drv.c s390/vfio-ap: fix memory leak in vfio_ap device driver 2023-04-06 12:10:46 +02:00
vfio_ap_ops.c s390: vfio-ap: tighten the NIB validity check 2023-03-10 09:33:02 +01:00
vfio_ap_private.h s390/vfio-ap: Fix memory allocation for mdev_types array 2022-10-26 14:47:31 +02:00
zcrypt_api.c
zcrypt_api.h
zcrypt_card.c
zcrypt_cca_key.h
zcrypt_ccamisc.c
zcrypt_ccamisc.h
zcrypt_cex2a.c
zcrypt_cex2a.h
zcrypt_cex2c.c
zcrypt_cex2c.h
zcrypt_cex4.c
zcrypt_cex4.h
zcrypt_debug.h
zcrypt_ep11misc.c
zcrypt_ep11misc.h
zcrypt_error.h
zcrypt_msgtype6.c s390/zcrypt: do not retry administrative requests 2023-07-23 13:49:35 +02:00
zcrypt_msgtype6.h
zcrypt_msgtype50.c
zcrypt_msgtype50.h
zcrypt_queue.c