diff mbox series

[net] net: dcb: Accept RTM_GETDCB messages carrying set-like DCB commands

Message ID a3edcfda0825f2aa2591801c5232f2bbf2d8a554.1610384801.git.me@pmachata.org (mailing list archive)
State Accepted
Commit df85bc140a4d6cbaa78d8e9c35154e1a2f0622c7
Delegated to: Netdev Maintainers
Headers show
Series [net] net: dcb: Accept RTM_GETDCB messages carrying set-like DCB commands | expand

Checks

Context Check Description
netdev/cover_letter success Link
netdev/fixes_present success Link
netdev/patch_count success Link
netdev/tree_selection success Clearly marked for net
netdev/subject_prefix success Link
netdev/cc_maintainers warning 5 maintainers not CCed: andrew@lunn.ch peter.p.waskiewicz.jr@intel.com jeffrey.t.kirsher@intel.com alexander.h.duyck@intel.com gaurav1086@gmail.com
netdev/source_inline success Was 0 now: 0
netdev/verify_signedoff success Link
netdev/module_param success Was 0 now: 0
netdev/build_32bit success Errors and warnings before: 1 this patch: 1
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/verify_fixes success Link
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 8 lines checked
netdev/build_allmodconfig_warn success Errors and warnings before: 1 this patch: 1
netdev/header_inline success Link
netdev/stable success Stable not CCed

Commit Message

Petr Machata Jan. 11, 2021, 5:07 p.m. UTC
In commit 826f328e2b7e ("net: dcb: Validate netlink message in DCB
handler"), Linux started rejecting RTM_GETDCB netlink messages if they
contained a set-like DCB_CMD_ command.

The reason was that privileges were only verified for RTM_SETDCB messages,
but the value that determined the action to be taken is the command, not
the message type. And validation of message type against the DCB command
was the obvious missing piece.

Unfortunately it turns out that mlnx_qos, a somewhat widely deployed tool
for configuration of DCB, accesses the DCB set-like APIs through
RTM_GETDCB.

Therefore do not bounce the discrepancy between message type and command.
Instead, in addition to validating privileges based on the actual message
type, validate them also based on the expected message type. This closes
the loophole of allowing DCB configuration on non-admin accounts, while
maintaining backward compatibility.

Fixes: 2f90b8657ec9 ("ixgbe: this patch adds support for DCB to the kernel and ixgbe driver")
Fixes: 826f328e2b7e ("net: dcb: Validate netlink message in DCB handler")
Signed-off-by: Petr Machata <petrm@nvidia.com>
---
 net/dcb/dcbnl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

patchwork-bot+netdevbpf@kernel.org Jan. 13, 2021, 12:10 a.m. UTC | #1
Hello:

This patch was applied to netdev/net.git (refs/heads/master):

On Mon, 11 Jan 2021 18:07:07 +0100 you wrote:
> In commit 826f328e2b7e ("net: dcb: Validate netlink message in DCB
> handler"), Linux started rejecting RTM_GETDCB netlink messages if they
> contained a set-like DCB_CMD_ command.
> 
> The reason was that privileges were only verified for RTM_SETDCB messages,
> but the value that determined the action to be taken is the command, not
> the message type. And validation of message type against the DCB command
> was the obvious missing piece.
> 
> [...]

Here is the summary with links:
  - [net] net: dcb: Accept RTM_GETDCB messages carrying set-like DCB commands
    https://git.kernel.org/netdev/net/c/df85bc140a4d

You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
diff mbox series

Patch

diff --git a/net/dcb/dcbnl.c b/net/dcb/dcbnl.c
index 7d49b6fd6cef..653e3bc9c87b 100644
--- a/net/dcb/dcbnl.c
+++ b/net/dcb/dcbnl.c
@@ -1765,7 +1765,7 @@  static int dcb_doit(struct sk_buff *skb, struct nlmsghdr *nlh,
 	fn = &reply_funcs[dcb->cmd];
 	if (!fn->cb)
 		return -EOPNOTSUPP;
-	if (fn->type != nlh->nlmsg_type)
+	if (fn->type == RTM_SETDCB && !netlink_capable(skb, CAP_NET_ADMIN))
 		return -EPERM;
 
 	if (!tb[DCB_ATTR_IFNAME])