Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3954774imu; Fri, 30 Nov 2018 08:33:44 -0800 (PST) X-Google-Smtp-Source: AFSGD/WWSlv9zq+aetWUIbRXpU3omfgsne/TZ0ESI2bt7ZMvdB5Yt5jh0BgCy3jo4B+PQcHUkmhY X-Received: by 2002:a17:902:9a4c:: with SMTP id x12mr6150454plv.94.1543595624155; Fri, 30 Nov 2018 08:33:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543595624; cv=none; d=google.com; s=arc-20160816; b=cRVR2rHkBJMs+J//mVeao58AoV2hIXfeJpSNzGJmYafesj28EFtQm9NeBYTWEeOO8A WAB/z/qVck6gSzgU3PgxXWCmRmgFm7TJJGlTp2YjVH6srPIpMQDtNh2y6xsDT/0bupu2 xUz0fPCLIAFq9hHjZmPxy6/R6yxr2aGvmUV0Z4trcR8v66j4rP5hukG2zzpbsxGiscAW VH8PfhmfUB5qszO/ZN7VRiSIK1Y3Qx/3A5+bLWwdVLm64JMqJAP4wNygeDTNu5cgnp0/ WAS3eFOeIG4/MNavicNZo5eTRRzS6KQov1avLyRsP3tHg3mEz98ma9YdhZRgLLvnwfbV Bouw== 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=sTgnW4yMACFcNJsjrT9up6TzvHvzKTfYY5edvOwupqQ=; b=Dge89n3V6rmZ/ghkaPZ11DFLPLSicyile5neSPBPszYLbhrYufApgH9Gze0mhkZ5e3 HUMK7TgMj/VlGUc0FijIF/YjKDMmIt78uBaJhKXaP57meOEZyILyz5xVCFvGG8vJSNY3 MnPq8erC9rGsI+Cs7zY/JQWcd4fWuN/RSdILhJwYH97KhZVdxh5tgN+fDjBUhjqa1Xmq enbOI3juEmSRO+lvy7HD2d4aKeBd155ljGIze7y06pnE52ob4L1e6d78V7iNOK4D9uUE cqLAl7hxjmRgukirYuDmShHy9J16zFsD9FG/5lKKGNA3ULgagU9OVuRmqrQM2LB/Z2mM dazg== 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 d195si5979780pfd.93.2018.11.30.08.33.18; Fri, 30 Nov 2018 08:33:44 -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 S1726881AbeLADmC (ORCPT + 99 others); Fri, 30 Nov 2018 22:42:02 -0500 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:60408 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726644AbeLADmC (ORCPT ); Fri, 30 Nov 2018 22:42:02 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 02194EBD; Fri, 30 Nov 2018 08:32:10 -0800 (PST) Received: from edgewater-inn.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.72.51.249]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id C67113F5AF; Fri, 30 Nov 2018 08:32:09 -0800 (PST) Received: by edgewater-inn.cambridge.arm.com (Postfix, from userid 1000) id 92BDA1AE12BC; Fri, 30 Nov 2018 16:32:28 +0000 (GMT) Date: Fri, 30 Nov 2018 16:32:28 +0000 From: Will Deacon To: Al Viro Cc: "Eric W. Biederman" , "gregkh@linuxfoundation.org" , Jan Glauber , "linux-fsdevel@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "jslaby@suse.com" Subject: Re: dcache_readdir NULL inode oops Message-ID: <20181130163228.GA10964@arm.com> References: <20181110111656.GA16667@hc> <20181120182854.GC28838@arm.com> <20181120190317.GA29161@arm.com> <20181121131900.GA18931@hc> <20181123180525.GA21017@arm.com> <20181128200806.GC32668@arm.com> <20181129184950.GA7290@hc> <20181130104154.GA11991@kroah.com> <875zwe389q.fsf@xmission.com> <20181130160852.GN2217@ZenIV.linux.org.uk> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20181130160852.GN2217@ZenIV.linux.org.uk> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Nov 30, 2018 at 04:08:52PM +0000, Al Viro wrote: > On Fri, Nov 30, 2018 at 09:16:49AM -0600, Eric W. Biederman wrote: > > >> > + inode_lock(parent->d_inode); > > >> > dentry->d_fsdata = NULL; > > >> > drop_nlink(dentry->d_inode); > > >> > d_delete(dentry); > > >> > + inode_unlock(parent->d_inode); > > >> > + > > >> > dput(dentry); /* d_alloc_name() in devpts_pty_new() */ > > >> > } > > > > > > This feels right but getting some feedback from others would be good. > > > > This is going to be special at least because we are not coming through > > the normal unlink path and we are manipulating the dcache. > > > > This looks plausible. If this is whats going on then we have had this > > bug for a very long time. I will see if I can make some time. > > > > It looks like in the general case everything is serialized by the > > devpts_mutex. I wonder if just changing the order of operations > > here would be enough. > > > > AKA: drop_nlink d_delete then dentry->d_fsdata. Ugh d_fsdata is not > > implicated so that won't help here. > > It certainly won't. The thing is, this > if (!dir_emit(ctx, next->d_name.name, next->d_name.len, > d_inode(next)->i_ino, dt_type(d_inode(next)))) > in dcache_readdir() obviously can block, so all we can hold over it is > blocking locks. Which we do - specifically, ->i_rwsem on our directory. > > It's actually worse than missing inode_lock() - consider the effects > of mount --bind /mnt/foo /dev/pts/42. What happens when that thing > goes away? Right, a lost mount... Ha, I hadn't even considered that scenario. Urgh! > I'll resurrect the "kernel-internal rm -rf done right" series and > post it; devpts is not the only place suffering such problem (binfmt_misc, > etc.) Thanks. I'm happy to test that it solves this issue if you throw me on cc. Will