OSDN Git Service

diag: Validate query dci event and log mask size properly
authorHardik Arya <harya@codeaurora.org>
Fri, 6 Apr 2018 09:40:36 +0000 (15:10 +0530)
committerGerrit - the friendly Code Review server <code-review@localhost>
Wed, 25 Apr 2018 15:43:24 +0000 (08:43 -0700)
Currently there is possibility of out-of-bound read due to
incorrect validation of received dci event and log mask for
query. The patch update the validation for the same.

Change-Id: I4266eb0f69fdbfa48c5aacc17744dec83995e9e6
Signed-off-by: Hardik Arya <harya@codeaurora.org>
drivers/char/diag/diag_dci.c

index 16ff781..b0b36d0 100644 (file)
@@ -689,7 +689,7 @@ int diag_dci_query_log_mask(struct diag_dci_client_tbl *entry,
        byte_mask = 0x01 << (item_num % 8);
        offset = equip_id * 514;
 
-       if (offset + byte_index > DCI_LOG_MASK_SIZE) {
+       if (offset + byte_index >= DCI_LOG_MASK_SIZE) {
                pr_err("diag: In %s, invalid offset: %d, log_code: %d, byte_index: %d\n",
                                __func__, offset, log_code, byte_index);
                return 0;
@@ -716,7 +716,7 @@ int diag_dci_query_event_mask(struct diag_dci_client_tbl *entry,
        bit_index = event_id % 8;
        byte_mask = 0x1 << bit_index;
 
-       if (byte_index > DCI_EVENT_MASK_SIZE) {
+       if (byte_index >= DCI_EVENT_MASK_SIZE) {
                pr_err("diag: In %s, invalid, event_id: %d, byte_index: %d\n",
                                __func__, event_id, byte_index);
                return 0;