Received: by 2002:a05:6602:18e:0:0:0:0 with SMTP id m14csp2484843ioo; Mon, 23 May 2022 21:28:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzw/Xq3wpWYFQJ1FM1ZLwlkADjQrwcRlS7fAr8PRk43jhiZ00AXeY/I9sTD9kRoG0Cn859h X-Received: by 2002:a17:907:980d:b0:6fa:3748:3f15 with SMTP id ji13-20020a170907980d00b006fa37483f15mr22776104ejc.731.1653366489751; Mon, 23 May 2022 21:28:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653366489; cv=none; d=google.com; s=arc-20160816; b=I5cfotCCEnbcIO3pqKjXfrMwsTV2k1jk1Hj+fW7LUO/ctkKld8YrLCso7SPZPEQwKO i7HA7xSHLTmSLTo7L1vh2Z2wcG0YMt2WQR6x301RPduJRjoBqgzo5kcLtKjouja/7QjT dShEGII4QDEp3yeb3y2FjTxFM1bfXZ5SN67eaim6nj1Jy3RQyO7WHTv9O9hSWp377JKX TqPgdZRm43I3kpiXtI85Vu2fXmj9MeAFD29ipt3fAyN02HojNCwYXc78MX5BkBFA3rA5 0bxLL4G7G4hH9jhP6o2mjD3OXomRtdgRCc/EDnVj2nQ0rG7CQhEOHPhUtQ2SjpSzE98W Rhqw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature:dkim-filter; bh=zPKtMSnuEl/NXLzAIfOK128Jcnh9ul+Fd7xjm3yifHk=; b=YgYjvgvfBLgTv3jqkaF8AMz5sCMYRLgIHScaGuuuv5K/h/J3/FhhaEdhgWwznfIx0F +CaXMRr3aGnLhiJLZjkmxwAqC5y9/SO8CeGNN+LxasZB97L7mMsRYtyGfhc4J1+TIYt4 1Ft++FFAoAWfm3Mrw33ztBWYqsvKVqJ9QOH8dXNogfFHET7xHPSINZJoNS51gaMJ+Yl9 5LY22jvonysuEjsaQg2kaE6IZFalmn699K4byXpYdVerICdthp8WOq4ueuaZDYNAeKWQ 9QvTAiaaczodCFceoyr0G//BbEJZmaHSAMct3A21heW1u1OutLtT7X8fihm4l492Ydpb LvQA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@fieldses.org header.s=default header.b=szHp7uhx; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=fieldses.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ne36-20020a1709077ba400b006fef773d9d5si3678316ejc.1002.2022.05.23.21.27.30; Mon, 23 May 2022 21:28:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@fieldses.org header.s=default header.b=szHp7uhx; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=fieldses.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229892AbiEXAH4 (ORCPT + 99 others); Mon, 23 May 2022 20:07:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46074 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229530AbiEXAH4 (ORCPT ); Mon, 23 May 2022 20:07:56 -0400 Received: from fieldses.org (fieldses.org [IPv6:2600:3c00:e000:2f7::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A465E9BAD9 for ; Mon, 23 May 2022 17:07:55 -0700 (PDT) Received: by fieldses.org (Postfix, from userid 2815) id CDFEC7083; Mon, 23 May 2022 20:07:54 -0400 (EDT) DKIM-Filter: OpenDKIM Filter v2.11.0 fieldses.org CDFEC7083 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fieldses.org; s=default; t=1653350874; bh=zPKtMSnuEl/NXLzAIfOK128Jcnh9ul+Fd7xjm3yifHk=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=szHp7uhx0cffCD1NvbrGsA2uxklfNCkp1u20Yzs7oOweVEhAcnhqUheUKsIz1jfH2 wuTmnIP3sdMESCOpbvtHqmTl4AVc1ma9f060Ivy23Axn/C+HAB4G15lUewHQOar8Ub oz7325/3Uk9TQe71WSrQwPCjYsVF/XvYZIjJYI48= Date: Mon, 23 May 2022 20:07:54 -0400 From: "J. Bruce Fields" To: Jeff Layton Cc: Chuck Lever III , Trond Myklebust , Linux NFS Mailing List Subject: Re: [PATCH RFC] NFSD: Fix possible sleep during nfsd4_release_lockowner() Message-ID: <20220524000754.GB31155@fieldses.org> References: <93d11e12532f5a10153d3702100271f70373bce6.camel@hammerspace.com> <5dfbc622c9ab70af5e4a664f9ae03b7ed659e8ac.camel@hammerspace.com> <17007994486027de807d80dfde1a716c3d127de1.camel@kernel.org> <20220523202938.GJ24163@fieldses.org> <20220523212816.GA31155@fieldses.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220523212816.GA31155@fieldses.org> User-Agent: Mutt/1.5.21 (2010-09-15) X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org On Mon, May 23, 2022 at 05:28:16PM -0400, J. Bruce Fields wrote: > On Mon, May 23, 2022 at 05:15:55PM -0400, Jeff Layton wrote: > > On Mon, 2022-05-23 at 16:29 -0400, J. Bruce Fields wrote: > > > On Mon, May 23, 2022 at 03:36:27PM -0400, Jeff Layton wrote: > > > > The other lockowner _is_ involved. It's the one holding the conflicting > > > > lock. nfs4_set_lock_denied copies info from the conflicting lockowner > > > > into the LOCK/LOCKT response. That's safe now because it holds a > > > > reference to the owner. At one point it wasn't (see commit aef9583b234a4 > > > > "NFSD: Get reference of lockowner when coping file_lock", which fixed > > > > that). > > > > > > I doubt that commit fixed the whole problem, for what it's worth. What > > > if the client holding the conflicting lock expires before we get to > > > nfs4_set_lock_denied? > > > > > > > Good point -- stateowners can't hold a client reference. > > > > clientid_t is 64 bits, so one thing we could do is just keep a copy of > > that in the lockowner. That way we wouldn't need to dereference > > so_client in nfs4_set_lock_denied. > > > > Maybe there are better ways to fix it though. > > I kinda feel like lock and testlock should both take a > > struct conflock { > void *data > void (*copier)(struct file_lock, struct conflock) > } > > and the caller should provide a "copier" that they can use to extract > the data they want while the flc_lock is held. > > I'm probably overthinking it. But in any case note the problem isn't just the copy of the clientid_t; nfs4_put_stateowner also dereferences the client. --b.