From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from www262.sakura.ne.jp ([202.181.97.72]:38884 "EHLO www262.sakura.ne.jp" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752915AbeEKKa3 (ORCPT ); Fri, 11 May 2018 06:30:29 -0400 To: miklos@szeredi.hu, viro@zeniv.linux.org.uk Cc: syzbot+32c236387d66c4516827@syzkaller.appspotmail.com, syzkaller-bugs@googlegroups.com, linux-fsdevel@vger.kernel.org Subject: Re: [PATCH] fuse: don't keep inode-less dentry at fuse_ctl_add_dentry(). From: Tetsuo Handa References: <000000000000c0a706056ad69897@google.com> <20180510200753.GU30522@ZenIV.linux.org.uk> In-Reply-To: Message-Id: <201805111930.BEF48997.tJFMOVFLFOHSOQ@I-love.SAKURA.ne.jp> Date: Fri, 11 May 2018 19:30:18 +0900 Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Sender: linux-fsdevel-owner@vger.kernel.org List-ID: Miklos Szeredi wrote: > On Thu, May 10, 2018 at 10:07 PM, Al Viro wrote: > > On Wed, May 09, 2018 at 07:58:58PM +0900, Tetsuo Handa wrote: > >> >From 9f41081f8bd6762a6f629e5e23e6d07a62bba69c Mon Sep 17 00:00:00 2001 > >> From: Tetsuo Handa > >> Date: Sat, 28 Apr 2018 11:24:09 +0900 > >> Subject: [PATCH] fuse: don't keep inode-less dentry at fuse_ctl_add_dentry(). > >> > >> syzbot is reporting NULL pointer dereference at fuse_ctl_remove_conn() [1]. > >> Since fc->ctl_ndents is incremented by fuse_ctl_add_conn() when new_inode() > >> failed, fuse_ctl_remove_conn() reaches an inode-less dentry and tries to > >> clear d_inode(dentry)->i_private field. Fix this by calling dput() rather > >> than incrementing fc->ctl_ndents when new_inode() failed. > > > > That looks bloody awful. Sure, everything that accesses fc->ctl_dentry is > > synchronous with this, but it would've been much easier to follow if > > shoving dentry into that array happened only after it's been fully set > > up. > > > > Incidentally, there's a nasty headache waiting to happen in that code - > > consider a twit mounting something on that. And think what happens when > > connection gets shut down... > > Need to call d_invalidate() instead of d_drop() in there. Is that > what you are referring to? > > Thanks, > Miklos > I couldn't catch what Al is worrying about. I assumed that dput() is fine because proc_setup_thread_self() in fs/proc/thread_self.c is doing dput() when new_inode_pseudo() failed after d_alloc_name().