Received: by 10.192.165.148 with SMTP id m20csp916179imm; Wed, 2 May 2018 10:50:41 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrdlk3u6D5IF7BYWZi9pYZBOkuJuaCrO24ngaavgAeODZdaqs3VU3IsVjgNQFyG2H82qG1U X-Received: by 2002:a17:902:14b:: with SMTP id 69-v6mr21254739plb.184.1525283441112; Wed, 02 May 2018 10:50:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525283441; cv=none; d=google.com; s=arc-20160816; b=OiIYRwX9Ki1wQtaOD4an1C4fhW5mzDJ0CHFEydO7oCPvDhPsjsUXy7zU6BKBqfqnbY VHs9lNIR1qnyarWMQl7NiNPUHNRKTdgB+3MB6T/X164QanXreCpGemu+Yt+qYv/i1lfl /RaIFpIX2Kk0nLBbRFrkQnbq2dhlexDaFMhjtQ8EP6bR1LLN7F1Pun/8GjkjcM5owkk/ bAYexdRVIKZzYm7KIMmRMi76S93Bt6DW6AGUdbl7Dp+QiwMBLTYKa7uyzWdA67WeyhtK be8B7s06UMEmIMLQnH5yfphVrhFh33TqyAofjDdUenSlZSkaqFeoNdQzmNf6EDQAOie/ 7/Ow== 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=4fymCIn5kQ1t0qy2gJd1+DqIl18DKdeO5ToUU0ZKRTg=; b=O6SQStdzPdD2QXRdXTJF3ltoEylxf5XSJbZWvG6UoKdUNQKGw/m+qgw1ixIobPzDxg z/2vb9KMGE9HRpzu5UCzt78sJmWXxqIGPWfu+/CIJbQNixjJTR1urq73U1y3Qjc6Llji kOz2lMYLGl4VkNr5p4F/d9evXF/ZtcZdamP8foF+WsfZsHYQD3qKS+MBkbVxFX8uJnwg fw2bzJkvL0jd5ZSFQtQ/pUPrYUFq9RCUQMpPCaOiMoxDGudqNDHpxgqagtIZvYH88DMR LbeO13UbxUZzwUWXm9Hmw09tj77BTFADBT3QWzZlHRxK5iC8YWqOfCnUubrmA9FbK6Va FruA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=adzPT/Fw; 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 l1-v6si9925011pgf.398.2018.05.02.10.50.26; Wed, 02 May 2018 10:50:41 -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=adzPT/Fw; 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 S1751562AbeEBRtS (ORCPT + 99 others); Wed, 2 May 2018 13:49:18 -0400 Received: from mail-pg0-f67.google.com ([74.125.83.67]:33138 "EHLO mail-pg0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751803AbeEBRsU (ORCPT ); Wed, 2 May 2018 13:48:20 -0400 Received: by mail-pg0-f67.google.com with SMTP id i194-v6so11162959pgd.0 for ; Wed, 02 May 2018 10:48:20 -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=4fymCIn5kQ1t0qy2gJd1+DqIl18DKdeO5ToUU0ZKRTg=; b=adzPT/Fwc5/7pVxPJqHIEdllSIyuIC1pyl610qvDmFOOODn+pRi9FsRYVsAgfvGloM 2rtgKc2cI5E4AR5YeXzG+P8T5J22BP3HOCJaQu8BEQxdhdK+DVlCIBK83Lw1e93MB8nq qxD7Tz6RclMqnpfJLWaKDyrp+becuZvETQYHQ= 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=4fymCIn5kQ1t0qy2gJd1+DqIl18DKdeO5ToUU0ZKRTg=; b=fy/Dh8v34hpZIB9txXSyhL7u0mDXQKOb3pPxxqOEf1dW4nqYkQNsbTePDwaxg2qHw2 JMHTHKcMgCiuzmFoERmDyEbLyxgzVqiWjkXAhp9I7jnMimUX0k6l3C0AkABUvFo/zJMK trmq0FWX542UUQE7mgp/OuJdE0k2kLem51gMlMITj8jRQJFrnxrFz+wqMmRPjNBczs+P bWZjWkbpTRVELWQXKY9T5ud7H2clrBPJt/A5JkM+BP2WAHYENRQggpaJcX/UCL34u0qy DvpPyL/P+1dCmceh9/HTFtSt4PlFgJzsnmlZzd0UXwVOxF3XKeS3c+5N0D4BOy7OM8Ex 7VMA== X-Gm-Message-State: ALQs6tAUv5+1StKhK2ju44lyaLGbp+rV1Hwn4YnT8+AUh8ccRvYlUxVE TV9u1Gn5ClrIYe0JbwhKsr23bvbKnNM= X-Received: by 2002:a17:902:8c83:: with SMTP id t3-v6mr17166196plo.357.1525283299065; Wed, 02 May 2018 10:48:19 -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.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 02 May 2018 10:48:17 -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 1/3] NFC: st21nfca: Fix out of bounds kernel access when handling ATR_REQ Date: Wed, 2 May 2018 23:18:06 +0530 Message-Id: <1525283288-7027-2-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 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. Signed-off-by: Suren Baghdasaryan Signed-off-by: Amit Pundir --- v2: 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 fd08be2..3420c51 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