s390/zcrypt: fix card and queue total counter wrap
The internal statistic counters for the total number of requests processed per card and per queue used integers. So they do wrap after a rather huge amount of crypto requests processed. This patch introduces uint64 counters which should hold much longer but still may wrap. The sysfs attributes request_count for card and queue also used only %ld and now display the counter value with %llu. This is not a security relevant fix. The int overflow which happened is not in any way exploitable as a security breach. Signed-off-by: Harald Freudenberger <freude@linux.ibm.com> Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
This commit is contained in:

committed by
Vasily Gorbik

parent
aab73d278d
commit
fcd98d4002
@@ -479,12 +479,12 @@ static ssize_t request_count_show(struct device *dev,
|
||||
char *buf)
|
||||
{
|
||||
struct ap_queue *aq = to_ap_queue(dev);
|
||||
unsigned int req_cnt;
|
||||
u64 req_cnt;
|
||||
|
||||
spin_lock_bh(&aq->lock);
|
||||
req_cnt = aq->total_request_count;
|
||||
spin_unlock_bh(&aq->lock);
|
||||
return snprintf(buf, PAGE_SIZE, "%d\n", req_cnt);
|
||||
return snprintf(buf, PAGE_SIZE, "%llu\n", req_cnt);
|
||||
}
|
||||
|
||||
static ssize_t request_count_store(struct device *dev,
|
||||
@@ -676,7 +676,7 @@ void ap_queue_message(struct ap_queue *aq, struct ap_message *ap_msg)
|
||||
list_add_tail(&ap_msg->list, &aq->requestq);
|
||||
aq->requestq_count++;
|
||||
aq->total_request_count++;
|
||||
atomic_inc(&aq->card->total_request_count);
|
||||
atomic64_inc(&aq->card->total_request_count);
|
||||
/* Send/receive as many request from the queue as possible. */
|
||||
ap_wait(ap_sm_event_loop(aq, AP_EVENT_POLL));
|
||||
spin_unlock_bh(&aq->lock);
|
||||
|
Reference in New Issue
Block a user