Received: by 10.192.165.148 with SMTP id m20csp2176758imm; Thu, 3 May 2018 11:40:27 -0700 (PDT) X-Google-Smtp-Source: AB8JxZoY/LVZ5yFTVFF5IsxYhQ+KJOU6e+zpms1sOuQCo7TjV9HLG3z3cTYeR+giTBl9IeWdukoZ X-Received: by 2002:a17:902:5ac1:: with SMTP id g1-v6mr24958718plm.43.1525372827338; Thu, 03 May 2018 11:40:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525372827; cv=none; d=google.com; s=arc-20160816; b=KbBWboRlTmVMQY0ycZNZjPh4xF4gr7fOmmY0q7z//Ub0wgYWVIRVAGij/eax4xrIuE 8jBxUP08ovhzH+fZVnA/Btk+90mtO2BqD2tWBcf7yEFLd8Oqu9zxxMCMlb1zdCHh+PIZ j4JEbV73uu+o6ZlIx4uFdxZoU5VtozLMv/WRHp8k6Opq5vUzahJd1vtTbhpIt0gILAbl zKz9ihKt9qPYmS3tfCy31ZSkkIr5oETxFASUm/h0GF1KE/gMbYNB9JNXCR7QpoTQABfZ sGepzZp5R636tZ3L4/SwH+qSC4dyJsrYssZKSwLVXtsVurxmx4eJxuYB3l9S7QZX6m5Q 7Yfg== 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=bQVjZYBsVQrcd9EmtkKcL4YPUtSEKCns/vDF2NvsVJQ=; b=RUXbQlGX7Egfln6F0IheeK+uPU1pSscAaJSYR0b2H+7kgLvuJXQ7aHrk4LVrgQjoTV XNNXVgLiQ5LxFMvxjULcNdO7C1a4sg3LxV+FYCk3+e+7Pv3MWjgneICUQWjc7Bl55LlN 2gzuUgLMT5kQlN6DQjpefT+3xKNV9D9GOyu+8Xqn0LhXxkJD0n6McMnCAP0m6z7/LviA NV9Bt6LoYmojBrKyRjuC/cpOXFCuLqon+WadVA+aHtWBJkC7Gb/zNLvyMPQKsSaUO3l1 3+ZGDWqktNbDeop59O1wJdw+C3uxGNhVhcKDK1t4/AvJ46yL2YQb0wTUEVv/jVpiKGNh MGMQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=jsWz82eU; 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 f186si14536140pfg.191.2018.05.03.11.40.13; Thu, 03 May 2018 11:40:27 -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=jsWz82eU; 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 S1751351AbeECSjO (ORCPT + 99 others); Thu, 3 May 2018 14:39:14 -0400 Received: from mail-pf0-f196.google.com ([209.85.192.196]:35154 "EHLO mail-pf0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751302AbeECSjH (ORCPT ); Thu, 3 May 2018 14:39:07 -0400 Received: by mail-pf0-f196.google.com with SMTP id j5so15417477pfh.2 for ; Thu, 03 May 2018 11:39:07 -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=bQVjZYBsVQrcd9EmtkKcL4YPUtSEKCns/vDF2NvsVJQ=; b=jsWz82eU07D0js9tGZjzfSYBz0kk5wGoEsNWOGQRAEVcwds7vuBdCM11sMleD4uvB+ kTrNPCy+FoW9ddgFGMsBZ9eXJBJcEq3CCdrHFVQbL8KigRt6lMw7EzaXUbf8BmBfah65 1FIJeyL8v5qks4/dUArzGWp9SsNPiENuKPCwE= 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=bQVjZYBsVQrcd9EmtkKcL4YPUtSEKCns/vDF2NvsVJQ=; b=EHx8c0hhGg9JzqzRriqrnXUak49uYB6Xro1Dqbce8Lhq0khsgGIcfKd5r4LhMy6EGC TUSQG7IS72KeDUP/W8FVVE2yktchWyqHPyk75iHvHwESahHghaTP8B0GxST2rblUlVoo IFrUiZN/6ZJT1XV1NlSBdk2Wu/Hr/JXPeBdwbUf5Z24GLfWxsrOWAv51d8PDc7opFiWf sukOdIIJUqut4ayCJISdcxSBQc+hmVdkW7UGStjFj0ps3ZdiacGEAHecnFkNPQnB1V0S vD51rBiMuFo+rlMo8GKK2u8TvEPdij5uPGr2MeqJfpup6hGCMJDhuRR8NF+JCtM62f4T pCzQ== X-Gm-Message-State: ALQs6tD9D17uAe3c5T5pyHxLV9WKH9RvlEYer2H+TkriMmLXarfjVfzT mf3acx5tuxUA2cWjL0k/GvAz10YH3q8= X-Received: by 2002:a17:902:700a:: with SMTP id y10-v6mr25151894plk.265.1525372746484; Thu, 03 May 2018 11:39:06 -0700 (PDT) Received: from localhost.localdomain ([106.51.17.226]) by smtp.gmail.com with ESMTPSA id o5-v6sm4130786pgv.47.2018.05.03.11.39.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 03 May 2018 11:39:05 -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 , Stable Subject: [PATCH v3 2/4] NFC: Fix possible memory corruption when handling SHDLC I-Frame commands Date: Fri, 4 May 2018 00:08:54 +0530 Message-Id: <1525372736-25094-2-git-send-email-amit.pundir@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1525372736-25094-1-git-send-email-amit.pundir@linaro.org> References: <1525372736-25094-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). cc: Stable Signed-off-by: Suren Baghdasaryan Signed-off-by: Amit Pundir Reviewed-by: Andy Shevchenko --- v3..v1: 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 ac8030c4bcf8..19cb2e473ea6 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