Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp3275001yba; Sat, 18 May 2019 13:12:41 -0700 (PDT) X-Google-Smtp-Source: APXvYqznHkhvHV5B4/7gPBKBNl2oEsfTeY5XfAfR6bHQJ/7CgUBULM69wcyYVG1HHbNGNlARZ3Ic X-Received: by 2002:a62:2706:: with SMTP id n6mr1161108pfn.150.1558210360911; Sat, 18 May 2019 13:12:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558210360; cv=none; d=google.com; s=arc-20160816; b=SXyUJJfRxrJqhuD0gs/GLb2gLj4R960wDC84LlxfGDvZZEJ9DfaSLvMtCQ1aZ943zr TXExdRzKDFjli83G+ZycmLEsUXtkJyXyqVnY0ui6sIXj77DvCdktoY8XjT2iNCPp+NFn FrkwjsdWsQ3VignnJnEmlZ86sW3Kvd1WKdVX4NfmkQuoYOL2+y/nMtoaFkvvOO5dV+kW s4CR3mhoMmX3bhRUyryk7I/b6wuPd95d1U5v+FGJ0o3+Mc7QcyWQ++rKzteh4EI2XY9e ozo/BK2S7/kDmUc6ci1ouJGW5RYLSgrHu26bP68WHFvTdfo4lQVZslE7JjMmwh4MlpiM NCXQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:from:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:date; bh=Nc57fAwdJKHCdvUsoekkqg7waHRFHzIQ+0DMhK7Yz1A=; b=ZPfFbZxj6c1E45qfHk3qvWX72EQnIii3wG1WIh3CfoRMAfh4oY72LpjPMuztrDhvpJ GEUz9jNidhSPk9PyPEsGjswoiJJNjKsglPvRXl0nZQHdiCRF5v6d0xTE+5ZtwBAZRvDg OQ5WwXUKygZGEOsCSonglbAGUSvr1/Q6PpZDzgDTAGhyvrDKN0ZOhiOzBEX0h8ZZlhtO z/dkW4DjAnVaFiC1TzUiLH6ERTsQY5eep3AfB3Y2akTKaqwULzESXkjQy5knJ3GfQCwQ RCVK+LeR2onxH8JmB/tH4rX1sCQkhJa48IsjTkb5yJq+gZb3bW+DykawiLPEF7Mo9xSa 1h8w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-nfs-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-nfs-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 v16si12590792pgk.431.2019.05.18.13.12.13; Sat, 18 May 2019 13:12:40 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-nfs-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-nfs-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727620AbfERUEL (ORCPT + 99 others); Sat, 18 May 2019 16:04:11 -0400 Received: from fieldses.org ([173.255.197.46]:55060 "EHLO fieldses.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725950AbfERUEL (ORCPT ); Sat, 18 May 2019 16:04:11 -0400 Received: by fieldses.org (Postfix, from userid 2815) id 535441C81; Sat, 18 May 2019 16:04:11 -0400 (EDT) Date: Sat, 18 May 2019 16:04:11 -0400 To: "J. Bruce Fields" Cc: linux-nfs@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: Re: [PATCH 1/2] nfsd: allow fh_want_write to be called twice Message-ID: <20190518200411.GB32684@fieldses.org> References: <1557969619-17157-1-git-send-email-bfields@redhat.com> <1557969619-17157-2-git-send-email-bfields@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1557969619-17157-2-git-send-email-bfields@redhat.com> User-Agent: Mutt/1.5.21 (2010-09-15) From: bfields@fieldses.org (J. Bruce Fields) Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org Ugh, sorry, ignore the two old patches that got sent with the new series. --b. On Wed, May 15, 2019 at 09:20:06PM -0400, J. Bruce Fields wrote: > From: "J. Bruce Fields" > > A fuzzer recently triggered lockdep warnings about potential sb_writers > deadlocks caused by fh_want_write(). > > Looks like we aren't careful to pair each fh_want_write() with an > fh_drop_write(). > > It's not normally a problem since fh_put() will call fh_drop_write() for > us. And was OK for NFSv3 where we'd do one operation that might call > fh_want_write(), and then put the filehandle. > > But an NFSv4 protocol fuzzer can do weird things like call unlink twice > in a compound, and then we get into trouble. > > I'm a little worried about this approach of just leaving everything to > fh_put(). But I think there are probably a lot of > fh_want_write()/fh_drop_write() imbalances so for now I think we need it > to be more forgiving. > > Signed-off-by: J. Bruce Fields > --- > fs/nfsd/vfs.h | 5 ++++- > 1 file changed, 4 insertions(+), 1 deletion(-) > > diff --git a/fs/nfsd/vfs.h b/fs/nfsd/vfs.h > index a7e107309f76..db351247892d 100644 > --- a/fs/nfsd/vfs.h > +++ b/fs/nfsd/vfs.h > @@ -120,8 +120,11 @@ void nfsd_put_raparams(struct file *file, struct raparms *ra); > > static inline int fh_want_write(struct svc_fh *fh) > { > - int ret = mnt_want_write(fh->fh_export->ex_path.mnt); > + int ret; > > + if (fh->fh_want_write) > + return 0; > + ret = mnt_want_write(fh->fh_export->ex_path.mnt); > if (!ret) > fh->fh_want_write = true; > return ret; > -- > 2.21.0