Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 CE25F41D23F for ; Mon, 17 Aug 2026 12:43:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786970609; cv=none; b=IBsUvSzMwz2/0JhEO9UuBf4Yj53L3ekbe0sSA0WpkGYh72eyuwifws/XkWFkUiiWI3vwBHDliW4Win8vLOsyfr5s0jLVmruk2Jt3ED67kXxYvjPuzJnfv0RyVktL3z1eDaOpYaGivJ4XYObPNCN2GNatLce8UXmsb5QzN0mCVmw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786970609; c=relaxed/simple; bh=gi1OT0Cwo/f/ajCU5CIzHLMHhkvxBR+z5UltsM14XFQ=; h=Subject:To:Cc:From:Date:Message-ID:MIME-Version:Content-Type; b=LmgUApOcwVACKJTvCnqIljZIWCH6w1topZgHyyij7w5hONuGW3Gi8PHpu9+SVzvRIVZYM+1JVz9CyYLkowGzBmrB0RUY+Es51ilhDe0xqxISkfcqCnH4AiOIipDsZ7MyaswK5huiqMpr2vSueIgSKxPkV53ERo4xZHXraCaIX5M= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=0QyATCNi; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="0QyATCNi" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 84F2E1F000E9; Mon, 17 Aug 2026 12:43:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1786970607; bh=vfUyJLQfSdjed3AgsE5N/UewLYnkstR4se965jDdsuA=; h=Subject:To:Cc:From:Date; b=0QyATCNiihzYGrDouwvKw83fmcxXBLerrRo1ZQeQxmVZ/CE08IlC4v2UzBOgKRbH1 ndnfDqOR9sJUbI8JuCa0XeZQ3uxjzYhyfc+ZW+aoeRLR3FpBtn6MQPIXFYEIG8e3WA cN+XRN13XuvyCvkKYyoUI4FfH/GOO5A5RWB5H1Q4= Subject: FAILED: patch "[PATCH] net: smc: fix splice entry lifetime imbalance in" failed to apply to 5.15-stable tree To: d4n.for.sec@gmail.com,dust.li@linux.alibaba.com,enjou1224z@gmail.com,kuba@kernel.org,lx24@stu.ynu.edu.cn,sidraya@linux.ibm.com,vega@nebusec.ai Cc: From: Date: Mon, 17 Aug 2026 14:41:10 +0200 Message-ID: <2026081710-untie-barn-6dcc@gregkh> Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=ANSI_X3.4-1968 Content-Transfer-Encoding: 8bit The patch below does not apply to the 5.15-stable tree. If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to . To reproduce the conflict and resubmit, you may use the following commands: git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-5.15.y git checkout FETCH_HEAD git cherry-pick -x 5d9686af2976741bbd79b150d1c9e60b81e7f12e # git commit -s git send-email --to '' --in-reply-to '2026081710-untie-barn-6dcc@gregkh' --subject-prefix 'PATCH 5.15.y' 'HEAD^..' Possible dependencies: thanks, greg k-h ------------------ original commit in Linus's tree ------------------ From 5d9686af2976741bbd79b150d1c9e60b81e7f12e Mon Sep 17 00:00:00 2001 From: Daming Li Date: Thu, 30 Jul 2026 22:55:52 +0800 Subject: [PATCH] net: smc: fix splice entry lifetime imbalance in smc_rx_splice smc_rx_splice() passes pages to splice_to_pipe() before taking the references that cover the lifetime of each splice entry. In the VM-backed RMB path, splice_to_pipe() may drop unqueued entries through smc_rx_spd_release(), while queued entries are released later via the pipe buffer callback. The old post-splice accounting also derives the number of queued VM pages from an offset mutated while building the descriptor, and a multi-page splice pairs one sock_hold() with multiple sock_put() calls. Take the page and socket references for every candidate entry before splice_to_pipe(), and drop the matching private state, page reference, and socket reference from smc_rx_spd_release() for entries that never get queued. This fixes a refcount imbalance that can underflow page refcounts and trigger a use-after-free. Fixes: 9014db202cb7 ("smc: add support for splice()") Cc: stable@vger.kernel.org Reported-by: Vega Co-developed-by: Xiao Liu Signed-off-by: Xiao Liu Signed-off-by: Daming Li Signed-off-by: Ren Wei Reviewed-by: Dust Li Reviewed-by: Sidraya Jayagond Link: https://patch.msgid.link/20260730145552.360287-2-enjou1224z@gmail.com Signed-off-by: Jakub Kicinski diff --git a/net/smc/smc_rx.c b/net/smc/smc_rx.c index c1d9b923938d..5c9e4d8b57de 100644 --- a/net/smc/smc_rx.c +++ b/net/smc/smc_rx.c @@ -150,7 +150,12 @@ static const struct pipe_buf_operations smc_pipe_ops = { static void smc_rx_spd_release(struct splice_pipe_desc *spd, unsigned int i) { + struct smc_spd_priv *priv = (struct smc_spd_priv *)spd->partial[i].private; + struct sock *sk = &priv->smc->sk; + + kfree(priv); put_page(spd->pages[i]); + sock_put(sk); } static int smc_rx_splice(struct pipe_inode_info *pipe, char *src, size_t len, @@ -209,6 +214,10 @@ static int smc_rx_splice(struct pipe_inode_info *pipe, char *src, size_t len, offset = 0; } } + for (i = 0; i < nr_pages; i++) { + get_page(pages[i]); + sock_hold(&smc->sk); + } spd.nr_pages_max = nr_pages; spd.nr_pages = nr_pages; spd.pages = pages; @@ -217,16 +226,8 @@ static int smc_rx_splice(struct pipe_inode_info *pipe, char *src, size_t len, spd.spd_release = smc_rx_spd_release; bytes = splice_to_pipe(pipe, &spd); - if (bytes > 0) { - sock_hold(&smc->sk); - if (!lgr->is_smcd && smc->conn.rmb_desc->is_vm) { - for (i = 0; i < PAGE_ALIGN(bytes + offset) / PAGE_SIZE; i++) - get_page(pages[i]); - } else { - get_page(smc->conn.rmb_desc->pages); - } + if (bytes > 0) atomic_add(bytes, &smc->conn.splice_pending); - } kfree(priv); kfree(partial); kfree(pages);