Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp7670393rdb; Thu, 4 Jan 2024 04:14:55 -0800 (PST) X-Google-Smtp-Source: AGHT+IGAX9BaDXPA6NIXkCxvot1h4jtJiBKb5lnL4gZsoujFFK3Au0hvbQb4Ia8TDEYX80wEN2GJ X-Received: by 2002:a17:90a:1142:b0:285:8a2a:1744 with SMTP id d2-20020a17090a114200b002858a2a1744mr381813pje.0.1704370495301; Thu, 04 Jan 2024 04:14:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704370495; cv=none; d=google.com; s=arc-20160816; b=HWWs6kpwZQhXrU8wf0ZStfxBCEVW9qfGOz1L832V3FqgHdk/CKqJjYXZMv4+2ZtitL MZO949RaPLnThpRLhJv8aRX+NrVtDTkmPgl0PaXCP1WkxWLCuCi5Yrq+Yx9kQuSDVPvC nmts0xE8XfP12ebAaROaVZSSr/nrYsW+Dpl6ankC6rNvo+8vMG6XvriBwahNGgYM2JqY Q5GjPpmBwA7kOMBVagIzrJiU6ZQ9vBg6GC5sca4Nx2mW56ASYMxKz9ZhUs4q2iidE3cG t2CWgiP9dT3+pouDvnWOL0s76EzO7j0vN11+V5zFW6w08i9+mjcv5AhQjr5WIMjKITbL fUdw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=fE0KotzFH+YWUKt15FwiXDTejYklHvADvzLvOeVbHns=; fh=hJNTCDtgS3PkNW4UT6wu69MxXhmbp+MUckWtpsv/p4E=; b=HAQryknj+lOV9rbXDa1PHKcdROMU8/9gDxrKRHT/VJngjgRr4Fj1UA5q2ZINUlceqJ jvkC+KTPESzwGWsnB7R61w9mYPP1LKcCLP4xUqQmHo1j+JBJda9fFdS18yB5ZgQhqEqt ooC39/m7Nwp837+eb9O8Z//I/949pEpyNhv3+RMvuD7h2Foh34B1P5dfJ56/zANY5UMo ndnuJ+UOIf8HFa0NuPtC4gWOLYhGFlQ04g3lCDz2QM+oaI8OmKtbMuZFpUlIt8WI4khg 1rKiLb7CNYO+T0Br2/5G30KhwUEDWgxMl4B3dy5evih0bp9iOryXVwTKdQy/fQl/EkeT Re1w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Jv4RQtrT; spf=pass (google.com: domain of linux-nfs+bounces-923-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-nfs+bounces-923-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id q3-20020a17090aa00300b0028c03cee45dsi2865775pjp.68.2024.01.04.04.14.54 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Jan 2024 04:14:55 -0800 (PST) Received-SPF: pass (google.com: domain of linux-nfs+bounces-923-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Jv4RQtrT; spf=pass (google.com: domain of linux-nfs+bounces-923-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-nfs+bounces-923-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id AD3D5B243B7 for ; Thu, 4 Jan 2024 12:13:59 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D102F21369; Thu, 4 Jan 2024 12:13:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="Jv4RQtrT" X-Original-To: linux-nfs@vger.kernel.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4A5D02137A for ; Thu, 4 Jan 2024 12:13:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1704370434; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=fE0KotzFH+YWUKt15FwiXDTejYklHvADvzLvOeVbHns=; b=Jv4RQtrTLOJxuToFhLGbAw0HPg3TOUYOF6ztvUVqW9oPn5RW2LWf24qMbS6Q/8xrLC72i1 4nbut35rDwhTRfVZ1kzbnRwL4Fvwq0mGNl8J+/OZIJljLTjV0Ho1tFGUi0JNaK5rYQRArH GQUoo5+IgnuwuORQTVnAJN+NdDob+5o= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-605-8W4_B05wNlm6ZJEJBQFZxQ-1; Thu, 04 Jan 2024 07:13:52 -0500 X-MC-Unique: 8W4_B05wNlm6ZJEJBQFZxQ-1 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 3F23D3813BC1; Thu, 4 Jan 2024 12:13:52 +0000 (UTC) Received: from [100.85.132.103] (ovpn-0-5.rdu2.redhat.com [10.22.0.5]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A22A0492BC6; Thu, 4 Jan 2024 12:13:51 +0000 (UTC) From: Benjamin Coddington To: Trond Myklebust , anna@kernel.org Cc: linux-nfs@vger.kernel.org Subject: Re: [PATCH v3 2/2] NFSv4.1: Use the nfs_client's rpc timeouts for backchannel Date: Thu, 04 Jan 2024 07:13:50 -0500 Message-ID: <47231988-6BE0-4A1C-93CE-F5D14600BA8F@redhat.com> In-Reply-To: <25DCF24F-FB84-4A52-A66E-63A445197AB6@redhat.com> References: <90c9365ad91e1eb0058b170fb332ea70ad554d8b.1702496910.git.bcodding@redhat.com> <1aa005d1c0b344a455ced93be866dff3c316e15e.camel@hammerspace.com> <25DCF24F-FB84-4A52-A66E-63A445197AB6@redhat.com> Precedence: bulk X-Mailing-List: linux-nfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.9 On 4 Jan 2024, at 6:55, Benjamin Coddington wrote: > On 3 Jan 2024, at 18:00, Trond Myklebust wrote: > >> On Wed, 2024-01-03 at 16:45 -0500, Anna Schumaker wrote: >>> Hi Ben, >>> >>> On Wed, Dec 13, 2023 at 2:49 PM Benjamin Coddington >>> wrote: >>>> >>>> For backchannel requests that lookup the appropriate nfs_client, >>>> use the >>>> state-management rpc_clnt's rpc_timeout parameters for the >>>> backchannel's >>>> response.  When the nfs_client cannot be found, fall back to using >>>> the >>>> xprt's default timeout parameters. >>> >>> I'm seeing a use-after-free after applying this patch when using pNFS >>> and session trunking. Any idea what's going on? Here is the stack >>> trace I'm seeing: >> >> I'm going to guess that this is happening because nothing is clearing >> rqstp->bc_rpc_clnt after a call to svc_process_bc(). So if something >> later calls CB_NULL, then the resulting svc_process_bc() will free an >> extra reference. > > Doh! > >>> >>> I hit this while testing against ontap, if that helps. >>> >>> Thanks, >>> Anna > > Thank you for the test!! > >>>> --- a/fs/nfs/callback_xdr.c >>>> +++ b/fs/nfs/callback_xdr.c >>>> @@ -967,6 +967,9 @@ static __be32 nfs4_callback_compound(struct >>>> svc_rqst *rqstp) >>>>                 nops--; >>>>         } >>>> >>>> +       if (svc_is_backchannel(rqstp) && cps.clp) >>>> +               rqstp->bc_rpc_clnt = cps.clp->cl_rpcclient; >> >> >> You can re-create the clnt->cl_timeout in svc_process_bc() by just >> storing the values of to_initval and to_retrans here. Why store a >> reference to an entire rpc client structure that you don't need? > > Hmm, I think I started by thinking we could simply set tk_client, but then > didn't end up with that for other reasons and just kept passing the single > pointer. .. and the client being NULL was the signal to fallback to using the xprt timeouts. That's lost with to_initval and to_retries because they can be set to zero deliberately. I'm not immediately seeing an easy way to carry all that info across on the svc_rqst without three additional fields or another struct. Either we drop the part where we fallback to the xprt defaults, or things get a bit uglier. Ben