Skip to content

Commit cfd68b3

Browse files
juergenchristVasily Gorbik
authored andcommitted
s390/zcrypt: Filter admin CPRBs on custom devices
Add a filter for custom devices to check for allowed control domains of admin CPRBs. This filter only applies to custom devices and not to the main device. Signed-off-by: Juergen Christ <jchrist@linux.ibm.com> Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
1 parent 895ae58 commit cfd68b3

1 file changed

Lines changed: 24 additions & 1 deletion

File tree

drivers/s390/crypto/zcrypt_api.c

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -923,11 +923,22 @@ static long _zcrypt_send_cprb(bool userspace, struct ap_perms *perms,
923923
if (rc)
924924
goto out;
925925

926+
tdom = *domain;
927+
if (perms != &ap_perms && tdom < AP_DOMAINS) {
928+
if (ap_msg.flags & AP_MSG_FLAG_ADMIN) {
929+
if (!test_bit_inv(tdom, perms->adm)) {
930+
rc = -ENODEV;
931+
goto out;
932+
}
933+
} else if ((ap_msg.flags & AP_MSG_FLAG_USAGE) == 0) {
934+
rc = -EOPNOTSUPP;
935+
goto out;
936+
}
937+
}
926938
/*
927939
* If a valid target domain is set and this domain is NOT a usage
928940
* domain but a control only domain, autoselect target domain.
929941
*/
930-
tdom = *domain;
931942
if (tdom < AP_DOMAINS &&
932943
!ap_test_config_usage_domain(tdom) &&
933944
ap_test_config_ctrl_domain(tdom))
@@ -1105,6 +1116,18 @@ static long _zcrypt_send_ep11_cprb(bool userspace, struct ap_perms *perms,
11051116
if (rc)
11061117
goto out_free;
11071118

1119+
if (perms != &ap_perms && domain < AUTOSEL_DOM) {
1120+
if (ap_msg.flags & AP_MSG_FLAG_ADMIN) {
1121+
if (!test_bit_inv(domain, perms->adm)) {
1122+
rc = -ENODEV;
1123+
goto out_free;
1124+
}
1125+
} else if ((ap_msg.flags & AP_MSG_FLAG_USAGE) == 0) {
1126+
rc = -EOPNOTSUPP;
1127+
goto out_free;
1128+
}
1129+
}
1130+
11081131
pref_zc = NULL;
11091132
pref_zq = NULL;
11101133
spin_lock(&zcrypt_list_lock);

0 commit comments

Comments
 (0)