1 From 80ced5ac18af3ef4dc9300fd6b152a732891cdb1 Mon Sep 17 00:00:00 2001
2 From: Young Xiao <92siuyang@gmail.com>
3 Date: Fri, 14 Jun 2019 15:13:02 +0800
4 Subject: nfc: Ensure presence of required attributes in the deactivate_target
7 [ Upstream commit 385097a3675749cbc9e97c085c0e5dfe4269ca51 ]
9 Check that the NFC_ATTR_TARGET_INDEX attributes (in addition to
10 NFC_ATTR_DEVICE_INDEX) are provided by the netlink client prior to
11 accessing them. This prevents potential unhandled NULL pointer dereference
12 exceptions which can be triggered by malicious user-mode programs,
13 if they omit one or both of these attributes.
15 Signed-off-by: Young Xiao <92siuyang@gmail.com>
16 Signed-off-by: David S. Miller <davem@davemloft.net>
17 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
19 net/nfc/netlink.c | 3 ++-
20 1 file changed, 2 insertions(+), 1 deletion(-)
22 diff --git a/net/nfc/netlink.c b/net/nfc/netlink.c
23 index 376181cc1def..9f2875efb4ac 100644
24 --- a/net/nfc/netlink.c
25 +++ b/net/nfc/netlink.c
26 @@ -922,7 +922,8 @@ static int nfc_genl_deactivate_target(struct sk_buff *skb,
27 u32 device_idx, target_idx;
30 - if (!info->attrs[NFC_ATTR_DEVICE_INDEX])
31 + if (!info->attrs[NFC_ATTR_DEVICE_INDEX] ||
32 + !info->attrs[NFC_ATTR_TARGET_INDEX])
35 device_idx = nla_get_u32(info->attrs[NFC_ATTR_DEVICE_INDEX]);