From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.82.173 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796015895; b=WUz1SM489kHMh3eOUzo/9kxclcCmhSBQkzurO0Mr5RPZZw3OdtxxsjhJxzK9W5eTIsHl Shrg+jXh1wwLDc0uk2IiLLh0N7saRcwFV+HBsxdLtS53ZKs/v/vZKD/Q+PCQZwS+xi3Xs YbSYPTRSgVxjfkpeOwQR/ymuF/fBFNJN30VayXJsBk3rSW5KE2bv1b2R8kazQ3uM2+22Y 06sZEn8VZC39KGovl1L5gcNwSGOCMFe/LaSBL1qnZGpl/bmXd7NxdSFh0EC0ZDSqeaoNm ahMXWukNGBrGyLCjucWFnetnU7g/Jrt9gDZw8xkELkYoHNkjLHwD8ZaRKOX/6Ut9zfQ== 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-Forwarded-Encrypted: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=qU3p3YanQNS4SYEjUVfF3axwfwdf2NVx2tlzquHmS7ukklPTnjVGLw3d1VcMcn2rSVOu 8QmMcbVdkwjzMGlKt8K5ni3ycuDfNcDYEgLmmOslX0VxPD9BupwlePn5KJMp7qotzKUb+ HRmmFzEu80n4FPGJieB+P16cdaYq4mfSoi/2yfywILcdBJyekXJPzYRWIWA0Ffy5YF4vc cBX6iZiuTuPoRxGLgc+7/xD3K/ojjam0IPiZZGjb00vwWNu1zKk0uYZYaRgk5XHZPRBFv Ha4pJ5r4+kkgIgpRJqbqLvNwuMFnZG8xmASisqgbm0gWy5SScU1Fl5Fkm3RbnmScd5g== 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.173 Received: from mail-dy1-f173.google.com (mail-dy1-f173.google.com [74.125.82.173]) (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 A8EBB606A331 for ; Mon, 30 Nov 2026 05:18:14 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org A8EBB606A331 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-dy1-f173.google.com with SMTP id 5a478bee46e88-385c497bf94so12822135eec.1 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=s1kBNugrT+mzNKQ7mV76wyi0IgN2BOoflizOv0sOmS+HrfQwMmeIlfA6W/YJM0ywb5 6ZFEyR3EBFg7iRUmSOb6bzHgxi/R5qIpOb8rOXKpTmvWkvYSBr3Mgyrvaoo0P8J7J/jy yj5ejaoHHFC+T8WpsLz/bKUpc1jFbtDysbpwgJX9Y7SIF/LEYp+zL1CckNnBX2Yrj0BX xH0aOspqiGcN+5yIJU1ob9BT/QWGvwyxTopfwbnw6PaO8eHv7GzLZvsTShqRg2CRUFI/ nftcw1p5Ywt6zxmDbIS8JsAp2/hWTZ0EUqBwinadfoGmakHB/ra2Koemh4X+H65ABeHi rpCA== X-Forwarded-Encrypted: i=1; AL+hErGUktUZl71p2sFOqshexB4613aKRroxM2IbQ3enVy5oAyB1rfqtmqZaThDxVy/FiEmSEzk2v0DG0Op7Ook=@vger.kernel.org X-Gm-Message-State: APuU4Z/57XDduwd2EyNo/gH+bKe+yQ8Zw/h9TLeHGlNYG+8S4WQuZj8I GlOUftzwRvOhcmWTdi7tfboa1N9fumAsZI3aqrTSdMUKrNwYBaXQ8ch5 X-Gm-Gg: AZFdTZck92QRGzj/CQIWQoa5I7uZhwmyog5lKB1zQ+nuQlzHCDY38KC4lwWFurmEEi0 JX/HQq5xIWfcnUa51aPq6n+VST1yMypdQl0G5iiw81TqrO9NF6ZuN4k2+jfO0rRPpVNEbCW0Z0f DzYWxuCURBZEwAzU0k9/Zm9ITYn0SJU26VVbUJKD6vEM3uWfNYeHmWetGKxtd2iWzINZR9dxp32 +DdXvNH7VgIbcVxQDq8vTPDiFKzI3I/fKmZojdEr07abV/pU+Oa0oFUiHXSwJauoMRtzIA6AgT8 g8H5vnAXApscraY7U+IDKmzUj+ruEodVo/n9k/ItferXeYL0xLnxI5StCeXlwR/E7MspJjSKHiV g8sCWVDsoKPNMB1mAmZO2kcbzZCuvBajX+KLOW0YF4QSv2guY2D7SHabsYsnm8ACk4J4fAEccWY bTzKMwN2+oVebwI+Yah2AUkXxYv0VJVf0jUqHRaVbCo6GMkdNb8W9uBSBgIl8Uy80uLc6dCqLkv dWOL91s3UT480dvXKp37uk9ISr6vizud7A+50kQCsDYi/JjNXClyw3LIFZcI9KfTAdEp+0IgKo9 JHmffhCdaN8uUgdpFhZgfp5RqoNCcZ9abb1uWkaKopaHxGm0t4UwXqCBKLNvdRVzby8fcS076fW 2miIFBpJjMKlx0w== 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-kernel@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