aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSuren Baghdasaryan <surenb@google.com>2018-05-04 00:08:54 +0530
committerSamuel Ortiz <sameo@linux.intel.com>2018-06-08 22:37:12 -0400
commit761e37b71e26de04de744794ef7155d41a78a8dd (patch)
treecb165334a026d476a4a531b1a2c9ac522abe4e3a
parent48badd41fbfd803331dc8796cbb12b826a6446b9 (diff)
downloadnfc-next-761e37b71e26de04de744794ef7155d41a78a8dd.tar.gz
NFC: Fix possible memory corruption when handling SHDLC I-Frame commands
When handling SHDLC I-Frame commands "pipe" field used for indexing into an array should be checked before usage. If left unchecked it might access memory outside of the array of size NFC_HCI_MAX_PIPES(127). cc: Stable <stable@vger.kernel.org> Signed-off-by: Suren Baghdasaryan <surenb@google.com> Signed-off-by: Amit Pundir <amit.pundir@linaro.org> Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
-rw-r--r--net/nfc/hci/core.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/net/nfc/hci/core.c b/net/nfc/hci/core.c
index ac8030c4bcf863..19cb2e473ea607 100644
--- a/net/nfc/hci/core.c
+++ b/net/nfc/hci/core.c
@@ -209,6 +209,11 @@ void nfc_hci_cmd_received(struct nfc_hci_dev *hdev, u8 pipe, u8 cmd,
}
create_info = (struct hci_create_pipe_resp *)skb->data;
+ if (create_info->pipe >= NFC_HCI_MAX_PIPES) {
+ status = NFC_HCI_ANY_E_NOK;
+ goto exit;
+ }
+
/* Save the new created pipe and bind with local gate,
* the description for skb->data[3] is destination gate id
* but since we received this cmd from host controller, we
@@ -232,6 +237,11 @@ void nfc_hci_cmd_received(struct nfc_hci_dev *hdev, u8 pipe, u8 cmd,
}
delete_info = (struct hci_delete_pipe_noti *)skb->data;
+ if (delete_info->pipe >= NFC_HCI_MAX_PIPES) {
+ status = NFC_HCI_ANY_E_NOK;
+ goto exit;
+ }
+
hdev->pipes[delete_info->pipe].gate = NFC_HCI_INVALID_GATE;
hdev->pipes[delete_info->pipe].dest_host = NFC_HCI_INVALID_HOST;
break;