Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp4620145pxj; Wed, 12 May 2021 09:23:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyrlf/KE1Ldwz2emOmbmIzI3rwLOjd/jm3MYLjKOWUZOIRKfLikirmwjm+rKOKOxTM0FlzH X-Received: by 2002:a54:4e1a:: with SMTP id a26mr8271408oiy.139.1620836590156; Wed, 12 May 2021 09:23:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620836590; cv=none; d=google.com; s=arc-20160816; b=PtFpyzTIl9j6+m1KPIK4KwLg4kt6TKNV/JA8c8KualpC/wvzmXfKz2oNyRR1Q789Bt rAAs5B9nHs21wk2z6JD4VncstTlU/qh3o6QuODhdvDuDetl0HLk+EcNjfazeRbHe3mey G4WF8N891C9Et/brk96ESsmSHSFj1pEht9dZKoRBsHofh5pdj8clJpfK56VHYijSy4ax 4oKfsECcDaBxaQ+wm9h+RWDMm1Ps87ZKaKIuiL+HE9Y+v7uz7DZ+w3ZNl9DXYzLaZOpE 9w+Y502K2uyc6YHt8k13cZtkXLV8HJqS6OCm+iNd4VvsVDY6yF25a+pk8fK8+BTHGpZr o2IA== 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=dCkFmF8jycjXQ6ESMWrMNNEVTtOvk0KPD3+EhkCjytc=; b=SpIn899myxf/dUew7nrXQXNFO3mYvcMB9rYPuNM0q8Ak0g6CxDqANboMAJY26SWcwk uI0ogGwvZMSOFq4DhcqDa7WnDGWfehFgjnxXDHpyzByGP5GXpn8q1ktey/r3cA1uNovO WKESyJX8A47h3bacMskHo3fwbJj8JBIXPyu63hXtKTThSVUvLHkLD9Xy3xNs37hxOaSd Z623f67rRFvpMCVi7FtxCsJj1KNEk7X1iIYzvPWty3JOmKziw05p/TeqqV1KCZmU3NOG THiCDV0e2oxzGNC5S56gflKsP4jqvS0RBYBEnZBQOzPN6AagXFaCRGJlLpcMJbmFU2Cy /IgA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=McV1GE20; 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 e2si300498otf.18.2021.05.12.09.22.55; Wed, 12 May 2021 09:23:10 -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=McV1GE20; 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 S233193AbhELQUp (ORCPT + 99 others); Wed, 12 May 2021 12:20:45 -0400 Received: from mail.kernel.org ([198.145.29.99]:51290 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236043AbhELPgs (ORCPT ); Wed, 12 May 2021 11:36:48 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 4B9BD61C39; Wed, 12 May 2021 15:18:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1620832692; bh=HAjZwOB7Sbf6jomtEiu3agcmtEFNo+gOOifVn3WIxO0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=McV1GE20H2g86LH/+g5ZvPZBQracGSYtYQ49KwqUCiwsTF8mVZ1voLkN22WL2KDgD eAR0jxGEMVWctABSq+atHcxtHPPrmzegYDmMiJuwNg2w7/wMr4wRVXWbmsiUCosB+k /C/DrUY6wzkBCe2v70wQ9NcMLcZVipQv/HbyyW2Q= 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 5.10 385/530] nfc: pn533: prevent potential memory corruption Date: Wed, 12 May 2021 16:48:15 +0200 Message-Id: <20210512144832.427832448@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210512144819.664462530@linuxfoundation.org> References: <20210512144819.664462530@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/pn533.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/nfc/pn533/pn533.c b/drivers/nfc/pn533/pn533.c index f7464bd6d57c..18e3435ab8f3 100644 --- a/drivers/nfc/pn533/pn533.c +++ b/drivers/nfc/pn533/pn533.c @@ -706,6 +706,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