Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp1279548ybi; Sat, 27 Jul 2019 06:20:47 -0700 (PDT) X-Google-Smtp-Source: APXvYqxk+A9Q5T63iGosoMng1F3GSZA1IlRL0HIX2L/LDMo1x7D7rEaqUG8Hi0wYeAzgROm3evON X-Received: by 2002:a17:902:be0a:: with SMTP id r10mr95612544pls.51.1564233647780; Sat, 27 Jul 2019 06:20:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564233647; cv=none; d=google.com; s=arc-20160816; b=SwJdd/Ar56/BUy806RayIHEGQqNDxemCMHK0obApf0oGiobTB+X3onn/V4LoL8K3kn idorn3dXruuB8ht07DIuYtYF7DSDSu+qhmZ44VKHeSlZkI+/KY0FOF35SwNuauXzS35v dN36gq+GzqalYfGrPRWfW7oXjaaTu0UvsEJymdkdXiOrUPH1zLbTGJerxg53MG6UZO4K tUKUbc5WVPLzim5ZMtDp/hsykny1Et8IEnoCEBOxRr54dZ9QG6dXfsxtXyH+3p0FdufM GxUUmsDk4jUXsEa8gDuP6w2ZuJnEMKKzM9/OiWk71aFR4/AJbPpXbuAyVM1HbsNAq5D8 84tQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=aCjlwzbn2Lnd6wdxupIG0k16oL0pyn/3JxDZFj3+/1E=; b=Ky8rcMn7lJkrtseOE9uNdx5AxxHgAXAtvJjiHYzdOAZayM/5TyOchAxyY6+wiTyqW5 nscF/wu6QOsxycrxwR0KuIuJNoEBKDwLhuXO9HBV1yYVVFl8lhujzRAqz8kCJ57Plgp7 ufP6l5FMf5WK176xC/YSCRb293kfyG7LpD6Gih6ueOl3tB1Qv7QaSdrV7QwDC5T+RFRH +EmJyixeEIPYMeO3hWZ3x6KSty89hVRl0cbAfTr64yLKQNWMsfsjHDIjRWujpSePzX8N u1gFxKWHRo7D/LiHg8HJQy5XAOjz83cjbfe7AuwiqTZZHtxyLiBqbspQ/TOA1K0UVcWS 5h1w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 65si50589453ple.240.2019.07.27.06.20.32; Sat, 27 Jul 2019 06:20:47 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387653AbfG0NR0 (ORCPT + 99 others); Sat, 27 Jul 2019 09:17:26 -0400 Received: from zeniv.linux.org.uk ([195.92.253.2]:57436 "EHLO ZenIV.linux.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387442AbfG0NR0 (ORCPT ); Sat, 27 Jul 2019 09:17:26 -0400 Received: from viro by ZenIV.linux.org.uk with local (Exim 4.92 #3 (Red Hat Linux)) id 1hrMZZ-0000Tv-SL; Sat, 27 Jul 2019 13:17:18 +0000 Date: Sat, 27 Jul 2019 14:17:17 +0100 From: Al Viro To: "Eric W. Biederman" Cc: Linus Torvalds , Christian Brauner , Linux List Kernel Mailing , David Howells , Miklos Szeredi , linux-fsdevel , Linux API Subject: Re: Regression in 5.3 for some FS_USERNS_MOUNT (aka user-namespace-mountable) filesystems Message-ID: <20190727131717.GQ1131@ZenIV.linux.org.uk> References: <20190726115956.ifj5j4apn3tmwk64@brauner.io> <20190726232220.GM1131@ZenIV.linux.org.uk> <878sskqp7p.fsf@xmission.com> <20190727022826.GO1131@ZenIV.linux.org.uk> <87h877pvv1.fsf@xmission.com> <20190727123705.GP1131@ZenIV.linux.org.uk> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190727123705.GP1131@ZenIV.linux.org.uk> User-Agent: Mutt/1.12.0 (2019-05-25) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Jul 27, 2019 at 01:37:05PM +0100, Al Viro wrote: > > So yes I agree the function of interest is always capable in some form, > > we just need the filesystem specific logic to check to see if we will > > have capable over the filesystem that will be mounted. > > > > I don't doubt that the new mount api has added a few new complexities. > > So far it looks like *in this particular case* complexities would be > reduced - with one exception all your ->permission() instances become > identical. > > Moreover, even in that case we still get the right overall behaviour > with the same instance... PS: For the record * I obviously agree with your reasoning behind making those checks fs-dependent (they have to) and with putting them (back then) into ->mount() instances (since that was the first method called) * I agree (violently) with not liking them done inside ->mount(). * in principle I agree that the stuff like "can that thing be mounted in non-initial userns" might better off as a method rather than a flag. However * these days filesystem *can* have "which userns should the capabilities be checked for?" handled outside ->mount(). Setting fc->user_ns in ->init_fs_context() does just that; the thing is called first in all cases. * with that done we get the same logics for all FS_USERNS_MOUNT filesystems. IOW, all your ->permission() methods would either become NULL (for !FS_USERNS_MOUNT) or, for all non-NULL, identical to each other. All variability between them is already taken care of when we set fc->user_ns. The last one is what makes me somewhat dubious re having that method - it's literally one bit of information encoded into a function pointer. Do you anticipate any cases where the thing would *NOT* be of the same form? I.e. when something is userns-mountable, but the check is not ns_capable(some userns, CAP_SYS_ADMIN)? While we are at it, kobj_ns_...() look like preparations to something that has never fully materialized. What would sysfs mount checks be supposed to do if we'd ever grown more than one struct kobj_ns_type_operations instance? Because that looks like the most plausible case of "we might need trickier ->permission()"...