* [PATCH net] net/smc: do not credit bytes that splice() did not take
@ 2026-08-20 8:55 Hidayath Khan
0 siblings, 0 replies; only message in thread
From: Hidayath Khan @ 2026-08-20 8:55 UTC (permalink / raw)
To: alibuda, dust.li, sidraya, mjambigi, andrew+netdev
Cc: tonylu, guwen, davem, edumazet, kuba, pabeni, horms, pasic,
hidayath, linux-s390, netdev, linux-rdma
smc_rx_recvmsg() offers a chunk of the RMB to splice_to_pipe() and then
credits the whole chunk regardless of what was taken.
splice_to_pipe() takes only what the pipe has room for. A short count and
a zero count are both non-negative, so both fall through as success: the
call returns more than it delivered, and the consumer cursor and
bytes_to_rcv are advanced by copylen rather than by what the reader
received. The skipped bytes are never handed to anyone.
A pipe that is not empty is enough to hit this; SPLICE_F_NONBLOCK on a
full pipe produces the zero case.
Account what splice_to_pipe() actually took, and stop there rather than
continuing to the second chunk of a wrapped read. When it took nothing,
return -EAGAIN instead of reporting a length that was not delivered.
Fixes: 9014db202cb7 ("smc: add support for splice()")
Cc: stable@vger.kernel.org
Reviewed-by: Sidraya Jayagond <sidraya@linux.ibm.com>
Signed-off-by: Hidayath Khan <hidayath@linux.ibm.com>
---
net/smc/smc_rx.c | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
diff --git a/net/smc/smc_rx.c b/net/smc/smc_rx.c
index 5c9e4d8b57de..d951dbe8eec3 100644
--- a/net/smc/smc_rx.c
+++ b/net/smc/smc_rx.c
@@ -488,6 +488,24 @@ int smc_rx_recvmsg(struct smc_sock *smc, struct msghdr *msg,
read_done = -EFAULT;
goto out;
}
+ /* splice_to_pipe() takes only what the pipe
+ * has room for, which may be less than was
+ * offered, or nothing. Account what it took
+ * and stop: crediting the whole chunk would
+ * advance the consumer past data the reader
+ * never received.
+ */
+ if (!msg && rc < chunk_len) {
+ if (!rc) {
+ if (!read_done)
+ read_done = -EAGAIN;
+ goto out;
+ }
+ copylen = chunk_len_sum - chunk_len + rc;
+ read_remaining -= rc;
+ read_done += rc;
+ break;
+ }
}
read_remaining -= chunk_len;
read_done += chunk_len;
base-commit: d3083202a78cd0040be6a88953f728b0d3db1990
--
2.52.0
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2026-08-20 8:55 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-20 8:55 [PATCH net] net/smc: do not credit bytes that splice() did not take Hidayath Khan
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox