From mboxrd@z Thu Jan 1 00:00:00 1970 From: ebiederm-aS9lmoZGLiVWk0Htik3J/w@public.gmane.org (Eric W. Biederman) Subject: Re: [PATCH review 2/4] vfs: Test for and handle paths that are unreachable from their mnt_root Date: Thu, 09 Apr 2015 21:24:20 -0500 Message-ID: <87sic83eln.fsf@x220.int.ebiederm.org> References: <871tncuaf6.fsf@x220.int.ebiederm.org> <87mw5xq7lt.fsf@x220.int.ebiederm.org> <87a8yqou41.fsf_-_@x220.int.ebiederm.org> <874moq9oyb.fsf_-_@x220.int.ebiederm.org> <87sica8ac5.fsf_-_@x220.int.ebiederm.org> <20150409231636.GW889@ZenIV.linux.org.uk> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Cc: Andrey Vagin , Richard Weinberger , Linux Containers , Andy Lutomirski , linux-fsdevel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, Jann Horn , Willy Tarreau To: Al Viro Return-path: In-Reply-To: <20150409231636.GW889-3bDd1+5oDREiFSDQTTA3OLVCufUGDwFn@public.gmane.org> (Al Viro's message of "Fri, 10 Apr 2015 00:16:36 +0100") List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: containers-bounces-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org Errors-To: containers-bounces-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org List-Id: linux-fsdevel.vger.kernel.org Al Viro writes: > On Wed, Apr 08, 2015 at 06:32:58PM -0500, Eric W. Biederman wrote: >> >> - Add a dentry flag DCACHE_MOUNT_VIOLATED to mark loopback mounts that >> have had a dentry moved into a directory that does not descend from >> the mount root dentry. >> >> - In mnt_put_root clear DCACHE_MOUNT_VIOLATED. >> >> - Add a function path_connected to verify a path.dentry is reachable from >> path.mnt.mnt_root. AKA rename did not do something nasty to the bind mount. >> >> - Disable ".." when a path is not connected during lookup. >> (Maybe we want to stop ".." at this path instead?) >> >> Following .. is not disabled after a transition to / >> and is never disabled when / is the directory we start >> with. Because we already limit .. no higher than / > > IDGI. Am I missing something, or you really only set that flag in the > beginning of the pathwalk? At the bare minimum, you want to treat > nd_jump_link() the same way, or your protection is trivially defeated by > using /proc/self/cwd/$PATHNAME instead of $PATHNAME... nd_jump_link() is definitely an oversight. Doh! Starting at the root or starting at mount_root of a mount point that flag is not necessary. As we can obviously walk up as far as it is possible to go on that mount. Furthermore legitimize_mnt will fail if a problematic rename happens during the mount. The next patch limits what follow_up and follow_nup_rcu can do. So I have all of the normal operations covered, but I definitely need to take a second look to see if there are any additional locations like nd_jump_link where we can jump onto a path in the middle of a mount and need to test to see if it is connected. Eric