Skip to content

Commit 3719114

Browse files
committed
Merge tag 's390-7.0-7' of git://git.kernel.org/pub/scm/linux/kernel/git/s390/linux
Pull s390 fixes from Vasily Gorbik: - Fix a memory leak in the zcrypt driver where the AP message buffer for clear key RSA requests was allocated twice, once by the caller and again locally, causing the first allocation to never be freed - Fix the cpum_sf perf sampling rate overflow adjustment to clamp the recalculated rate to the hardware maximum, preventing exceptions on heavily loaded systems running with HZ=1000 * tag 's390-7.0-7' of git://git.kernel.org/pub/scm/linux/kernel/git/s390/linux: s390/zcrypt: Fix memory leak with CCA cards used as accelerator s390/cpum_sf: Cap sampling rate to prevent lsctl exception
2 parents 1523e4d + c8d46f1 commit 3719114

2 files changed

Lines changed: 19 additions & 19 deletions

File tree

arch/s390/kernel/perf_cpum_sf.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1168,6 +1168,7 @@ static void hw_collect_samples(struct perf_event *event, unsigned long *sdbt,
11681168
static void hw_perf_event_update(struct perf_event *event, int flush_all)
11691169
{
11701170
unsigned long long event_overflow, sampl_overflow, num_sdb;
1171+
struct cpu_hw_sf *cpuhw = this_cpu_ptr(&cpu_hw_sf);
11711172
struct hw_perf_event *hwc = &event->hw;
11721173
union hws_trailer_header prev, new;
11731174
struct hws_trailer_entry *te;
@@ -1247,8 +1248,11 @@ static void hw_perf_event_update(struct perf_event *event, int flush_all)
12471248
* are dropped.
12481249
* Slightly increase the interval to avoid hitting this limit.
12491250
*/
1250-
if (event_overflow)
1251+
if (event_overflow) {
12511252
SAMPL_RATE(hwc) += DIV_ROUND_UP(SAMPL_RATE(hwc), 10);
1253+
if (SAMPL_RATE(hwc) > cpuhw->qsi.max_sampl_rate)
1254+
SAMPL_RATE(hwc) = cpuhw->qsi.max_sampl_rate;
1255+
}
12521256
}
12531257

12541258
static inline unsigned long aux_sdb_index(struct aux_buffer *aux,

drivers/s390/crypto/zcrypt_msgtype6.c

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -953,6 +953,10 @@ static atomic_t zcrypt_step = ATOMIC_INIT(0);
953953
/*
954954
* The request distributor calls this function if it picked the CEXxC
955955
* device to handle a modexpo request.
956+
* This function assumes that ap_msg has been initialized with
957+
* ap_init_apmsg() and thus a valid buffer with the size of
958+
* ap_msg->bufsize is available within ap_msg. Also the caller has
959+
* to make sure ap_release_apmsg() is always called even on failure.
956960
* @zq: pointer to zcrypt_queue structure that identifies the
957961
* CEXxC device to the request distributor
958962
* @mex: pointer to the modexpo request buffer
@@ -964,21 +968,17 @@ static long zcrypt_msgtype6_modexpo(struct zcrypt_queue *zq,
964968
struct ap_response_type *resp_type = &ap_msg->response;
965969
int rc;
966970

967-
ap_msg->msg = (void *)get_zeroed_page(GFP_KERNEL);
968-
if (!ap_msg->msg)
969-
return -ENOMEM;
970-
ap_msg->bufsize = PAGE_SIZE;
971971
ap_msg->receive = zcrypt_msgtype6_receive;
972972
ap_msg->psmid = (((unsigned long)current->pid) << 32) +
973973
atomic_inc_return(&zcrypt_step);
974974
rc = icamex_msg_to_type6mex_msgx(zq, ap_msg, mex);
975975
if (rc)
976-
goto out_free;
976+
goto out;
977977
resp_type->type = CEXXC_RESPONSE_TYPE_ICA;
978978
init_completion(&resp_type->work);
979979
rc = ap_queue_message(zq->queue, ap_msg);
980980
if (rc)
981-
goto out_free;
981+
goto out;
982982
rc = wait_for_completion_interruptible(&resp_type->work);
983983
if (rc == 0) {
984984
rc = ap_msg->rc;
@@ -991,15 +991,17 @@ static long zcrypt_msgtype6_modexpo(struct zcrypt_queue *zq,
991991
ap_cancel_message(zq->queue, ap_msg);
992992
}
993993

994-
out_free:
995-
free_page((unsigned long)ap_msg->msg);
996-
ap_msg->msg = NULL;
994+
out:
997995
return rc;
998996
}
999997

1000998
/*
1001999
* The request distributor calls this function if it picked the CEXxC
10021000
* device to handle a modexpo_crt request.
1001+
* This function assumes that ap_msg has been initialized with
1002+
* ap_init_apmsg() and thus a valid buffer with the size of
1003+
* ap_msg->bufsize is available within ap_msg. Also the caller has
1004+
* to make sure ap_release_apmsg() is always called even on failure.
10031005
* @zq: pointer to zcrypt_queue structure that identifies the
10041006
* CEXxC device to the request distributor
10051007
* @crt: pointer to the modexpoc_crt request buffer
@@ -1011,21 +1013,17 @@ static long zcrypt_msgtype6_modexpo_crt(struct zcrypt_queue *zq,
10111013
struct ap_response_type *resp_type = &ap_msg->response;
10121014
int rc;
10131015

1014-
ap_msg->msg = (void *)get_zeroed_page(GFP_KERNEL);
1015-
if (!ap_msg->msg)
1016-
return -ENOMEM;
1017-
ap_msg->bufsize = PAGE_SIZE;
10181016
ap_msg->receive = zcrypt_msgtype6_receive;
10191017
ap_msg->psmid = (((unsigned long)current->pid) << 32) +
10201018
atomic_inc_return(&zcrypt_step);
10211019
rc = icacrt_msg_to_type6crt_msgx(zq, ap_msg, crt);
10221020
if (rc)
1023-
goto out_free;
1021+
goto out;
10241022
resp_type->type = CEXXC_RESPONSE_TYPE_ICA;
10251023
init_completion(&resp_type->work);
10261024
rc = ap_queue_message(zq->queue, ap_msg);
10271025
if (rc)
1028-
goto out_free;
1026+
goto out;
10291027
rc = wait_for_completion_interruptible(&resp_type->work);
10301028
if (rc == 0) {
10311029
rc = ap_msg->rc;
@@ -1038,9 +1036,7 @@ static long zcrypt_msgtype6_modexpo_crt(struct zcrypt_queue *zq,
10381036
ap_cancel_message(zq->queue, ap_msg);
10391037
}
10401038

1041-
out_free:
1042-
free_page((unsigned long)ap_msg->msg);
1043-
ap_msg->msg = NULL;
1039+
out:
10441040
return rc;
10451041
}
10461042

0 commit comments

Comments
 (0)