Linux s390 Architecture development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Bryam Vargas" <hexlabsecurity@proton.me>
Cc: linux-rdma@vger.kernel.org, linux-s390@vger.kernel.org,
	"Heiko Carstens" <hca@linux.ibm.com>,
	"Vasily Gorbik" <gor@linux.ibm.com>,
	"Alexander Gordeev" <agordeev@linux.ibm.com>,
	"Christian Borntraeger" <borntraeger@linux.ibm.com>
Subject: Re: [PATCH net] net/smc: don't spin in smc_rx_recvmsg() while a pipe holds spliced data
Date: Wed, 14 Oct 2026 20:45:22 +0000	[thread overview]
Message-ID: <sashiko-outbox-171898@kernel.org> (raw)
In-Reply-To: <20261013-b4-disp-193a2a59-v1-1-ed88ac10a41c@proton.me>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] smc: missing SOCKWQ_ASYNC_WAITDATA flag causes spurious SIGIO and -EINTR
--

commit ffdc9d46059a93d975c6fd059f43bc43b71fe12f
Author: Bryam Vargas <hexlabsecurity@proton.me>

net/smc: don't spin in smc_rx_recvmsg() while a pipe holds spliced data

This commit introduces smc_rx_wait_splice() to allow recvmsg() to sleep
instead of spinning on the CPU while bytes spliced off the RMB are still in
a pipe. It checks for timeouts and signals before waiting, ending the wait
when the pipe releases the data or the connection is killed.

> diff --git a/net/smc/smc_rx.c b/net/smc/smc_rx.c
> index 197fddc6271f0..6f409bda4c37a 100644
> --- a/net/smc/smc_rx.c
> +++ b/net/smc/smc_rx.c
[ ... ]
> @@ -286,6 +286,22 @@ int smc_rx_wait(struct smc_sock *smc, long *timeo, size_t peeked,
>  	return rc;
>  }
>  
> +/* Wait until the pipe releases the spliced data. Unlike smc_rx_wait(),
> + * this does not end on shutdown or a socket error: the data to read is
> + * already in the RMB. smc_conn_kill() wakes the socket, and the caller
> + * checks conn->killed.
> + */
> +static void smc_rx_wait_splice(struct smc_sock *smc, long *timeo)
> +{
> +	DEFINE_WAIT_FUNC(wait, woken_wake_function);
> +	struct smc_connection *conn = &smc->conn;
> +	struct sock *sk = &smc->sk;
> +
> +	add_wait_queue(sk_sleep(sk), &wait);
> +	sk_wait_event(sk, timeo, !atomic_read(&conn->splice_pending), &wait);

[Severity: Medium]
Does smc_rx_wait_splice() need to set and clear the SOCKWQ_ASYNC_WAITDATA bit
around sk_wait_event()?

If FASYNC is enabled on an SMC socket, smc_rx_wake_up() will send a SIGIO
signal to the process unless the SOCKWQ_ASYNC_WAITDATA bit is set.

Since smc_rx_wait_splice() puts the socket to sleep without setting this bit,
a spurious SIGIO could be delivered if the peer sends more data or the pipe
drains while the process is sleeping here.

This could interrupt wait_woken(), causing smc_rx_recvmsg() to prematurely
abort the wait and return -EINTR (or a short read) instead of waiting for
the pipe to drain. While applications generally handle -EINTR by retrying,
this breaks the expected blocking semantics.

For comparison, smc_rx_wait() uses this pattern:

int smc_rx_wait(...) {
    ...
    sk_set_bit(SOCKWQ_ASYNC_WAITDATA, sk);
    add_wait_queue(sk_sleep(sk), &wait);
    rc = sk_wait_event(...);
    remove_wait_queue(sk_sleep(sk), &wait);
    sk_clear_bit(SOCKWQ_ASYNC_WAITDATA, sk);
    ...
}

> +	remove_wait_queue(sk_sleep(sk), &wait);
> +}
[ ... ]

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261013-b4-disp-193a2a59-v1-1-ed88ac10a41c@proton.me?part=1

      parent reply	other threads:[~2026-10-14 20:45 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-13 20:45 [PATCH net] net/smc: don't spin in smc_rx_recvmsg() while a pipe holds spliced data Bryam Vargas via B4 Relay
2026-10-13 20:50 ` netdev-bot+sinfo
2026-10-14 20:45 ` sashiko-bot [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=sashiko-outbox-171898@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=agordeev@linux.ibm.com \
    --cc=borntraeger@linux.ibm.com \
    --cc=gor@linux.ibm.com \
    --cc=hca@linux.ibm.com \
    --cc=hexlabsecurity@proton.me \
    --cc=linux-rdma@vger.kernel.org \
    --cc=linux-s390@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox