bridge: Forbid '/' in bridge names to prevent arbitrary directory access.
[openvswitch] / vswitchd / bridge.c
index 33c9bd76caa009652b75ba4d43a66a9a3b0b4a5e..4e2833e0be70b2c0b65754bfd762d9817ede4498 100644 (file)
@@ -739,9 +739,16 @@ add_del_bridges(const struct ovsrec_open_vswitch *cfg)
     /* Collect new bridges' names and types. */
     shash_init(&new_br);
     for (i = 0; i < cfg->n_bridges; i++) {
+        static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(1, 5);
         const struct ovsrec_bridge *br_cfg = cfg->bridges[i];
-        if (!shash_add_once(&new_br, br_cfg->name, br_cfg)) {
-            VLOG_WARN("bridge %s specified twice", br_cfg->name);
+
+        if (strchr(br_cfg->name, '/')) {
+            /* Prevent remote ovsdb-server users from accessing arbitrary
+             * directories, e.g. consider a bridge named "../../../etc/". */
+            VLOG_WARN_RL(&rl, "ignoring bridge with invalid name \"%s\"",
+                         br_cfg->name);
+        } else if (!shash_add_once(&new_br, br_cfg->name, br_cfg)) {
+            VLOG_WARN_RL(&rl, "bridge %s specified twice", br_cfg->name);
         }
     }
 
@@ -1281,8 +1288,7 @@ iface_refresh_status(struct iface *iface)
     }
 }
 
-/* Writes 'iface''s CFM statistics to the database.  Returns true if anything
- * changed, false otherwise. */
+/* Writes 'iface''s CFM statistics to the database. */
 static void
 iface_refresh_cfm_stats(struct iface *iface)
 {
@@ -2669,7 +2675,7 @@ static void
 iface_configure_cfm(struct iface *iface)
 {
     const struct ovsrec_interface *cfg = iface->cfg;
-    const char *extended_str;
+    const char *extended_str, *opstate_str;
     struct cfm_settings s;
 
     if (!cfg->n_cfm_mpid) {
@@ -2688,6 +2694,9 @@ iface_configure_cfm(struct iface *iface)
                                               "false");
     s.extended = !strcasecmp("true", extended_str);
 
+    opstate_str = get_interface_other_config(iface->cfg, "cfm_opstate", "up");
+    s.opup = !strcasecmp("up", opstate_str);
+
     ofproto_port_set_cfm(iface->port->bridge->ofproto, iface->ofp_port, &s);
 }