summaryrefslogtreecommitdiff
path: root/drivers/nfc/pn533/pn533.c
diff options
context:
space:
mode:
authorDan Carpenter <dan.carpenter@oracle.com>2021-04-02 14:44:42 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2021-05-14 10:44:27 +0300
commitcab33b3b6da87df0b7d6def1b87f835c893cde04 (patch)
treec4f37a4fcf4cfa561a8bf524d1534da6e1070a8c /drivers/nfc/pn533/pn533.c
parentefb0f45b4535dd8ca31ae13528de890b8849965e (diff)
downloadlinux-cab33b3b6da87df0b7d6def1b87f835c893cde04.tar.xz
nfc: pn533: prevent potential memory corruption
[ 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 <dan.carpenter@oracle.com> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'drivers/nfc/pn533/pn533.c')
-rw-r--r--drivers/nfc/pn533/pn533.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/drivers/nfc/pn533/pn533.c b/drivers/nfc/pn533/pn533.c
index a172a32aa9d9..3ea38ce86cc9 100644
--- a/drivers/nfc/pn533/pn533.c
+++ b/drivers/nfc/pn533/pn533.c
@@ -680,6 +680,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;
}