Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.82.42 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796015895; b=Ar/if59hwUS+N5Vf2v19xteVHK21UzlWqTaa0O1e0l4EZ3d1+ULvEI+U70IWs4kD0KDB 3sme0Bkn7v2g0Y/rmfOIqIf73GrHHj8baJxVtlw01EM4I/nYRl0MbEDeuBWH9Iy0X2nTB 9+foTbu0TklPqEBUpHjxM1YTPjXj2G7jNvskd791xN3PeHLZzgpUBTAXBtyJoCe0PNZdg fAZe8Lb2Uu8bSJnrm8W7dPaNKVTVDcI1An+dHP0Wxrcg7amkqA18QR5kqf3gdIUi0JAVq ge4lopnDLX5JzGfT+KuOx6R2IuwR1HU4XtlBPRjg+Rca83YffeVdmt6KkkDKcEC5r0w== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796015895; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Gm-Message-State:X-Gm-Gg:X-Received:Received:From:To:Cc:Subject: Date:Message-Id:X-Mailer:In-Reply-To:References:MIME-Version: Content-Type:Content-Transfer-Encoding; bh=X92tW7qeJZaOKd8p7T66QT36ShbA1goCKb2iz+atcNc=; b=E+nWRBJ9vkSKGH5s/eZT8A7HKCoeZsVFeqAjZBEUXZnRHIvVp0SIUr+3nFIsEPt3crEC j14A2LShwbr6W2nWoj5brwrv4s2Ouc8UexjwTaX/HPjiRRNf1VSpPlwc6B+4FLEXcJ06Q Vh1aZ44QgP1yPVFU5lNzn2yg+TaSqUOXZE3uIZE9LbzqJjLNtiM6D3cgGyQ9LDdf2iwoZ sszl4xM22Y7s1/bWaS2j2GOvS8QYH1AAabm0/++waOVg7y3hybjdTJ5RoO3kLKP0czRJz HXa0N128rVE0OBIpUfwjdx2wAlVo+kEEKPrl+86Mkv+0t9wUlSWBqhL81gYAgIxKn5g== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b="Do/3v91A"; arc=none smtp.remote-ip=74.125.82.42 Received: from mail-dl1-f42.google.com (mail-dl1-f42.google.com [74.125.82.42]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BAC79606A327 for ; Mon, 30 Nov 2026 05:18:14 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org BAC79606A327 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=Do/3v91A Received: by mail-dl1-f42.google.com with SMTP id a92af1059eb24-1a2761c69fbso16183130c88.0 for ; Sun, 29 Nov 2026 21:18:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796015894; x=1796620694; darn=vger.kernel.org; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:from:to:cc:subject :date:message-id:reply-to:content-type; bh=X92tW7qeJZaOKd8p7T66QT36ShbA1goCKb2iz+atcNc=; b=Do/3v91A5Xkau+fKaGE2g2A3eq0otG63jEnEY+PXHMbcLJ4wbkFNwNC07qAH5MFFdf HhAeMGTtacZgaEB9+PfkXdFLqCFpGpIIZOZEiwDX/5/ua7+yFNwvRgCFOL2WLX1NQ+/a f0m0x3ne72wr9/Jxv54b47UcBp3i5vi8h7VVj02EYFgZ8EmH3y+BSLEbSQ5/VDP+Ec+r wy2OyesS2FDm6/j1p1WLjnWWU69v2TqcP+uGceZnlwq2/d8GirBlCDOs5/YzJGnSnxf/ 6sFvJ24vuHpUo3vbe4n5suq/8O56V7yznwELEdiSOErTWO3d3GUPDxZGCzKp0noviOiu tfYQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796015894; x=1796620694; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=X92tW7qeJZaOKd8p7T66QT36ShbA1goCKb2iz+atcNc=; b=a2mvJOkW3hcHAXBYpVKZa0qQLCznS/O2YWcI0lp8O3xpF0kV/I91EBDF+PBhefnkhX EZg5w1BJLTqMIqzg6euHLaosNHir1QaXKmsOzRVKLESHqVojeSdvrfSphk32YfVSjHk/ GFVhj6n9atbEloSXqkswWUrCA1RHe29ZEEgOc3O1/a5IgjbNE6u9C3iU5kabTFcLcxZy SQ3TCAIL9lY7To/59NcfUc8ebkNpT+Jn7IZLbifJJLFvcS3drlB64DPP1+jvh/3org37 KTTm/Uw/H9vERsH3z9HnXtIzIuqJQ9c1C1/9ONw7X9HbOnK3QOMe2LP1o+TQPlennOw+ PMYg== X-Gm-Message-State: APuU4Z/WXmepIWuLmJQF13NFCOIRN+4pD7fuRTXFxz9h9/tZy1ciOTUS kgbIu35lGoaKOglaG/plPqX0cqnXTWNtkttR6HUt2iDsv+RZ7YfB3DwMRsgR9Q== X-Gm-Gg: AZFdTZf2LLFwrTmx5kimTQ3TPzYLD8OJNAkPfJcr4WQytTtfNriIuYJCYEPwAXqWvIl 4wdF3U1qCPzDJu/Ts4j3VrhJLI0mHvw1YHlPXpfo+bNerBy8dXKQ4e7F4s/CKWfcPjdxZgzjoL4 3TzgOGkEcTqLTo7jCt9zw4jF7IcHF3yvGsfanhlS61iZ4zH7X+NMWej5gQJt/d+8w2FlwFi4kjq 0C9GX4mAojAj4rrG0hevYbP/jwhBAk1yAPnHj4qTeKevNcg5y9v+FQW/BIGOM1rC4Dly9eZ+U8t HmItd22UwPrhdwGpaqeZSSuUaMl5tkpuKm7Cta+buJRgr+Syj04KOaLenrm4JbN6TX+vUEPp9b0 6hieHNkTlTFfT9C/UPGeI87MFCIOZnki7zsHAcfKxT333Aue9yMW/jVexm9hPvEgrnokfTfkWXt AsE/8tDibYTTwV2iNE/UMynxSaWTMv8HvutEVqSqJmLuqMtDbIuhInoBId1MNVGtj9c2OietFUX IxqMM/5pCSJoE6h5UZ5j29S5Y7GCOBqqBjjtVL6giz/TYGNnJtixF2+bzHVLtyOW9I2IGRBPy+r 8CagmMc8bgubWzzX6ESCiCJuA7dhNP7p4oVGjeu5LidboA/rfE7Lvej1S81JOG6PX62BV10+495 uhxN2Mdz2Br0dZg== X-Received: by 2002:a05:7022:b0c8:b0:1b2:6855:998a with SMTP id a92af1059eb24-1b556911007mr27884452c88.34.1796015893645; Sun, 29 Nov 2026 21:18:13 -0800 (PST) Received: from youngkk-vm.localdomain (67.216.200.102.16clouds.com. [67.216.200.102]) by smtp.gmail.com with ESMTPSA id a92af1059eb24-1b55681301asm74831029c88.8.2026.11.29.21.18.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 29 Nov 2026 21:18:13 -0800 (PST) From: Cheng Yongkang To: Trond Myklebust , Anna Schumaker Cc: linux-nfs@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: Re: [PATCH v2] NFS: keep in-flight slots when shrinking the session slot table Date: Sun, 29 Nov 2026 21:18:05 -0800 Message-Id: <20261130051805.3469379-1-teel4res@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <1ea6f3606dc3c3caaed3e013a1a51a4b2c78d909.camel@kernel.org> References: <20261026105215.1149970-1-teel4res@gmail.com> <1ea6f3606dc3c3caaed3e013a1a51a4b2c78d909.camel@kernel.org> X-Mailing-List: linux-nfs@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On Sat, 2026-11-28 at 19:56 -0500, Trond Myklebust wrote: > NACK. nfs4_reset_slot_table() is never called on a session table that > is in use. It is called as part of the create_session workflow, and as > part of the NFSv4.0 client initialisation. The case I hit is the create_session workflow run from nfs4_reset_session(). The drain there does not keep the table empty until nfs4_proc_create_session() runs. nfs4_drain_slot_tbl() returns once highest_used_slotid is NFS4_NO_SLOT, but nfs4_setup_sequence() and nfs41_assign_slot() still give slots to privileged RPCs while NFS4_SLOT_TBL_DRAINING is set. Since commit dfe1fe75e00e ("NFSv4: Fix deadlock between nfs4_evict_inode() and nfs4_opendata_get_inode()"), the DELEGRETURN sent from nfs4_evict_inode() is privileged once nfs_igrab_and_active() fails, so it can take a slot after the drain: state manager inode eviction nfs4_reset_session() nfs4_begin_drain_session() table empty, returns nfs4_proc_destroy_session() nfs4_evict_inode() DELEGRETURN (privileged) nfs4_setup_sequence() takes slot 1 nfs4_proc_create_session() server returns max_reqs = 1 nfs4_setup_session_slot_tables() nfs4_realloc_slot_table() nfs4_reset_slot_table() nfs4_shrink_slot_table() kfree(slot 1) DELEGRETURN reply decode_sequence() reads the freed slot I reproduced it on 7.3 with a test server that answers a GETATTR compound with NFS4ERR_BADSESSION, delays the DESTROY_SESSION and DELEGRETURN replies, and returns max_reqs = 1 instead of 4 in the new session: BUG: KASAN: slab-use-after-free in decode_sequence+0xb3/0x690 Read of size 8 at addr ... by task kworker/u8:1/13 Workqueue: rpciod rpc_async_schedule decode_sequence+0xb3/0x690 nfs4_xdr_dec_delegreturn+0x54/0x380 call_decode+0x522/0x930 __rpc_execute+0x520/0x1270 rpc_async_schedule+0x52/0xa0 Freed by task ...: kfree nfs4_realloc_slot_table+0x597 nfs4_setup_session_slot_tables nfs4_proc_create_session nfs4_run_state_manager The delays only widen the window. RFC 8881 lets a server destroy a session while fore channel requests are outstanding (section 18.37.3 only allows it to refuse for unanswered CB_COMPOUNDs), and lets it change ca_maxrequests for the fore channel in CREATE_SESSION (section 18.36). v2 keeps the slots that are still in use when the table is shrunk. If you would rather keep the privileged DELEGRETURN off the slot table during a session reset, or wait for it before nfs4_proc_create_session(), I can rework it that way. Thanks, Cheng