Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp7060884ybi; Thu, 13 Jun 2019 08:55:37 -0700 (PDT) X-Google-Smtp-Source: APXvYqxrpYBpCZDzBSH0hxx6oeuoTlWNkknBX+eyXmjAyF14qVU/UM6aJXbu8DRgEaORXzJiuTYO X-Received: by 2002:a65:4209:: with SMTP id c9mr32141771pgq.111.1560441337343; Thu, 13 Jun 2019 08:55:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560441337; cv=none; d=google.com; s=arc-20160816; b=tRcrRqwIq2z5219dmm204a/hdDEFC6fLhBSKBoqE41+LYYRCIAnKllcplRBfVemaFD N7VEdszyjc/bhVVtd0bTSOQ7Z+3ptRlqN3bfqgfzySsx9KNf5JYgSCCtqGoW8m8YRA4A 0VWluDFNGLird5JFobMrmIzZjX8nosJ1+dPoUo/pn8X5p5sYIMsmSqazEiJFF+LzobFQ LXGmaXFl+MYWicOvhSnN/9n3oqFzbB0kFt7GqJQ1j93YGnqXldjONXbPS6JH8Kssy0A2 wm/NHmDavSXg25CPV86+DFXgFVEfbuL5+HYYNmadg/n5z7vOTzggc6hfzEBWP1in8Pfk j+FA== 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=n1hvh6IrXuWCx6GN0u/M5kwkhjeM4Gvq8F3PXY4eBB8=; b=RPAv5cgLdyWqYMH0WD5TmX0ndBPG4grSU/IHTuyMcGSvuaAMPGN4C5IQQK47weR1GA n4z13t0V/spafAgmHW6pX2jfw+fUCSzW1RQJHdiebJWRsgKp/wKI1OTx9YqAnQGWeHDY K5OG29ptSXZhu8Re/EcCI5dui0hnsWjRqrZqKZ0cCFiccka/hxc+06VXdVB3iMpOGY3X ACvoYiHdJlbEUunRjei/LBCjTwuqBWO/29OlllH3pS9E46vNnhBFr5J7XNh1sJzdGLaM tjHTTK728/ajtTJVu/5irwVeiUYmnhmf5soh3HuAFqngqi00J1ZwIrA61Y/oMZNkHSyJ UA9Q== 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 r14si52803pjp.95.2019.06.13.08.55.22; Thu, 13 Jun 2019 08:55:37 -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 S2388987AbfFMPxW (ORCPT + 99 others); Thu, 13 Jun 2019 11:53:22 -0400 Received: from foss.arm.com ([217.140.110.172]:36722 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731617AbfFMJDQ (ORCPT ); Thu, 13 Jun 2019 05:03:16 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id E8B92367; Thu, 13 Jun 2019 02:03:15 -0700 (PDT) Received: from lakrids.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.121.207.14]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 22DCB3F694; Thu, 13 Jun 2019 02:03:15 -0700 (PDT) Date: Thu, 13 Jun 2019 10:03:06 +0100 From: Mark Rutland To: Eric Biggers Cc: David Howells , Alexander Viro , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] vfs: fsmount: add missing mntget() Message-ID: <20190613090305.GA40885@lakrids.cambridge.arm.com> References: <20190610183031.GE63833@gmail.com> <20190612184313.143456-1-ebiggers@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190612184313.143456-1-ebiggers@kernel.org> User-Agent: Mutt/1.11.1+11 (2f07cb52) (2018-12-01) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jun 12, 2019 at 11:43:13AM -0700, Eric Biggers wrote: > From: Eric Biggers > > sys_fsmount() needs to take a reference to the new mount when adding it > to the anonymous mount namespace. Otherwise the filesystem can be > unmounted while it's still in use, as found by syzkaller. > > Reported-by: Mark Rutland > Reported-by: syzbot+99de05d099a170867f22@syzkaller.appspotmail.com > Reported-by: syzbot+7008b8b8ba7df475fdc8@syzkaller.appspotmail.com > Fixes: 93766fbd2696 ("vfs: syscall: Add fsmount() to create a mount for a superblock") > Signed-off-by: Eric Biggers With this patch applied, my reproducer from [1] no longer triggers the issue. I polled /proc/meminfo, and don't see any leak. FWIW: Tested-by: Mark Rutland Thanks for fixing this! Mark. [1] https://lore.kernel.org/lkml/20190605135401.GB30925@lakrids.cambridge.arm.com/ > --- > fs/namespace.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/fs/namespace.c b/fs/namespace.c > index b26778bdc236e..5dc137a22d406 100644 > --- a/fs/namespace.c > +++ b/fs/namespace.c > @@ -3445,6 +3445,7 @@ SYSCALL_DEFINE3(fsmount, int, fs_fd, unsigned int, flags, > ns->root = mnt; > ns->mounts = 1; > list_add(&mnt->mnt_list, &ns->list); > + mntget(newmount.mnt); > > /* Attach to an apparent O_PATH fd with a note that we need to unmount > * it, not just simply put it. > -- > 2.22.0.rc2.383.gf4fbbf30c2-goog >