Skip to contentSkip to conversation

nfc: Ensure presence of required attributes in the deactivate_target handler

PATCH In review Young Xiao 2 participants 2 messages Jun 14, 2019

Subsystems (3)
lore
Share & tools
lore

Young Xiao

author
#0 lore raw

PATCH 1/1 nfc: Ensure presence of required attributes in the deactivate_target handler

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.

---
 net/nfc/netlink.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
net/nfc/netlink.c +2 -1
index 04a8e47..89d885d 100644
@@ -923,7 +923,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]);
Signature · 1 line
2.7.4
maintainer
#1 lore raw

From: Young Xiao <[email protected]>
Date: Fri, 14 Jun 2019 15:13:02 +0800

Quoted 7 lines

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.

Applied and queued up for -stable, thanks.