FAILED: patch "[PATCH] net: smc: fix splice entry lifetime imbalance in" failed to apply to 5.10-stable tree
[email protected]
maintainerThe patch below does not apply to the 5.10-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 <[email protected]>.
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.10.y
git checkout FETCH_HEAD
git cherry-pick -x 5d9686af2976741bbd79b150d1c9e60b81e7f12e
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<[email protected]>' --in-reply-to '2026081711-stamina-rebuttal-bfcf@gregkh' --subject-prefix 'PATCH 5.10.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 <[email protected]>
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.
net/smc/smc_rx.c +10 -9
@@ -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);
Sasha Levin
maintainerPATCH 1/2 net/smc: rdma write inline if qp has sufficient inline space
From: Guangguan Wang <[email protected]>
[ Upstream commit 793a7df63071eb09e5b88addf2a569d7bfd3c973 ]
Rdma write with inline flag when sending small packages, whose length is shorter than the qp's max_inline_data, can help reducing latency.
In my test environment, which are 2 VMs running on the same physical host and whose NICs(ConnectX-4Lx) are working on SR-IOV mode, qperf shows 0.5us-0.7us improvement in latency.
Test command:
server: smc_run taskset -c 1 qperf
client: smc_run taskset -c 1 qperf <server ip> -oo \
msg_size:1:2K:*2 -t 30 -vu tcp_lat
The results shown below:
msgsize before after 1B 11.2 us 10.6 us (-0.6 us) 2B 11.2 us 10.7 us (-0.5 us) 4B 11.3 us 10.7 us (-0.6 us) 8B 11.2 us 10.6 us (-0.6 us) 16B 11.3 us 10.7 us (-0.6 us) 32B 11.3 us 10.6 us (-0.7 us) 64B 11.2 us 11.2 us (0 us) 128B 11.2 us 11.2 us (0 us) 256B 11.2 us 11.2 us (0 us) 512B 11.4 us 11.3 us (-0.1 us) 1KB 11.4 us 11.5 us (0.1 us) 2KB 11.5 us 11.5 us (0 us)
Stable-dep-of: 5d9686af2976 ("net: smc: fix splice entry lifetime imbalance in smc_rx_splice")
--- net/smc/smc_tx.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-)
net/smc/smc_tx.c +12 -5
@@ -320,12 +320,20 @@ static int smcr_tx_rdma_writes(struct smc_connection *conn, size_t len,int rc;for (dstchunk =0 ; dstchunk <2 ; dstchunk++) { -struct ib_sge *sge = - wr_rdma_buf->wr_tx_rdma[dstchunk].wr.sg_list; +struct ib_rdma_wr *wr = &wr_rdma_buf->wr_tx_rdma[dstchunk]; +struct ib_sge *sge = wr->wr.sg_list; +u64 base_addr = dma_addr; + +if (dst_len < link->qp_attr.cap.max_inline_data) { + base_addr = (uintptr_t )conn->sndbuf_desc->cpu_addr; + wr->wr.send_flags |=IB_SEND_INLINE ; + }else { + wr->wr.send_flags &= ~IB_SEND_INLINE ; + } num_sges =0 ;for (srcchunk =0 ; srcchunk <2 ; srcchunk++) { - sge[srcchunk].addr = dma_addr + src_off; + sge[srcchunk].addr = base_addr + src_off; sge[srcchunk].length = src_len; num_sges++;
@@ -339,8 +347,7 @@ static int smcr_tx_rdma_writes(struct smc_connection *conn, size_t len, src_len = dst_len - src_len;/* remainder */ src_len_sum += src_len; } - rc =smc_tx_rdma_write (conn, dst_off, num_sges, - &wr_rdma_buf->wr_tx_rdma[dstchunk]); + rc =smc_tx_rdma_write (conn, dst_off, num_sges, wr);if (rc)return rc;if (dst_len_sum == len)
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 2/2 net: smc: fix splice entry lifetime imbalance in smc_rx_splice
From: Daming Li <[email protected]>
[ Upstream commit 5d9686af2976741bbd79b150d1c9e60b81e7f12e ]
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.
--- net/smc/smc_rx.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)
net/smc/smc_rx.c +8 -4
@@ -144,7 +144,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,
@@ -164,6 +169,8 @@ static int smc_rx_splice(struct pipe_inode_info *pipe, char *src, size_t len, partial.len = len; partial.private = (unsigned long )priv; +get_page (smc->conn.rmb_desc->pages); +sock_hold (&smc->sk); spd.nr_pages_max =1 ; spd.nr_pages =1 ; spd.pages = &smc->conn.rmb_desc->pages;
@@ -172,11 +179,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); -get_page (smc->conn.rmb_desc->pages); +if (bytes >0 )atomic_add (bytes, &smc->conn.splice_pending); - }return bytes; }
Signature · 1 line
2.53.0