nfc: Ensure presence of required attributes in the deactivate_target handler
authorYoung Xiao <92siuyang@gmail.com>
Fri, 14 Jun 2019 07:13:02 +0000 (15:13 +0800)
committerDavid S. Miller <davem@davemloft.net>
Fri, 14 Jun 2019 15:48:08 +0000 (08:48 -0700)
Check that the NFC_ATTR_TARGET_INDEX attributes (in addition to
NFC_ATTR_DEVICE_INDEX) are provided by the netlink client prior to
accessing them. This prevents potential unhandled NULL pointer dereference
exceptions which can be triggered by malicious user-mode programs,
if they omit one or both of these attributes.

Signed-off-by: Young Xiao <92siuyang@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/nfc/netlink.c

index 1180b3e58a0abe940e6fdba4fc887ed4b4b80a7b..ea64c90b14e8c8c5385c8357b69efe1a1eac9d4c 100644 (file)
@@ -911,7 +911,8 @@ static int nfc_genl_deactivate_target(struct sk_buff *skb,
        u32 device_idx, target_idx;
        int rc;
 
-       if (!info->attrs[NFC_ATTR_DEVICE_INDEX])
+       if (!info->attrs[NFC_ATTR_DEVICE_INDEX] ||
+           !info->attrs[NFC_ATTR_TARGET_INDEX])
                return -EINVAL;
 
        device_idx = nla_get_u32(info->attrs[NFC_ATTR_DEVICE_INDEX]);