Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp623050pxj; Thu, 20 May 2021 18:12:23 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwS708XlztA45rh6sD71h8UNbrDWwyEO65uExsWxK9+FY/lNJnk+FjSkPhtA8eOM0gZ0kT1 X-Received: by 2002:a17:906:6d51:: with SMTP id a17mr7277865ejt.151.1621559542868; Thu, 20 May 2021 18:12:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621559542; cv=none; d=google.com; s=arc-20160816; b=mMRScf0ZHQu6g+h8CUtf4DZX2hmf7usOcvHh5IbyfIBKNH+KHkKMVzWSQdwYrCDFJP FR+K/5q4vB1GPDip5qvwcX6RGfpiD6tHPXDaeV2GAw4br/zNbBQ54PLM6HmUHPml2umw 8qr0wWcWs4sIl+qoK7MRFKj/DyO9fhl7S/KZQ4koop39doR4PtgiUIg1/3bszLkOWz93 K/csLD31ualnMNc49SN2SVy5PyYLOZlSlSpK1tvtL7zkGyJaVDkdDltLqJxQJYWCpErZ wKExQrFY5YCEorq7QIOSWeziEDbprwREir2Zyq6z+Y2K/6w1tS7r9X3RZ0CvfxUwJL+1 1sGw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=wR5H2zGje05nmGJmR5DSzxROUzd1Q0HYqUXxMrRu1Og=; b=TR0uAKV165gmH3Ynbp7vt8+3ibHJbnBfnV4XE7r2VPFb2gxHJpMpgq6VLkCNAYSja8 rE5Fqn7bnReENrr/uST4d+m7phmspv3EDdMBXh5/ycXYdefx2rBHAMD+CnLYT1929TSp 1tsv9zTYa1YavswoJwodIxyoJGTUGvBDAzqwHk2MZUxKWcw7feAbjaVUUVpL4hZhVspS DPkacmdJP2zHM2RgkA/lPh7+LgMcCjjRFurhhFoflnVGrXbbOyswAjBfviPcLzk6I3SJ CAlJHbh6LVGr95ccBrWJJfo/yKYOO4aPQKaoSiJFZaWLfDp6QcR5n9bU3452EKYTSghv OUfA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="lFv6j/8l"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s15si3823652eji.457.2021.05.20.18.11.58; Thu, 20 May 2021 18:12:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="lFv6j/8l"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242036AbhETLlb (ORCPT + 99 others); Thu, 20 May 2021 07:41:31 -0400 Received: from mail.kernel.org ([198.145.29.99]:43606 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240465AbhETLUg (ORCPT ); Thu, 20 May 2021 07:20:36 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 7991B61D84; Thu, 20 May 2021 10:11:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621505469; bh=ZpKop7a3TUJCeE4gnzgdKitIvMnEbF0gqyaNlowowLA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lFv6j/8lnq3g0pCP61pgpbhebHZrwgDK9zPq39bGvE9cGD4isjglpkMDg+95oXuIM 6UqAcfyXbvxKDT8O8uAcKM8t05jit4yRlTgzq/yx7kNsQV1Q+HXS1ql718ipfc6GBp V+8xYV3NM+5zrz21kQ7MRjXtPSy92+fisiFNUa00= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dan Carpenter , "David S. Miller" , Sasha Levin Subject: [PATCH 4.4 115/190] nfc: pn533: prevent potential memory corruption Date: Thu, 20 May 2021 11:22:59 +0200 Message-Id: <20210520092106.004568090@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210520092102.149300807@linuxfoundation.org> References: <20210520092102.149300807@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Dan Carpenter [ Upstream commit ca4d4c34ae9aa5c3c0da76662c5e549d2fc0cc86 ] If the "type_a->nfcid_len" is too large then it would lead to memory corruption in pn533_target_found_type_a() when we do: memcpy(nfc_tgt->nfcid1, tgt_type_a->nfcid_data, nfc_tgt->nfcid1_len); Fixes: c3b1e1e8a76f ("NFC: Export NFCID1 from pn533") Signed-off-by: Dan Carpenter Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- drivers/nfc/pn533.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/nfc/pn533.c b/drivers/nfc/pn533.c index bb3d5ea9869c..001c12867e43 100644 --- a/drivers/nfc/pn533.c +++ b/drivers/nfc/pn533.c @@ -1250,6 +1250,9 @@ static bool pn533_target_type_a_is_valid(struct pn533_target_type_a *type_a, if (PN533_TYPE_A_SEL_CASCADE(type_a->sel_res) != 0) return false; + if (type_a->nfcid_len > NFC_NFCID1_MAXSIZE) + return false; + return true; } -- 2.30.2