summaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorPetr Machata <me@pmachata.org>2020-12-22 22:49:44 +0100
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2021-01-23 15:36:56 +0100
commite8063f88d942df6138cc28506e9229ffc0192a42 (patch)
tree042f730957c8c3a8026c29c9f06dfd7e109e8504 /net
parent6d6829545febb24bb35d708ef06287db9da3fe8a (diff)
downloadlinux-stable-e8063f88d942df6138cc28506e9229ffc0192a42.tar.gz
linux-stable-e8063f88d942df6138cc28506e9229ffc0192a42.tar.bz2
linux-stable-e8063f88d942df6138cc28506e9229ffc0192a42.zip
net: dcb: Validate netlink message in DCB handler
[ Upstream commit 826f328e2b7e8854dd42ea44e6519cd75018e7b1 ] DCB uses the same handler function for both RTM_GETDCB and RTM_SETDCB messages. dcb_doit() bounces RTM_SETDCB mesasges if the user does not have the CAP_NET_ADMIN capability. However, the operation to be performed is not decided from the DCB message type, but from the DCB command. Thus DCB_CMD_*_GET commands are used for reading DCB objects, the corresponding SET and DEL commands are used for manipulation. The assumption is that set-like commands will be sent via an RTM_SETDCB message, and get-like ones via RTM_GETDCB. However, this assumption is not enforced. It is therefore possible to manipulate DCB objects without CAP_NET_ADMIN capability by sending the corresponding command in an RTM_GETDCB message. That is a bug. Fix it by validating the type of the request message against the type used for the response. Fixes: 2f90b8657ec9 ("ixgbe: this patch adds support for DCB to the kernel and ixgbe driver") Signed-off-by: Petr Machata <me@pmachata.org> Link: https://lore.kernel.org/r/a2a9b88418f3a58ef211b718f2970128ef9e3793.1608673640.git.me@pmachata.org Signed-off-by: Jakub Kicinski <kuba@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'net')
-rw-r--r--net/dcb/dcbnl.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/net/dcb/dcbnl.c b/net/dcb/dcbnl.c
index 6fe2b615518c..6a675fd36f9b 100644
--- a/net/dcb/dcbnl.c
+++ b/net/dcb/dcbnl.c
@@ -1725,6 +1725,8 @@ 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)
+ return -EPERM;
if (!tb[DCB_ATTR_IFNAME])
return -EINVAL;