net: devmem: add missing permission check for bind-tx
Subsystems (4)
PATCH 1/1 net: devmem: add missing permission check for bind-tx
From: Tristan Madani <[email protected]>
The bind-tx netlink command (NETDEV_CMD_BIND_TX) was introduced in commit 8802087d20c0 ("net: devmem: TCP tx netlink api") without any permission flags in the netlink spec. As a result, the generated genl code does not enforce any capability check, allowing unprivileged users to bind DMA-BUFs to network devices that support TX netmem.
In contrast, the bind-rx command (NETDEV_CMD_BIND_RX) correctly requires GENL_UNS_ADMIN_PERM (CAP_NET_ADMIN in the namespace's owning user namespace). Both operations perform the same class of privileged DMA-BUF binding, and bind-tx should require the same level of authorization.
Add the uns-admin-perm flag to the bind-tx command in the netlink spec and update the generated C code to enforce CAP_NET_ADMIN.
--- Documentation/netlink/specs/netdev.yaml | 1 + net/core/netdev-genl-gen.c | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-)
Documentation/netlink/specs/netdev.yaml +1 -0
@@ -832,6 +832,7 @@ operations: name: bind-tx doc: Bind dmabuf to netdev for TX attribute-set: dmabuf + flags: [uns-admin-perm] do: request: attributes:
net/core/netdev-genl-gen.c +1 -1
@@ -234,7 +234,7 @@ static const struct genl_split_ops netdev_nl_ops[] = { .doit = netdev_nl_bind_tx_doit, .policy = netdev_bind_tx_nl_policy, .maxattr = NETDEV_A_DMABUF_FD, - .flags = GENL_CMD_CAP_DO, + .flags = GENL_UNS_ADMIN_PERM | GENL_CMD_CAP_DO, }, { .cmd = NETDEV_CMD_QUEUE_CREATE,
Signature · 1 line
2.47.3
Quoted 14 lines · Tristan Madani
From: Tristan Madani <[email protected]>
The bind-tx netlink command (
NETDEV_CMD_BIND_TX) was introduced in commit8802087d20c0("net: devmem: TCP tx netlink api") without any permission flags in the netlink spec. As a result, the generated genl code does not enforce any capability check, allowing unprivileged users to bind DMA-BUFs to network devices that support TX netmem.In contrast, the bind-rx command (
NETDEV_CMD_BIND_RX) correctly requiresGENL_UNS_ADMIN_PERM(CAP_NET_ADMINin the namespace's owning user namespace). Both operations perform the same class of privileged DMA-BUF binding, and bind-tx should require the same level of authorization.
Quoted 6 lines
Add the uns-admin-perm flag to the bind-tx command in the netlink spec and update the generated C code to enforce
CAP_NET_ADMIN.Fixes 8802087d20c0 ("net: devmem: TCP tx netlink api")Signed-off-by Tristan Madani <[email protected]>
This is the second time some AI finds this 'bug'. It's intentional that rx needs permissions, and tx doesn't. rx bind takes ownership of an rx queue. tx does not.
Signature · 2 lines
Thanks, Mina
Quoted 19 lines · Mina Almasry
Quoted 17 lines · Tristan Madani
From: Tristan Madani <[email protected]>
The bind-tx netlink command (
NETDEV_CMD_BIND_TX) was introduced in commit8802087d20c0("net: devmem: TCP tx netlink api") without any permission flags in the netlink spec. As a result, the generated genl code does not enforce any capability check, allowing unprivileged users to bind DMA-BUFs to network devices that support TX netmem.In contrast, the bind-rx command (
NETDEV_CMD_BIND_RX) correctly requiresGENL_UNS_ADMIN_PERM(CAP_NET_ADMINin the namespace's owning user namespace). Both operations perform the same class of privileged DMA-BUF binding, and bind-tx should require the same level of authorization.Add the uns-admin-perm flag to the bind-tx command in the netlink spec and update the generated C code to enforce
CAP_NET_ADMIN.
Quoted 8 lines
Quoted 3 lines
Fixes 8802087d20c0 ("net: devmem: TCP tx netlink api")Signed-off-by Tristan Madani <[email protected]>This is the second time some AI finds this 'bug'. It's intentional that rx needs permissions, and tx doesn't. rx bind takes ownership of an rx queue. tx does not.
It may be worth it to add a comment at this point for future AIs reviewing the code.
Signature · 2 lines
Thanks, Mina