Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp7660114rdb; Thu, 4 Jan 2024 03:56:22 -0800 (PST) X-Google-Smtp-Source: AGHT+IH4AMZtBAvDIAN4KZ7FsoIdYFH+Ii2Dhw7YX9GRDZwWtuXhrQInld5VPO514TREeP36i9tD X-Received: by 2002:ad4:5dec:0:b0:680:c616:7a22 with SMTP id jn12-20020ad45dec000000b00680c6167a22mr456983qvb.121.1704369382369; Thu, 04 Jan 2024 03:56:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704369382; cv=none; d=google.com; s=arc-20160816; b=GHHPCg1XQeUWGzddhrn9hiirqVUYtbZA4xp8VqoiOqhSPYx+BYCd8VBruQjCywmjcB RrsXSPJAk164Uy1YENsTByXnhxBZXAUJnvg5PlgXOovyQ/iVTuj5jiZd+caiMewCTAcf ErD1R4H8kZvP8GzmgnYaHrFPXd85PvM3SiMcOSgrCBo57P1C+XlRGSahi48ylF98GR0y rWXwyHUeEHUT3Bvmn/cePs5WBTLzpYIauXUOR1/Ah+2kFoZ/ib1FRK/GqwdFskLVHzHk 1EMiwyFN6R2EJRlC0XNCd5PJZmSKhBhfvlI0el+nw/7XqgEwsFKVG1psgafbRbrQZN14 EC9g== 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=DEgmA49MzeAdHJu8hJGVoYylU8Sm0te82PfQumrL6p4=; fh=hJNTCDtgS3PkNW4UT6wu69MxXhmbp+MUckWtpsv/p4E=; b=cbBH1RRz3/XqD6p8TlhB/O6v7b5+ZTnWn6XFXYfVz5GDJ6VwPZ5QNzC5CxvkRTtiRc xwk8JoPH2nyGxSm0HkZuISFvhzTt5/Ng4huCdZQIcuX87Ywb1c6uFE3k2fR5uaenVQjI 4ilNURUxrxq5bSPwn3JKSxb72I+6yvjmjiOnRxgNuiNswO0kkCjFlR5cUVRfk12F0HgH 1cwv1psfkME6dE9H2x0g48esYJTmoPlk4Q0GSyam8HL0CZ9MTblWASbQGjep/0i9Y9bs VonJJqZfpVDWmDLk1XBjavkzlqUL09RttDVVHNfJKtgFyjQ3hRkvxl/FUQH45/A3Mjex SFyg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="ioJY4M/G"; spf=pass (google.com: domain of linux-nfs+bounces-922-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-nfs+bounces-922-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id d12-20020a05620a158c00b00781935e3a74si13297416qkk.104.2024.01.04.03.56.22 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Jan 2024 03:56:22 -0800 (PST) Received-SPF: pass (google.com: domain of linux-nfs+bounces-922-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="ioJY4M/G"; spf=pass (google.com: domain of linux-nfs+bounces-922-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-nfs+bounces-922-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 2481B1C21B2E for ; Thu, 4 Jan 2024 11:56:22 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4C1102135B; Thu, 4 Jan 2024 11:56:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="ioJY4M/G" 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 9E0C521359 for ; Thu, 4 Jan 2024 11:55:58 +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=1704369357; 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=DEgmA49MzeAdHJu8hJGVoYylU8Sm0te82PfQumrL6p4=; b=ioJY4M/GjSDt0423K6wtO5ogbPNCyMk1kGSR2eF5c/lo0GGJyPSJ3XCex7MmwuHiYA0n/O ntnnvOuCIRQ8Hf6w3VaQlZtYiIro5KHzHFgXmvRuBXbNj1NI+OiANHisqYsxw1ZpxDG93h FwPeNS9OKi6DQCIo70aAIckrN+CdJXo= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-659-0tsutftuMiuiZSWJBKfgbg-1; Thu, 04 Jan 2024 06:55:54 -0500 X-MC-Unique: 0tsutftuMiuiZSWJBKfgbg-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 E1BEC185A780; Thu, 4 Jan 2024 11:55:53 +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 5C4EC492BC6; Thu, 4 Jan 2024 11:55:53 +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 06:55:51 -0500 Message-ID: <25DCF24F-FB84-4A52-A66E-63A445197AB6@redhat.com> In-Reply-To: <1aa005d1c0b344a455ced93be866dff3c316e15e.camel@hammerspace.com> References: <90c9365ad91e1eb0058b170fb332ea70ad554d8b.1702496910.git.bcodding@redhat.com> <1aa005d1c0b344a455ced93be866dff3c316e15e.camel@hammerspace.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 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. I will send a v4 with your suggestion. Ben