aboutsummaryrefslogtreecommitdiffstats
path: root/net/openvswitch
diff options
context:
space:
mode:
authorTycho Andersen <tycho.andersen@canonical.com>2016-02-05 11:20:52 -0500
committerDavid S. Miller <davem@davemloft.net>2016-02-11 09:53:19 -0500
commit4a92602aa1cd5bbaeedbd9536ff992f7d26fe9d1 (patch)
tree0c1fc8a9c5f393a08cd34c6c02544643eaf0681d /net/openvswitch
parent4456ed04ea44b800d691b18c14a68ec9894d2aca (diff)
openvswitch: allow management from inside user namespaces
Operations with the GENL_ADMIN_PERM flag fail permissions checks because this flag means we call netlink_capable, which uses the init user ns. Instead, let's introduce a new flag, GENL_UNS_ADMIN_PERM for operations which should be allowed inside a user namespace. The motivation for this is to be able to run openvswitch in unprivileged containers. I've tested this and it seems to work, but I really have no idea about the security consequences of this patch, so thoughts would be much appreciated. v2: use the GENL_UNS_ADMIN_PERM flag instead of a check in each function v3: use separate ifs for UNS_ADMIN_PERM and ADMIN_PERM, instead of one massive one Reported-by: James Page <james.page@canonical.com> Signed-off-by: Tycho Andersen <tycho.andersen@canonical.com> CC: Eric Biederman <ebiederm@xmission.com> CC: Pravin Shelar <pshelar@ovn.org> CC: Justin Pettit <jpettit@nicira.com> CC: "David S. Miller" <davem@davemloft.net> Acked-by: Pravin B Shelar <pshelar@ovn.org> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/openvswitch')
-rw-r--r--net/openvswitch/datapath.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/net/openvswitch/datapath.c b/net/openvswitch/datapath.c
index deadfdab1bc3..d6f7fe92744a 100644
--- a/net/openvswitch/datapath.c
+++ b/net/openvswitch/datapath.c
@@ -654,7 +654,7 @@ static const struct nla_policy packet_policy[OVS_PACKET_ATTR_MAX + 1] = {
654 654
655static const struct genl_ops dp_packet_genl_ops[] = { 655static const struct genl_ops dp_packet_genl_ops[] = {
656 { .cmd = OVS_PACKET_CMD_EXECUTE, 656 { .cmd = OVS_PACKET_CMD_EXECUTE,
657 .flags = GENL_ADMIN_PERM, /* Requires CAP_NET_ADMIN privilege. */ 657 .flags = GENL_UNS_ADMIN_PERM, /* Requires CAP_NET_ADMIN privilege. */
658 .policy = packet_policy, 658 .policy = packet_policy,
659 .doit = ovs_packet_cmd_execute 659 .doit = ovs_packet_cmd_execute
660 } 660 }
@@ -1391,12 +1391,12 @@ static const struct nla_policy flow_policy[OVS_FLOW_ATTR_MAX + 1] = {
1391 1391
1392static const struct genl_ops dp_flow_genl_ops[] = { 1392static const struct genl_ops dp_flow_genl_ops[] = {
1393 { .cmd = OVS_FLOW_CMD_NEW, 1393 { .cmd = OVS_FLOW_CMD_NEW,
1394 .flags = GENL_ADMIN_PERM, /* Requires CAP_NET_ADMIN privilege. */ 1394 .flags = GENL_UNS_ADMIN_PERM, /* Requires CAP_NET_ADMIN privilege. */
1395 .policy = flow_policy, 1395 .policy = flow_policy,
1396 .doit = ovs_flow_cmd_new 1396 .doit = ovs_flow_cmd_new
1397 }, 1397 },
1398 { .cmd = OVS_FLOW_CMD_DEL, 1398 { .cmd = OVS_FLOW_CMD_DEL,
1399 .flags = GENL_ADMIN_PERM, /* Requires CAP_NET_ADMIN privilege. */ 1399 .flags = GENL_UNS_ADMIN_PERM, /* Requires CAP_NET_ADMIN privilege. */
1400 .policy = flow_policy, 1400 .policy = flow_policy,
1401 .doit = ovs_flow_cmd_del 1401 .doit = ovs_flow_cmd_del
1402 }, 1402 },
@@ -1407,7 +1407,7 @@ static const struct genl_ops dp_flow_genl_ops[] = {
1407 .dumpit = ovs_flow_cmd_dump 1407 .dumpit = ovs_flow_cmd_dump
1408 }, 1408 },
1409 { .cmd = OVS_FLOW_CMD_SET, 1409 { .cmd = OVS_FLOW_CMD_SET,
1410 .flags = GENL_ADMIN_PERM, /* Requires CAP_NET_ADMIN privilege. */ 1410 .flags = GENL_UNS_ADMIN_PERM, /* Requires CAP_NET_ADMIN privilege. */
1411 .policy = flow_policy, 1411 .policy = flow_policy,
1412 .doit = ovs_flow_cmd_set, 1412 .doit = ovs_flow_cmd_set,
1413 }, 1413 },
@@ -1777,12 +1777,12 @@ static const struct nla_policy datapath_policy[OVS_DP_ATTR_MAX + 1] = {
1777 1777
1778static const struct genl_ops dp_datapath_genl_ops[] = { 1778static const struct genl_ops dp_datapath_genl_ops[] = {
1779 { .cmd = OVS_DP_CMD_NEW, 1779 { .cmd = OVS_DP_CMD_NEW,
1780 .flags = GENL_ADMIN_PERM, /* Requires CAP_NET_ADMIN privilege. */ 1780 .flags = GENL_UNS_ADMIN_PERM, /* Requires CAP_NET_ADMIN privilege. */
1781 .policy = datapath_policy, 1781 .policy = datapath_policy,
1782 .doit = ovs_dp_cmd_new 1782 .doit = ovs_dp_cmd_new
1783 }, 1783 },
1784 { .cmd = OVS_DP_CMD_DEL, 1784 { .cmd = OVS_DP_CMD_DEL,
1785 .flags = GENL_ADMIN_PERM, /* Requires CAP_NET_ADMIN privilege. */ 1785 .flags = GENL_UNS_ADMIN_PERM, /* Requires CAP_NET_ADMIN privilege. */
1786 .policy = datapath_policy, 1786 .policy = datapath_policy,
1787 .doit = ovs_dp_cmd_del 1787 .doit = ovs_dp_cmd_del
1788 }, 1788 },
@@ -1793,7 +1793,7 @@ static const struct genl_ops dp_datapath_genl_ops[] = {
1793 .dumpit = ovs_dp_cmd_dump 1793 .dumpit = ovs_dp_cmd_dump
1794 }, 1794 },
1795 { .cmd = OVS_DP_CMD_SET, 1795 { .cmd = OVS_DP_CMD_SET,
1796 .flags = GENL_ADMIN_PERM, /* Requires CAP_NET_ADMIN privilege. */ 1796 .flags = GENL_UNS_ADMIN_PERM, /* Requires CAP_NET_ADMIN privilege. */
1797 .policy = datapath_policy, 1797 .policy = datapath_policy,
1798 .doit = ovs_dp_cmd_set, 1798 .doit = ovs_dp_cmd_set,
1799 }, 1799 },
@@ -2158,12 +2158,12 @@ static const struct nla_policy vport_policy[OVS_VPORT_ATTR_MAX + 1] = {
2158 2158
2159static const struct genl_ops dp_vport_genl_ops[] = { 2159static const struct genl_ops dp_vport_genl_ops[] = {
2160 { .cmd = OVS_VPORT_CMD_NEW, 2160 { .cmd = OVS_VPORT_CMD_NEW,
2161 .flags = GENL_ADMIN_PERM, /* Requires CAP_NET_ADMIN privilege. */ 2161 .flags = GENL_UNS_ADMIN_PERM, /* Requires CAP_NET_ADMIN privilege. */
2162 .policy = vport_policy, 2162 .policy = vport_policy,
2163 .doit = ovs_vport_cmd_new 2163 .doit = ovs_vport_cmd_new
2164 }, 2164 },
2165 { .cmd = OVS_VPORT_CMD_DEL, 2165 { .cmd = OVS_VPORT_CMD_DEL,
2166 .flags = GENL_ADMIN_PERM, /* Requires CAP_NET_ADMIN privilege. */ 2166 .flags = GENL_UNS_ADMIN_PERM, /* Requires CAP_NET_ADMIN privilege. */
2167 .policy = vport_policy, 2167 .policy = vport_policy,
2168 .doit = ovs_vport_cmd_del 2168 .doit = ovs_vport_cmd_del
2169 }, 2169 },
@@ -2174,7 +2174,7 @@ static const struct genl_ops dp_vport_genl_ops[] = {
2174 .dumpit = ovs_vport_cmd_dump 2174 .dumpit = ovs_vport_cmd_dump
2175 }, 2175 },
2176 { .cmd = OVS_VPORT_CMD_SET, 2176 { .cmd = OVS_VPORT_CMD_SET,
2177 .flags = GENL_ADMIN_PERM, /* Requires CAP_NET_ADMIN privilege. */ 2177 .flags = GENL_UNS_ADMIN_PERM, /* Requires CAP_NET_ADMIN privilege. */
2178 .policy = vport_policy, 2178 .policy = vport_policy,
2179 .doit = ovs_vport_cmd_set, 2179 .doit = ovs_vport_cmd_set,
2180 }, 2180 },