Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp7706766rdb; Thu, 4 Jan 2024 05:24:03 -0800 (PST) X-Google-Smtp-Source: AGHT+IFv1D0x4xCBjvjGDWQiygR8+/tISwZQcwZ/GrWB55lkEqMsQpz3T1vX+RmIa4NFJnmYd7rr X-Received: by 2002:a2e:b8cb:0:b0:2cc:ddb9:e458 with SMTP id s11-20020a2eb8cb000000b002ccddb9e458mr371089ljp.28.1704374643391; Thu, 04 Jan 2024 05:24:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704374643; cv=none; d=google.com; s=arc-20160816; b=VUkF2mq7Tz4h7FA+ajUcjsOTkZvIwJLgGh2FZKXCNG9vjrrPX9odrAuZswhcYG42mE kNV4oLHIyPGidxVfPmFcIDDp/szKP03CUWcFlqu1LRMUEwZnNOpDfNP6EHdxuqs4dArv B3etAFJqj0qkaTjhTZposEN+dpUy45giMxGYNji5Qscyy4ltaWxW7NJrc+Eg19VniEeM +g1jWjGjyM5Fcm5rB3fXh1Pdb4AUNWK8Wcy7G85TyMR9Xbxqc3+a2FLbDSqaqG51ds8X PfALYiPOd+tdiX5hcFBNiXY4SjeEJ3Cp0yIlsZINl5NzAyntCgaREttrxPr8ppFVMxfl 9I+w== 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=TxF3E+AX7HoTfqENFhqN5Y9zYCI2xd3X/a0XXxt61NU=; fh=hJNTCDtgS3PkNW4UT6wu69MxXhmbp+MUckWtpsv/p4E=; b=HVYreKdNoq6hzjPkaNSyxv4tJGFgzIJJ5Ut1N99gg9nptgwVYJKCStb2yzaG2keNyj ok/ereR3ZDtUpi4RFSbdkBDQnxJn2vu7UKnvSmJ0kBQf/5DCPm8i1ZJ++V9VhvMlp+tM ktyynTq7XYcEUcDTPTR+krj65m4CFmGea6TGmGqYudTgLJgI2N3WzhfPGLIsnds7yJYO CaW+fSH5y4oK+D0yGZemQZIoVk9oO32hTw1hDwR8S1qgzwkIGCAr5KLnXJ/TfGwPrV6E g4kcG7bCo91/p3IwDy1odPLit0imGppgtq21uJQ57Gn8YOWWRZYMJHZpKHraX/ofVjZG VhLA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=aE2FxnmQ; spf=pass (google.com: domain of linux-nfs+bounces-925-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-nfs+bounces-925-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id u26-20020a50c05a000000b0055346ed3134si12883448edd.546.2024.01.04.05.24.03 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Jan 2024 05:24:03 -0800 (PST) Received-SPF: pass (google.com: domain of linux-nfs+bounces-925-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=aE2FxnmQ; spf=pass (google.com: domain of linux-nfs+bounces-925-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-nfs+bounces-925-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 1BB391F22709 for ; Thu, 4 Jan 2024 13:24:03 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D77FC22314; Thu, 4 Jan 2024 13:24:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="aE2FxnmQ" X-Original-To: linux-nfs@vger.kernel.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.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 1B44C22323 for ; Thu, 4 Jan 2024 13:23:57 +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=1704374636; 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=TxF3E+AX7HoTfqENFhqN5Y9zYCI2xd3X/a0XXxt61NU=; b=aE2FxnmQrzy+wXlT8KG0UsEuMBq+fCZP9EWyJJmsNUlsHhs2v+ujFVx/teVm2tYPB83HmR Tgt6ceNQnZdcHqxtJcwRp7aEcDJa6voWir1mwEoRBxK92xKIkYotgqlHZ1BMfjstonz1fH RvJnPQIsdD6XkGtXJNb4jTK7q01Y738= 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-10-363TL0tjO2uXRJRY5fBozg-1; Thu, 04 Jan 2024 08:23:52 -0500 X-MC-Unique: 363TL0tjO2uXRJRY5fBozg-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (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 80C4C8489E2; Thu, 4 Jan 2024 13:23: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 EF25F51D5; Thu, 4 Jan 2024 13:23: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 08:23:50 -0500 Message-ID: <1707B7F5-0D22-44BC-8170-1D119F71F9B1@redhat.com> In-Reply-To: <47231988-6BE0-4A1C-93CE-F5D14600BA8F@redhat.com> References: <90c9365ad91e1eb0058b170fb332ea70ad554d8b.1702496910.git.bcodding@redhat.com> <1aa005d1c0b344a455ced93be866dff3c316e15e.camel@hammerspace.com> <25DCF24F-FB84-4A52-A66E-63A445197AB6@redhat.com> <47231988-6BE0-4A1C-93CE-F5D14600BA8F@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.5 On 4 Jan 2024, at 7:13, Benjamin Coddington wrote: > 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 wrong about this ^^. The mount option timeo must be > 0, so we can check if to_initval is zero to see if we should fall back to the xprt default. Ben