]> git.proxmox.com Git - mirror_ovs.git/commitdiff
bridge: Forbid '/' in bridge names to prevent arbitrary directory access.
authorBen Pfaff <blp@nicira.com>
Fri, 14 Oct 2011 17:17:41 +0000 (10:17 -0700)
committerBen Pfaff <blp@nicira.com>
Mon, 17 Oct 2011 16:05:15 +0000 (09:05 -0700)
vswitchd/bridge.c

index 186f2501870a88d35b3ece9a6eecf6e26ea40f92..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);
         }
     }