Received: by 10.192.165.148 with SMTP id m20csp915133imm; Wed, 2 May 2018 10:49:31 -0700 (PDT) X-Google-Smtp-Source: AB8JxZreo2qrYaGw+Wg1+YPYLbL/6Eg49d0rFXFv5CEAZ31sdR6ARBZKLlUS6NkSgGtWt1Fe7LLg X-Received: by 2002:a63:5ec5:: with SMTP id s188-v6mr16837487pgb.21.1525283371567; Wed, 02 May 2018 10:49:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525283371; cv=none; d=google.com; s=arc-20160816; b=Fx+okqp6h81KIUw1YcEtli3WDF1LQ3/bXoWl+tjeBU5GIhIVc0mEIbC22CYbelC+i3 Tcw15Ws2Z0FiUY4+f6219p+8wJFdBxjpJ6tJReT06bVQYpswgFbwZPn2CxWHjXoMtPdJ AWk/mMTZyiT6nZS4I3DjnxLG2ommpXR3269iLzHczmQyyNyVHAG0sQnqHQGTJYxkif9M nqhI2PNGZ0uM7altH3MUogjD9F16buoA4PdtuTBl86A4VGcdiXvpYJ0hSeKWGZZMSJnu 3QN2m44O7FIORxJe09CLrT0QiYjX17pD798dWfNXrre43WaFlako4r7Oi+p+fvBO3vd8 j50A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=z47AkYrZrCYwdJHLcba161nVjfCLWE0I/WK1pjwAC5w=; b=IQ8+z262xFstmMYdcSq5KPQoaMDS+f/l1pUhLQAfssB/q3ejZOzVqUShkXkJyuqLo4 pkMPLKGJD6SgONCj2F549Sd1sfSrQktcfQvPOm1VMnUPzdN5Bew/L/lX+v9sgfMGuSCl HevSsejRBVEMxgvaph+9OsvbvwgtG2Z/1nY1pt7D0mPEFXoBQ0gb8wpFrM6lAdr1Dajn qq9kF7bEbunQCCbOHm7VvouEoi0q5cDbouR/H0zlcBLkfFNCbwSy5LNS+uOnvSKGaiRS H4lphs+iOKu673OWAxrviEFNDbasGrwuBxWgXP0c0rgXAn06VXbN1k4S8JDE7UeJKvbd oXsA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=djnVsbdS; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x7-v6si9775344pgb.300.2018.05.02.10.49.17; Wed, 02 May 2018 10:49:31 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=djnVsbdS; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751839AbeEBRs3 (ORCPT + 99 others); Wed, 2 May 2018 13:48:29 -0400 Received: from mail-pf0-f195.google.com ([209.85.192.195]:37087 "EHLO mail-pf0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751790AbeEBRsY (ORCPT ); Wed, 2 May 2018 13:48:24 -0400 Received: by mail-pf0-f195.google.com with SMTP id e9so8414267pfi.4 for ; Wed, 02 May 2018 10:48:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=z47AkYrZrCYwdJHLcba161nVjfCLWE0I/WK1pjwAC5w=; b=djnVsbdSHiXGUI3L7k1vTen67hc4ydsopoxbcg5aQKFjpdYkrA6wF/G7pDJv88/jiA Jd/fSkRFJkDMfOL3UfvlcdDTg1QbVWKrk2qQpvvymDRSCiezYRUhQga+zD6lsJTMPn/J 8+0KzoKrC8aX632RAIikX1mXP2/vNtogb59YE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=z47AkYrZrCYwdJHLcba161nVjfCLWE0I/WK1pjwAC5w=; b=R11s5xNAeajtnpua/OgDOYCjrykwOvyIYY8KSiEBtS5nYdLkE6B6U+OzHpoorRhA6m vfTmjXwXw8fAlMZq1p1APBytT0mV+V0FC335OZRWhOfbmIVdEAnq9I7LIS5Q++0VBtN3 KYkxOmrvPi62TB3UqkqRYKMn2E0E9mpzOrJIZLQVbYkrcbkngLwinPBTiY7Y4+O3n1va BSMKC5p34aZpkb1YstHRWvHfUQyGFsHLOHzkRbJu0dg1pjHuxIFFVYmU+YQC1Tbj01aq FZvXzbn5pfhIrH9BbL4BvVwhBp/+kn7cc+JlJnbApZzbwp+UXq5KT+UDE2zB8sZPFBgb 4ukw== X-Gm-Message-State: ALQs6tBBWOAyxrJtdM7Y7MTS1//fTk3pShTAneIjug0wKqEtEbsNN7aa ++vmuoiKpfGV98bfeuXJcvw88bwBMlQ= X-Received: by 2002:a17:902:2826:: with SMTP id e35-v6mr20947133plb.348.1525283303179; Wed, 02 May 2018 10:48:23 -0700 (PDT) Received: from localhost.localdomain ([106.51.17.226]) by smtp.gmail.com with ESMTPSA id l19-v6sm19179875pgn.44.2018.05.02.10.48.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 02 May 2018 10:48:22 -0700 (PDT) From: Amit Pundir To: lkml , linux-wireless@vger.kernel.org Cc: Suren Baghdasaryan , Samuel Ortiz , Christophe Ricard , Andy Shevchenko , Greg KH , John Stultz , Dmitry Shmidt , Todd Kjos , Android Kernel Team Subject: [PATCH v2 2/3] NFC: Fix possible memory corruption when handling SHDLC I-Frame commands Date: Wed, 2 May 2018 23:18:07 +0530 Message-Id: <1525283288-7027-3-git-send-email-amit.pundir@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1525283288-7027-1-git-send-email-amit.pundir@linaro.org> References: <1525283288-7027-1-git-send-email-amit.pundir@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Suren Baghdasaryan 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). Signed-off-by: Suren Baghdasaryan Signed-off-by: Amit Pundir --- v2: Resend. No changes. net/nfc/hci/core.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/net/nfc/hci/core.c b/net/nfc/hci/core.c index ac8030c4..19cb2e4 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; -- 2.7.4