apparmor: fix disconnected bind mnts reconnection
authorJohn Johansen <john.johansen@canonical.com>
Fri, 25 Jul 2014 11:02:08 +0000 (04:02 -0700)
committerJohn Johansen <john.johansen@canonical.com>
Tue, 12 Jul 2016 15:43:10 +0000 (08:43 -0700)
Bind mounts can fail to be properly reconnected when PATH_CONNECT is
specified. Ensure that when PATH_CONNECT is specified the path has
a root.

BugLink: http://bugs.launchpad.net/bugs/1319984
Signed-off-by: John Johansen <john.johansen@canonical.com>
Acked-by: Seth Arnold <seth.arnold@canonical.com>
security/apparmor/path.c

index edddc026406b4ef47b53e163e039d1d83f741fe2..f2616780065acabc38e3afdb0e56f6cd38b7cccd 100644 (file)
@@ -141,7 +141,10 @@ static int d_namespace_path(const struct path *path, char *buf, int buflen,
                        error = -EACCES;
                        if (*res == '/')
                                *name = res + 1;
-               }
+               } else if (*res != '/')
+                       /* CONNECT_PATH with missing root */
+                       error = prepend(name, *name - buf, "/", 1);
+
        }
 
 out: