nfc: pn533: prevent potential memory corruption
Subsystems (4)
PATCH 1/1 nfc: pn533: prevent potential memory corruption
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 <[email protected]>
--- drivers/nfc/pn533/pn533.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/nfc/pn533/pn533.c +3 -0
@@ -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; }
Signature · 1 line
2.30.2
This patch was applied to netdev/net-next.git (refs/heads/master):
Hello:
This patch was applied to netdev/net-next.git (refs/heads/master):
Quoted 9 lines · On Fri, 2 Apr 2021 14:44:42 +0300 you wrote:
If the "
type_a->nfcid_len" is too large then it would lead to memory corruption inpn533_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 <[email protected]>[...]
Here is the summary with links:
- [net-next] nfc: pn533: prevent potential memory corruption
https://git.kernel.org/netdev/net-next/c/ca4d4c34ae9a
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html