Received: by 2002:a25:c205:0:0:0:0:0 with SMTP id s5csp7225875ybf; Fri, 6 Mar 2020 12:57:08 -0800 (PST) X-Google-Smtp-Source: ADFU+vu1fQHujYRXpfJr8PMZPO11eMk1fNxwn0tP1d06EXfSEnRNWLq+BJ1ZUl4AR1gPq8Dv+j7l X-Received: by 2002:a54:4403:: with SMTP id k3mr3795881oiw.111.1583528228410; Fri, 06 Mar 2020 12:57:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1583528228; cv=none; d=google.com; s=arc-20160816; b=E5gqEgCHRCn+wntWLu9q4NNJ1fif69O4G8mvFO+1mZ8k66SQn/YKvb7bnfjg1I5qFk TOdN66pIVTpyTMT2K5nR/h9YJkTAK6h2BnrsC4/7CYxBI15vfdXqrWq00iYWTJGGLSM4 vdVx9HxE9muviimHQmDELPQpLuP1c6R10usEBUqjWWm4MbdPaZzUtcZbIJ386VENR0wU i3YgHN6jFY6s4/M9vVgJwZujzR2/AdisPCKSM+K1uBp+AZVMu+uWP5fQ95GjOr0xermE 0hFfKVO9Qv63uWQP23e1K+Uo3AleStCCpHvaZksta16ajCdO7VndfHgNn1wYFzZwkWaG 23vg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=UH9B4kZavQJviK2CkDU70UqZQcrZzaBhLpk44/luFqg=; b=DB+iwiM+5kjEGM+fAlaHAv7aI3QKD8FEZzic1GD1eVlkqHtBnQcnxV9JCTgGExCPJz lwmIK5CoCiSSkZo8kK3nCGklF/IBZR5iNBV3+DQMe+0/6Y+TWMzRjG6CZp4tFHQDmDgF MiicvthYmySR0w8p0vUw8/02dMivhiDhrNBVSeMS9b0EI/UbwEg5tUPGJjQUVD+4LJKd +lz1rNnS9cOvMQsIEwS/ZAtAhQOuDjuY7/w4FWSLAzvlnPnpUg61wti/9gvas7tGftNp d673tOJSdyqjJPbgGe+zLO4kDlfnzo+dfFFHASMmvnu7pK/wNWl4AvZrfnMoYwDH6z8t 0gKg== 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 u207si303187oia.176.2020.03.06.12.56.56; Fri, 06 Mar 2020 12:57:08 -0800 (PST) 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 S1726892AbgCFU43 (ORCPT + 99 others); Fri, 6 Mar 2020 15:56:29 -0500 Received: from zeniv.linux.org.uk ([195.92.253.2]:39290 "EHLO ZenIV.linux.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726185AbgCFU43 (ORCPT ); Fri, 6 Mar 2020 15:56:29 -0500 Received: from viro by ZenIV.linux.org.uk with local (Exim 4.92.3 #3 (Red Hat Linux)) id 1jAK14-006Uhe-Ur; Fri, 06 Mar 2020 20:56:19 +0000 Date: Fri, 6 Mar 2020 20:56:18 +0000 From: Al Viro To: Miklos Szeredi Cc: Ian Kent , David Howells , Christian Brauner , James Bottomley , Steven Whitehouse , Miklos Szeredi , Christian Brauner , Jann Horn , "Darrick J. Wong" , Linux API , linux-fsdevel , lkml , Greg Kroah-Hartman Subject: Re: [PATCH 00/17] VFS: Filesystem information and notifications [ver #17] Message-ID: <20200306205618.GF23230@ZenIV.linux.org.uk> References: <0403cda7345e34c800eec8e2870a1917a8c07e5c.camel@themaw.net> <20200306162549.GA28467@miu.piliscsaba.redhat.com> <20200306194322.GY23230@ZenIV.linux.org.uk> <20200306195823.GZ23230@ZenIV.linux.org.uk> <20200306200522.GA23230@ZenIV.linux.org.uk> <20200306203705.GB23230@ZenIV.linux.org.uk> <20200306203844.GC23230@ZenIV.linux.org.uk> <20200306204523.GD23230@ZenIV.linux.org.uk> <20200306204926.GE23230@ZenIV.linux.org.uk> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200306204926.GE23230@ZenIV.linux.org.uk> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Mar 06, 2020 at 08:49:26PM +0000, Al Viro wrote: > On Fri, Mar 06, 2020 at 08:45:23PM +0000, Al Viro wrote: > > On Fri, Mar 06, 2020 at 08:38:44PM +0000, Al Viro wrote: > > > On Fri, Mar 06, 2020 at 08:37:05PM +0000, Al Viro wrote: > > > > > > > You are misreading mntput_no_expire(), BTW - your get_mount() can > > > > bloody well race with umount(2), hitting the moment when we are done > > > > figuring out whether it's busy but hadn't cleaned ->mnt_ns (let alone > > > > set MNT_DOOMED) yet. If somebody calls umount(2) on a filesystem that > > > > is not mounted anywhere else, they are not supposed to see the sucker > > > > return 0 until the filesystem is shut down. You break that. > > > > > > While we are at it, d_alloc_parallel() requires i_rwsem on parent held > > > at least shared. > > > > Egads... Let me see if I got it right - you are providing procfs symlinks > > to objects on the internal mount of that thing. And those objects happen > > to be directories, so one can get to their parent that way. Or am I misreading > > that thing? > > IDGI. You have (in your lookup) kstrtoul, followed by snprintf, followed > by strcmp and WARN_ON() in case of mismatch? Is there any point in having > stat(2) on "00" spew into syslog? Confused... AFAICS, refcounting in there cannot be right: +static struct dentry *mountfs_lookup(struct inode *dir, struct dentry *dentry, + unsigned int flags) +{ + struct mountfs_entry *entry = dir->i_private; + int i = 0; + + if (entry) { + for (i = 0; i < ARRAY_SIZE(mountfs_attrs); i++) + if (strcmp(mountfs_attrs[i], dentry->d_name.name) == 0) + break; + if (i == ARRAY_SIZE(mountfs_attrs)) + return ERR_PTR(-ENOMEM); + i++; + } else { + entry = mountfs_get_entry(dentry->d_name.name); + if (!entry) + return ERR_PTR(-ENOENT); + } + + return mountfs_lookup_entry(dentry, entry, i); +} ends up consuming a reference in mountfs_lookup_entry() (at the very least, drops it in case of inode allocation hitting OOM) and nothing in the that loop in mountfs_lookup() appears to do a matching reference grab.