linux-uconsole/net/nfc
Fedor Pchelkin 8978315cb4 nfc: fix memory leak of se_io context in nfc_genl_se_io
[ Upstream commit 25ff6f8a5a ]

The callback context for sending/receiving APDUs to/from the selected
secure element is allocated inside nfc_genl_se_io and supposed to be
eventually freed in se_io_cb callback function. However, there are several
error paths where the bwi_timer is not charged to call se_io_cb later, and
the cb_context is leaked.

The patch proposes to free the cb_context explicitly on those error paths.

At the moment we can't simply check 'dev->ops->se_io()' return value as it
may be negative in both cases: when the timer was charged and was not.

Fixes: 5ce3f32b52 ("NFC: netlink: SE API implementation")
Reported-by: syzbot+df64c0a2e8d68e78a4fa@syzkaller.appspotmail.com
Signed-off-by: Fedor Pchelkin <pchelkin@ispras.ru>
Signed-off-by: Alexey Khoroshilov <khoroshilov@ispras.ru>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2023-03-11 16:40:13 +01:00
..
hci treewide: replace '---help---' in Kconfig files with 'help' 2020-06-14 01:57:21 +09:00
nci NFC: nci: Bounds check struct nfc_target arrays 2022-12-14 11:32:02 +01:00
af_nfc.c nfc: fix error handling of nfc_proto_register() 2021-10-20 11:45:04 +02:00
core.c NFC: NULL out the dev->rfkill to prevent UAF 2022-06-09 10:21:01 +02:00
digital.h
digital_core.c NFC: digital: fix possible memory leak in digital_tg_listen_mdaa() 2021-10-20 11:45:04 +02:00
digital_dep.c net:nfc:digital: Fix a double free in digital_tg_recv_dep_req 2021-05-14 09:50:44 +02:00
digital_technology.c NFC: digital: fix possible memory leak in digital_in_send_sdd_req() 2021-10-20 11:45:04 +02:00
Kconfig
llcp.h
llcp_commands.c
llcp_core.c net: nfc: Fix use-after-free in local_cleanup() 2023-02-01 08:23:12 +01:00
llcp_sock.c nfc: llcp: fix NULL error pointer dereference on sendmsg() after failed bind() 2022-01-27 10:53:41 +01:00
Makefile
netlink.c nfc: fix memory leak of se_io context in nfc_genl_se_io 2023-03-11 16:40:13 +01:00
nfc.h
rawsock.c net/nfc/rawsock.c: fix a permission check bug 2021-06-16 12:01:35 +02:00