From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795913797; b=1FC1cwloPu9Y5gnjiqszJz5OsrhyA2N3O4mrn24zex24TE3pJryj8F7Mz3Tq0i/YTQbi NVYi9fv3LoULy3kaJK56UxAPZPIVQB4o56NRolnbGUFgepdgVHNARqZlHqR9ecOafeeV3 dK29dXAkPT9EjfQ5MfMVw1Y8F7CzajqPePcEiIGsOPXlE1b/XRNEo3wVbIG32FZRvQyfs Rkpou8xHtdtxp6/0fL9U4vLCGMrngOOelDNUqDpY+JwlBHTlsWQ/DqjqgBTOYMki8lVVA njte4YoBmYjOiJNU1Jmvvs9o58+lLKaAcefHDvBoOpJFLHe0O8v7tcYvBL6Ojjrca0A== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795913797; h=Received:DKIM-Signature:Message-ID:Subject:From:To:Cc:Date: In-Reply-To:References:Content-Type:Content-Transfer-Encoding: User-Agent:MIME-Version; bh=HiCsX06htCik9qSfCbMtamEKaOh1p77jHrr3MS9ujy8=; b=AIvJSywAmjfPst+bw6c3v7yK4kl5WDItarARPmQqIkt8z2KFGxH6A68fZLZThzyLruHr KLm4m7NA1tyu/pWTBZkFR6EjgbQocU0cKeiXeYEaaQLe8LqPatKguwmJ8xeukqYhV4Yz5 +gXpfNRISafdQY6XH8M3wuU4E1wIZBA65LaXopGcu9epd8frdnw/4xwHykhIG+uS/Rch4 9pfQGri3Y7beDxLEC3YXF1DCii3kILQoSIqCkoZ0VAL0jOzPu+Hzl2dDkAEfXU/P8SNYr C/JFujUBwT3i6b+IZm2aBdeXiZy5k4Zegq/I/upKRut2VOxhnj40Tb6gNCAtsn1ivmg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b="n63D//Re"; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 06278606A31C; Sun, 29 Nov 2026 00:56:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=n63D//Re Received: by smtp.kernel.org (Postfix) with ESMTPSA id 325951F00896; Sun, 29 Nov 2026 00:56:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795913796; bh=HiCsX06htCik9qSfCbMtamEKaOh1p77jHrr3MS9ujy8=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=n63D//ReH6aPqwwVVdEP9dB2YMUxXoFttz6tTETTAseIvyJSeEcBaWiOa1JpoO5ox BXaUdy0sGLaiDKp0ALiObiycP9GxIM9LYz5o4vQBWavntQgG8cTgRaLq53yUvVFCZ/ Z1JqpSR+16N4dYGDJ2ffwjRhUvN4udHwu9bmLl4kjUhSKUHR/fCAVc4qvLXERLs2/M xm+3A7AqExMlPr+qe1IMaVY3F7nY4akseReRhy2WFlvqAa76EKDG+b+5AIZM7KJnmO mnKAg8sc+2P3b5Lu/fHanv9DntGOH/vMM/opBg5zo+bW28cVbeoAwRKWyodHTG7cFK DLnAI/ASMU7UQ== Message-ID: <1ea6f3606dc3c3caaed3e013a1a51a4b2c78d909.camel@kernel.org> Subject: Re: [PATCH v2] NFS: keep in-flight slots when shrinking the session slot table From: Trond Myklebust To: Cheng Yongkang , Anna Schumaker Cc: linux-nfs@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org Date: Sat, 28 Nov 2026 19:56:35 -0500 In-Reply-To: <20261026105215.1149970-1-teel4res@gmail.com> References: <20261026105215.1149970-1-teel4res@gmail.com> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.62.1 (3.62.1-1.fc45) 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 On Mon, 2026-10-26 at 03:52 -0700, Cheng Yongkang wrote: > nfs4_reset_slot_table() shrinks the forechannel slot table to the new > session's max_reqs without checking whether any of the slots being > freed are still in use.=C2=A0 The session drain it follows only snapshots > highest_used_slotid once, while nfs4_setup_sequence() and > nfs41_assign_slot() deliberately let privileged RPCs (sa_privileged, > e.g. the DELEGRETURN sent while an inode is being evicted) allocate a > slot after that snapshot.=C2=A0 If such an RPC owns a slot with > slot_nr >=3D max_reqs, nfs4_shrink_slot_table() kfree()s it and the > reply path (decode_sequence(), nfs41_release_slot(), > nfs4_free_slot()) > later dereferences the freed slot: a slab-use-after-free. >=20 > Clamp the shrink target to highest_used_slotid + 1 when the table is > not empty, so only slots above the highest used slot are freed, and > stop resetting highest_used_slotid: the high-water mark is still > needed > to release those slots and to complete a later drain.=C2=A0 max_slotid is > still set to the server's new highest slotid, so new RPCs cannot use > the preserved slots above the new max_reqs.=C2=A0 A server advertising > max_reqs =3D=3D 0 arrives with server_highest_slotid =3D=3D NFS4_NO_SLOT; > make > that wrap explicit. >=20 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. --=20 Trond Myklebust Linux NFS client maintainer, Hammerspace trondmy@kernel.org, trond.myklebust@hammerspace.com