From mboxrd@z Thu Jan 1 00:00:00 1970 From: Miklos Szeredi Subject: Re: [PATCH review 0/4] Loopback mount escape fixes Date: Mon, 13 Apr 2015 14:18:40 +0200 Message-ID: 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> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Cc: Linux Containers , linux-fsdevel , Al Viro , Andy Lutomirski , "Serge E. Hallyn" , Richard Weinberger , Andrey Vagin , Jann Horn , Willy Tarreau , Omar Sandoval To: "Eric W. Biederman" Return-path: Received: from mail-ig0-f173.google.com ([209.85.213.173]:35242 "EHLO mail-ig0-f173.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751227AbbDMMSn (ORCPT ); Mon, 13 Apr 2015 08:18:43 -0400 Received: by igbyr2 with SMTP id yr2so7573670igb.0 for ; Mon, 13 Apr 2015 05:18:42 -0700 (PDT) Received: from mail-ie0-f178.google.com (mail-ie0-f178.google.com. [209.85.223.178]) by mx.google.com with ESMTPSA id f126sm3468945ioe.21.2015.04.13.05.18.40 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 13 Apr 2015 05:18:41 -0700 (PDT) Received: by iebmp1 with SMTP id mp1so62614480ieb.0 for ; Mon, 13 Apr 2015 05:18:40 -0700 (PDT) In-Reply-To: <874moq9oyb.fsf_-_@x220.int.ebiederm.org> Sender: linux-fsdevel-owner@vger.kernel.org List-ID: On Thu, Apr 9, 2015 at 1:31 AM, Eric W. Biederman wrote: > > After the last round of feedback I sat down and played with my fix > for the fact that a strategically placed rename, ".." on bind mounts > go up past the root of the bind mount. > > The code better handles the escaped directory returning into it's bind > mount, and is now roughly a constant factor cost in all cases from what > the code costs without the fix. > > So I think I have found a better tradeoff between fixing this bug and > not slowing down path name lookups in the common case. Maybe I'm missing something, but I see a much simpler fix: - When following ".." first just check against the dentry being equal to the root dentry. - If so, then check mount being equal to root mount. - If so, then we are fine, found the root. - If mount is not root mount, then we either have a bind mount or the escape scenario. So have a peek at the mount tree to see if we have a chance of reaching root or not. - If yes, then we are fine, continue upward. - Otherwise stop here and act like we found root. This doesn't have to hook into d_move() and will only trigger the "violated" mode on an very specific and rare case. I haven't thought about this very hard, but I don't see how the root dentry could be avoided without first having access to something outside the root. Thanks, Miklos