]> git.baikalelectronics.ru Git - kernel.git/commit
nfc: pn533: Clear nfc_target before being used
authorMinsuk Kang <linuxlovemin@yonsei.ac.kr>
Wed, 14 Dec 2022 01:51:39 +0000 (10:51 +0900)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 18 Jan 2023 10:41:32 +0000 (11:41 +0100)
commitb7e9b39ab56ab2ed85ce3da03993e2f156a40e43
treeb292d3e353f8988e54d4705fb2c21a695c3cc559
parent5dbd62e1b1ef4cd7249bf0bba61c67339aadf079
nfc: pn533: Clear nfc_target before being used

[ Upstream commit 34192af78d54701d906f6609e6b8e4fd144c8cd0 ]

Fix a slab-out-of-bounds read that occurs in nla_put() called from
nfc_genl_send_target() when target->sensb_res_len, which is duplicated
from an nfc_target in pn533, is too large as the nfc_target is not
properly initialized and retains garbage values. Clear nfc_targets with
memset() before they are used.

Found by a modified version of syzkaller.

BUG: KASAN: slab-out-of-bounds in nla_put
Call Trace:
 memcpy
 nla_put
 nfc_genl_dump_targets
 genl_lock_dumpit
 netlink_dump
 __netlink_dump_start
 genl_family_rcv_msg_dumpit
 genl_rcv_msg
 netlink_rcv_skb
 genl_rcv
 netlink_unicast
 netlink_sendmsg
 sock_sendmsg
 ____sys_sendmsg
 ___sys_sendmsg
 __sys_sendmsg
 do_syscall_64

Fixes: 790a9190d3d4 ("NFC: pn533: Send ATR_REQ directly for active device detection")
Fixes: e98b9959c9df ("NFC: DEP link hook implementation for pn533")
Signed-off-by: Minsuk Kang <linuxlovemin@yonsei.ac.kr>
Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Link: https://lore.kernel.org/r/20221214015139.119673-1-linuxlovemin@yonsei.ac.kr
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/nfc/pn533/pn533.c