Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

nfc: Ensure presence of NFC_ATTR_FIRMWARE_NAME attribute in nfc_genl_fw_download()

Check that the NFC_ATTR_FIRMWARE_NAME attributes 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.

Similar to commit a0323b979f81 ("nfc: Ensure presence of required attributes in the activate_target handler").

Fixes: 9674da8759df ("NFC: Add firmware upload netlink command")
Signed-off-by: Defang Bo <bodefang@126.com>
Link: https://lore.kernel.org/r/1603107538-4744-1-git-send-email-bodefang@126.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Defang Bo and committed by
Jakub Kicinski
280e3ebd b142083b

+1 -1
+1 -1
net/nfc/netlink.c
··· 1217 1217 u32 idx; 1218 1218 char firmware_name[NFC_FIRMWARE_NAME_MAXSIZE + 1]; 1219 1219 1220 - if (!info->attrs[NFC_ATTR_DEVICE_INDEX]) 1220 + if (!info->attrs[NFC_ATTR_DEVICE_INDEX] || !info->attrs[NFC_ATTR_FIRMWARE_NAME]) 1221 1221 return -EINVAL; 1222 1222 1223 1223 idx = nla_get_u32(info->attrs[NFC_ATTR_DEVICE_INDEX]);