Received: by 10.192.165.148 with SMTP id m20csp2176057imm; Thu, 3 May 2018 11:39:36 -0700 (PDT) X-Google-Smtp-Source: AB8JxZp/pB0UmuUVuo+b/RBHUxopDrqLBUH/UYixuFZuClZcB0mTvlV3xY2l26gc0ydofwG/oWMe X-Received: by 10.98.106.10 with SMTP id f10mr23631874pfc.99.1525372776830; Thu, 03 May 2018 11:39:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525372776; cv=none; d=google.com; s=arc-20160816; b=dcgPkbTRmcR5uEs7eAyxB5JXp/kgXItIZgzPwWmS7J7M23zDXGJrQ2ATIvi64uGOuM 8CipfPDkMBriWMEms5jvruUDULc5HMK8AEX3a06WviuJwIG2uKXsY0uAbJpIE3KnTVDo WRsNbodkjDm88ZNq2GCFG4nS+IZ5lp3LWCbVewfoVuDhpCU50mER1+3SLFMiZ7m9HHYY J7yGrmkPQPgOmwAbRXbakZa+iy5NT2yqQZPJ8YCOfWQ1sNJ1yFopROYigsC2yBoSFm5k P0r1BsMixChEL67ifWNuI5UVLCsMLBr8tJA1FNVrDj6CWr+3bHaQ5+dbMpansEgXGces hbPA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=aZuHMnS8HoYQvymWT9toB6eMu7hXaR3HCblMyZn8Yd8=; b=ZVMwLuvF2XXsMtPgMfpG0bGoGwnCmrh+oThN4oQK5dCzCwCx/kAHJ5P4w3jpfCWGtI wgwozH7mzq2uMZw60s5lkUZgFM2o6qbaq6Uc41tDsZuJJcdBSHiS3M1oRl+uayvtFS7W QXs3XhPx75x4+64K/w5m45aan35kNgJMAdptM+B8g4cPWfhGBru8xEt2bk8EYGczh2Ln wIDVznDwo8qO1O7SYv0NhmWWgqghXUk6Ov3U3ExzrGbhlNlbEtl9R1rKedBwgIbZC3O3 CPwdShg+BR9WDw+hmKM3dS2izb4THzo8Sv21FZxOa3jWFCVXztUSxQWS3M53czHxCqo+ 6dtA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=AFrJSQ3g; 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 e14-v6si528495pgv.516.2018.05.03.11.39.22; Thu, 03 May 2018 11:39:36 -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=AFrJSQ3g; 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 S1751279AbeECSjF (ORCPT + 99 others); Thu, 3 May 2018 14:39:05 -0400 Received: from mail-pf0-f196.google.com ([209.85.192.196]:42681 "EHLO mail-pf0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751140AbeECSjD (ORCPT ); Thu, 3 May 2018 14:39:03 -0400 Received: by mail-pf0-f196.google.com with SMTP id p14so4026552pfh.9 for ; Thu, 03 May 2018 11:39:03 -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; bh=aZuHMnS8HoYQvymWT9toB6eMu7hXaR3HCblMyZn8Yd8=; b=AFrJSQ3g/0LEig40pCkgJBvQ97ub/yxdTMQMssKjZx4DN79hEkvqrCPpcVw2T3eq3Q Ef2wkiYwai7EzotwNhm+0x5YUoU3IfrQBWITitILNDFgEkKQc3sXu50p6NO98ohP//gS D/is42CRiBelk8q9v9w7SDdvZ2ML+xbPlT/Fo= 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; bh=aZuHMnS8HoYQvymWT9toB6eMu7hXaR3HCblMyZn8Yd8=; b=G2TEqCkLKUwV5GhaBaQ/JjxgDssINC+1+B9K5iSXtl84zl18p/H9oOHKXNVxvph0jc AaWGTLFLbj/DuY3YpA/Cv7L3XKuCK0BeCL0pCo6g9DJX4SpQlaxaBUQVlHWJlm3kVBuT 3BlKbIfoDVGaTwiUCs+/9WVKBYtoqPaMn/OuJkN/niYIPXiTrTUtZGljmXxGdFDR8pLJ lzeOtRREi0w6/PXbWQOBSEBQXsNaQ7GVYHWYzYg2RpPfWX2hg3Un63ivN8LmZwGqzX4c w8bEfZLVrKaeXR5YTmcl191iqK9iq/mpWO6VBMtvEd8OZfoLi1n/yW9NaHEjET3ckFis 7MOQ== X-Gm-Message-State: ALQs6tDD5wuq9Zr9Zusl7hBVUOqUBJUVb66fMv3KTiRVSo9p1wbts1Ac EYJiYPvYXYXAExGk+O5CfIGO12B1CmA= X-Received: by 2002:a63:5ec5:: with SMTP id s188-v6mr20021730pgb.21.1525372742210; Thu, 03 May 2018 11:39:02 -0700 (PDT) Received: from localhost.localdomain ([106.51.17.226]) by smtp.gmail.com with ESMTPSA id o5-v6sm4130786pgv.47.2018.05.03.11.38.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 03 May 2018 11:39:01 -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 1/4] NFC: st21nfca: Fix out of bounds kernel access when handling ATR_REQ Date: Fri, 4 May 2018 00:08:53 +0530 Message-Id: <1525372736-25094-1-git-send-email-amit.pundir@linaro.org> X-Mailer: git-send-email 2.7.4 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Suren Baghdasaryan Out of bounds kernel accesses in st21nfca's NFC HCI layer might happen when handling ATR_REQ events if user-specified atr_req->length is bigger than the buffer size. In that case memcpy() inside st21nfca_tm_send_atr_res() will read extra bytes resulting in OOB read from the kernel heap. cc: Stable Signed-off-by: Suren Baghdasaryan Signed-off-by: Amit Pundir Reviewed-by: Andy Shevchenko --- v3..v1: Resend. No changes. drivers/nfc/st21nfca/dep.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/nfc/st21nfca/dep.c b/drivers/nfc/st21nfca/dep.c index fd08be2917e6..3420c5104c94 100644 --- a/drivers/nfc/st21nfca/dep.c +++ b/drivers/nfc/st21nfca/dep.c @@ -217,7 +217,8 @@ static int st21nfca_tm_recv_atr_req(struct nfc_hci_dev *hdev, atr_req = (struct st21nfca_atr_req *)skb->data; - if (atr_req->length < sizeof(struct st21nfca_atr_req)) { + if (atr_req->length < sizeof(struct st21nfca_atr_req) || + atr_req->length > skb->len) { r = -EPROTO; goto exit; } -- 2.7.4