Commit aedddb4e authored by Lin Ma's avatar Lin Ma Committed by David S. Miller

NFC: add necessary privilege flags in netlink layer

The CAP_NET_ADMIN checks are needed to prevent attackers faking a
device under NCIUARTSETDRIVER and exploit privileged commands.

This patch add GENL_ADMIN_PERM flags in genl_ops to fulfill the check.
Except for commands like NFC_CMD_GET_DEVICE, NFC_CMD_GET_TARGET,
NFC_CMD_LLC_GET_PARAMS, and NFC_CMD_GET_SE, which are mainly information-
read operations.
Signed-off-by: default avatarLin Ma <linma@zju.edu.cn>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 2bd080b0
...@@ -1664,31 +1664,37 @@ static const struct genl_ops nfc_genl_ops[] = { ...@@ -1664,31 +1664,37 @@ static const struct genl_ops nfc_genl_ops[] = {
.cmd = NFC_CMD_DEV_UP, .cmd = NFC_CMD_DEV_UP,
.validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP, .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
.doit = nfc_genl_dev_up, .doit = nfc_genl_dev_up,
.flags = GENL_ADMIN_PERM,
}, },
{ {
.cmd = NFC_CMD_DEV_DOWN, .cmd = NFC_CMD_DEV_DOWN,
.validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP, .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
.doit = nfc_genl_dev_down, .doit = nfc_genl_dev_down,
.flags = GENL_ADMIN_PERM,
}, },
{ {
.cmd = NFC_CMD_START_POLL, .cmd = NFC_CMD_START_POLL,
.validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP, .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
.doit = nfc_genl_start_poll, .doit = nfc_genl_start_poll,
.flags = GENL_ADMIN_PERM,
}, },
{ {
.cmd = NFC_CMD_STOP_POLL, .cmd = NFC_CMD_STOP_POLL,
.validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP, .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
.doit = nfc_genl_stop_poll, .doit = nfc_genl_stop_poll,
.flags = GENL_ADMIN_PERM,
}, },
{ {
.cmd = NFC_CMD_DEP_LINK_UP, .cmd = NFC_CMD_DEP_LINK_UP,
.validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP, .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
.doit = nfc_genl_dep_link_up, .doit = nfc_genl_dep_link_up,
.flags = GENL_ADMIN_PERM,
}, },
{ {
.cmd = NFC_CMD_DEP_LINK_DOWN, .cmd = NFC_CMD_DEP_LINK_DOWN,
.validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP, .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
.doit = nfc_genl_dep_link_down, .doit = nfc_genl_dep_link_down,
.flags = GENL_ADMIN_PERM,
}, },
{ {
.cmd = NFC_CMD_GET_TARGET, .cmd = NFC_CMD_GET_TARGET,
...@@ -1706,26 +1712,31 @@ static const struct genl_ops nfc_genl_ops[] = { ...@@ -1706,26 +1712,31 @@ static const struct genl_ops nfc_genl_ops[] = {
.cmd = NFC_CMD_LLC_SET_PARAMS, .cmd = NFC_CMD_LLC_SET_PARAMS,
.validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP, .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
.doit = nfc_genl_llc_set_params, .doit = nfc_genl_llc_set_params,
.flags = GENL_ADMIN_PERM,
}, },
{ {
.cmd = NFC_CMD_LLC_SDREQ, .cmd = NFC_CMD_LLC_SDREQ,
.validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP, .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
.doit = nfc_genl_llc_sdreq, .doit = nfc_genl_llc_sdreq,
.flags = GENL_ADMIN_PERM,
}, },
{ {
.cmd = NFC_CMD_FW_DOWNLOAD, .cmd = NFC_CMD_FW_DOWNLOAD,
.validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP, .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
.doit = nfc_genl_fw_download, .doit = nfc_genl_fw_download,
.flags = GENL_ADMIN_PERM,
}, },
{ {
.cmd = NFC_CMD_ENABLE_SE, .cmd = NFC_CMD_ENABLE_SE,
.validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP, .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
.doit = nfc_genl_enable_se, .doit = nfc_genl_enable_se,
.flags = GENL_ADMIN_PERM,
}, },
{ {
.cmd = NFC_CMD_DISABLE_SE, .cmd = NFC_CMD_DISABLE_SE,
.validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP, .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
.doit = nfc_genl_disable_se, .doit = nfc_genl_disable_se,
.flags = GENL_ADMIN_PERM,
}, },
{ {
.cmd = NFC_CMD_GET_SE, .cmd = NFC_CMD_GET_SE,
...@@ -1737,21 +1748,25 @@ static const struct genl_ops nfc_genl_ops[] = { ...@@ -1737,21 +1748,25 @@ static const struct genl_ops nfc_genl_ops[] = {
.cmd = NFC_CMD_SE_IO, .cmd = NFC_CMD_SE_IO,
.validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP, .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
.doit = nfc_genl_se_io, .doit = nfc_genl_se_io,
.flags = GENL_ADMIN_PERM,
}, },
{ {
.cmd = NFC_CMD_ACTIVATE_TARGET, .cmd = NFC_CMD_ACTIVATE_TARGET,
.validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP, .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
.doit = nfc_genl_activate_target, .doit = nfc_genl_activate_target,
.flags = GENL_ADMIN_PERM,
}, },
{ {
.cmd = NFC_CMD_VENDOR, .cmd = NFC_CMD_VENDOR,
.validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP, .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
.doit = nfc_genl_vendor_cmd, .doit = nfc_genl_vendor_cmd,
.flags = GENL_ADMIN_PERM,
}, },
{ {
.cmd = NFC_CMD_DEACTIVATE_TARGET, .cmd = NFC_CMD_DEACTIVATE_TARGET,
.validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP, .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
.doit = nfc_genl_deactivate_target, .doit = nfc_genl_deactivate_target,
.flags = GENL_ADMIN_PERM,
}, },
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment