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=1795035399; b=tjDlRMLd6Rfmbqcb1CCOz8azYCfdUKEzUdctvdkKf+/kzp0kTQYrhHK79ELbOc27TIZN SqQc6Q4QYsgZ6vT1/RJL4lTwrIyHXk/cqtr9mVfwHfCMdQhvhyAvb6t8e5AZR7fGGv5HE kN8p8vNhgahksvpAc2SIZMku9Lid6G0RUp1Do5UmJ5EWoDSsfCnI5E89z0kHdEi8HRSz3 ePc5Da/bIMKOfGSBlCWHkfTu6MrSuc/9QNd5heUuvErW7gxJF5Qdc6er4Lig3V/43yI/Q f8686EyGn2MZCyM487eTDjF0hh9l2PmCyZcRPye8rReZ9I7aNz7kuuHvKbrJWgSGhgQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795035399; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=soIu+dawldxpOG1+6hB2etvnq4tDGmPMff5Lb4PZwLg=; b=zyy46nPPJsWDsOXXwbZfHvE4G8D4YneK2Aomck6qUfrlXcudFdvLGHtHg64gdXsj3XyH Tg6UtVh0y5vOlkGhYxIouUDavv6qAlqSqOZj/pLG9vgPwRyIlPUyyAs+IpF/h174hh/fa AXYtgbELjw+0VzsW+WZsmrcU5pUbHyGgtLqZ3nC+g/6h/iYFW6wY8E4/K6G8HvacMFUp/ anct9Ukvm5avHjCpZBD7AlrB2OCtHmoAReRUE7a7+5vOlTq9xZVtmgay1H+yt9Rm1+2fU 5/rjUeF4H34YNLRE608lR1Cd/tB0CWzn7pBLXWQ7olOcG+DoQgfAqeIG8Widox8mYkg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=nnZ4wlnu; 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 F13AD606A31C; Wed, 18 Nov 2026 20:56:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=nnZ4wlnu Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4E2A71F000C4; Wed, 18 Nov 2026 20:56:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1795035398; bh=soIu+dawldxpOG1+6hB2etvnq4tDGmPMff5Lb4PZwLg=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=nnZ4wlnu/Vw9QCBTvNzEVhe1sEKg8+5nYpCjnyHwUEdzgWUc74coZU2HeavRk1JC8 6ev6NeFC3NuM/OsQ+mBWT54Auz/qVwEvr0gWrSrG8WWCR+yOmfBKzuHYOaHUiYbb1p OvunOSsQsMkmRiJ/iK+/x5fSfWEEA2/yCch8lpQU= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Farhad Alemi , Chuck Lever Subject: [PATCH 6.6 0688/3318] NFSD: Dont complete a cld upcall the daemon has not read Date: Wed, 18 Nov 2026 15:21:50 +0100 Message-ID: <20261118150338.867690899@linuxfoundation.org> X-Mailer: git-send-email 2.56.0 In-Reply-To: <20261118150313.527275416@linuxfoundation.org> References: <20261118150313.527275416@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: patches@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Chuck Lever commit 7f4bf851aca4e18940ebf2bddf4ba6783802ee81 upstream. cld_pipe_downcall() matches a reply to its upcall on the xid alone. A write that arrives before the daemon has read that upcall completes __cld_pipe_upcall() while its struct rpc_pipe_msg is still queued on the pipe. The waiter returns, its stack frame goes away, and the pipe keeps a list_head that points into it. The next rpc_queue_upcall() walks that pointer: BUG: KASAN: vmalloc-out-of-bounds in __list_add_valid_or_report Read of size 8 at addr ffffc90007027950 by task syz.0.96/13066 __list_add_valid_or_report+0x6a/0x130 rpc_queue_upcall cld_pipe_upcall nfsd4_cld_grace_start nfsd4_cld_tracking_init The pipe is mode 0600 in rpc_pipefs, so the trigger is a broken or hostile nfsdcld rather than an unprivileged task. Record whether the daemon has consumed the whole message and complete only when it has. cld_pipe_destroy_msg() runs on every path by which the pipe releases a message, so it can maintain that flag under cn_lock. nfsdcld sends its -EINPROGRESS downcalls only after reading the upcall, so the new check does not break the GraceStart record stream. Fixes: f3f8014862d8 ("nfsd: add the infrastructure to handle the cld upcall") Cc: stable@vger.kernel.org Reported-by: Farhad Alemi Closes: https://lore.kernel.org/linux-nfs/CA+0ovCjVF58WLeen2ctdzHyWUASAAW3Y=Yjihyq0pFApYawtDg@mail.gmail.com/ Link: https://patch.msgid.link/20260901-alemi-v2-1-e163f94a3a6e@kernel.org Signed-off-by: Chuck Lever Signed-off-by: Greg Kroah-Hartman --- fs/nfsd/nfs4recover.c | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) --- a/fs/nfsd/nfs4recover.c +++ b/fs/nfsd/nfs4recover.c @@ -724,6 +724,8 @@ struct cld_upcall { struct list_head cu_list; struct cld_net *cu_net; struct completion cu_done; + /* daemon has read the whole upcall; protected by cn_lock */ + bool cu_inflight; union { struct cld_msg_hdr cu_hdr; struct cld_msg cu_msg; @@ -883,6 +885,13 @@ cld_pipe_downcall(struct file *filp, con spin_lock(&cn->cn_lock); list_for_each_entry(tmp, &cn->cn_list, cu_list) { if (get_unaligned(&tmp->cu_u.cu_hdr.cm_xid) == xid) { + /* + * Completing now would return the waiter + * while its message is still queued on the + * pipe. + */ + if (!tmp->cu_inflight) + break; cup = tmp; if (status != -EINPROGRESS) list_del_init(&cup->cu_list); @@ -891,9 +900,9 @@ cld_pipe_downcall(struct file *filp, con } spin_unlock(&cn->cn_lock); - /* couldn't find upcall? */ + /* no upcall to complete? */ if (!cup) { - dprintk("%s: couldn't find upcall -- xid=%u\n", __func__, xid); + dprintk("%s: no completable upcall -- xid=%u\n", __func__, xid); return -EINVAL; } @@ -913,8 +922,16 @@ cld_pipe_destroy_msg(struct rpc_pipe_msg struct cld_msg *cmsg = msg->data; struct cld_upcall *cup = container_of(cmsg, struct cld_upcall, cu_u.cu_msg); + struct cld_net *cn = cup->cu_net; + + /* + * errno >= 0 means the daemon read the whole message and a + * downcall will complete the upcall. + */ + spin_lock(&cn->cn_lock); + cup->cu_inflight = msg->errno >= 0; + spin_unlock(&cn->cn_lock); - /* errno >= 0 means we got a downcall */ if (msg->errno >= 0) return;