Linux s390 Architecture development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Bryam Vargas" <hexlabsecurity@proton.me>
Cc: 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 RFC net v5 09/10] net/iucv: decrement pendings when a pending frame's transmit fails
Date: Sat, 05 Dec 2026 03:02:30 +0000	[thread overview]
Message-ID: <sashiko-outbox-250970@kernel.org> (raw)
In-Reply-To: <20261203-b4-disp-8029c32d-v5-9-0bce531e20d0@proton.me>

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] net/iucv: unordered pendings decrement in
  afiucv_hs_callback_txnotify()
--

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

net/iucv: decrement pendings when a pending frame's transmit fails

This commit decrements iucv->pendings in afiucv_hs_callback_txnotify()
when HiperSockets reports TX_NOTIFY_DELAYED_UNREACHABLE or
TX_NOTIFY_DELAYED_GENERALERROR, so a failed pending SYN does not leave
pendings elevated across a subsequent connect().

> diff --git a/net/iucv/af_iucv.c b/net/iucv/af_iucv.c
> index 8336f7056d49c..1f1f6f6986484 100644
> --- a/net/iucv/af_iucv.c
> +++ b/net/iucv/af_iucv.c
> @@ -2725,6 +2725,11 @@ static void afiucv_hs_callback_txnotify(struct sock *sk, enum iucv_tx_notify n)
>  		if (atomic_dec_return(&iucv->pendings) <= 0)
>  			iucv_sock_wake_msglim(sk);
>  		break;
> +	case TX_NOTIFY_DELAYED_UNREACHABLE:
> +	case TX_NOTIFY_DELAYED_GENERALERROR:
> +		/* counted when the device reported the frame as pending */
> +		atomic_dec(&iucv->pendings);
> +		fallthrough;
>  	default:
>  		atomic_dec(&iucv->skbs_in_xmit);
>  		if (sk->sk_state == IUCV_CONNECTED) {

[Severity: Medium]
Can the unordered atomic_dec(&iucv->pendings) cause a missed wakeup in
sendmsg() or poll()?

atomic_dec() is unordered, and on s390x (default MARCH_Z196 and newer)
arch_atomic_dec() emits asi without bcr 14,0 serialization.  The
unlocked load of sk->sk_state in the fallthrough path can therefore
reorder before the store to iucv->pendings becomes visible.

If a socket in IUCV_BOUND with a pending SYN transitions to
IUCV_CONNECTED on a matching SYN|ACK while the delayed TX error
notification for that SYN runs on another CPU:

CPU0                                CPU1
----                                ----
afiucv_hs_synack()
  sk->sk_state = IUCV_CONNECTED
iucv_sock_sendmsg()
  iucv_sock_wait()
    prepare_to_wait()
                                    afiucv_hs_callback_txnotify()
                                      atomic_dec(&iucv->pendings)
                                      /* unordered vs later load */
                                      if (sk->sk_state == IUCV_CONNECTED)
                                      /* sees IUCV_BOUND, skips wake */
    iucv_below_msglim()
      atomic_read(&iucv->pendings)
      /* sees stale 1 */
    schedule()  <-- missed wakeup

With pendings now 0 and no further TX completion arriving, a sendmsg()
without SO_SNDTIMEO (or poll(EPOLLOUT)) stays blocked until interrupted
by a signal or peer disconnect.

Calling iucv_sock_wake_msglim(sk) when
atomic_dec_return(&iucv->pendings) <= 0 (matching TX_NOTIFY_DELAYED_OK),
or adding smp_mb() before reading sk->sk_state, closes this window.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261203-b4-disp-8029c32d-v5-0-0bce531e20d0@proton.me?part=9

  reply	other threads:[~2026-12-05  3:02 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-04  3:02 [PATCH RFC net v5 00/10] net/iucv: serialize the HiperSockets receive path with the socket lock Bryam Vargas via B4 Relay
2026-12-04  3:02 ` [PATCH RFC net v5 01/10] net/iucv: record that a HiperSockets socket sent its SYN Bryam Vargas via B4 Relay
2026-12-04 18:58   ` Alexandra Winter
2026-12-04  3:02 ` [PATCH RFC net v5 02/10] net/iucv: do not clear SEND_SHUTDOWN to send a control frame Bryam Vargas via B4 Relay
2026-12-04  3:02 ` [PATCH RFC net v5 03/10] net/iucv: fail sendmsg() with EPIPE once sending is shut down Bryam Vargas via B4 Relay
2026-12-05  3:02   ` sashiko-bot
2026-12-04  3:02 ` [PATCH RFC net v5 04/10] net/iucv: run recvmsg() under the socket lock Bryam Vargas via B4 Relay
2026-12-05  3:02   ` sashiko-bot
2026-12-04  3:02 ` [PATCH RFC net v5 05/10] net/iucv: factor out the HiperSockets frame dispatch and state changes Bryam Vargas via B4 Relay
2026-12-04  3:02 ` [PATCH RFC net v5 06/10] net/iucv: serialize HiperSockets receive with the socket lock Bryam Vargas via B4 Relay
2026-12-05  3:02   ` sashiko-bot
2026-12-04  3:02 ` [PATCH RFC net v5 07/10] net/iucv: set RCV_SHUTDOWN under the socket spinlock Bryam Vargas via B4 Relay
2026-12-05  3:02   ` sashiko-bot
2026-12-04  3:02 ` [PATCH RFC net v5 08/10] net/iucv: return EOF to a reader parked when the peer closes Bryam Vargas via B4 Relay
2026-12-05  3:02   ` sashiko-bot
2026-12-04  3:02 ` [PATCH RFC net v5 09/10] net/iucv: decrement pendings when a pending frame's transmit fails Bryam Vargas via B4 Relay
2026-12-05  3:02   ` sashiko-bot [this message]
2026-12-04  3:02 ` [PATCH RFC net v5 10/10] net/iucv: forget a SYN that the device reports unreachable Bryam Vargas via B4 Relay
2026-12-05  3:02   ` sashiko-bot
2026-12-04 11:05 ` [PATCH RFC net v5 00/10] net/iucv: serialize the HiperSockets receive path with the socket lock Hidayath Khan
2026-12-05  3:02 ` sashiko-bot

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-250970@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-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