From: sashiko-bot@kernel.org
To: "Bryam Vargas" <hexlabsecurity@proton.me>
Cc: linux-s390@vger.kernel.org,
"Christian Borntraeger" <borntraeger@linux.ibm.com>,
"Heiko Carstens" <hca@linux.ibm.com>,
"Alexander Gordeev" <agordeev@linux.ibm.com>,
"Vasily Gorbik" <gor@linux.ibm.com>
Subject: Re: [PATCH net v3] net/iucv: fix the recvmsg window update
Date: Sat, 29 Aug 2026 19:07:49 +0000 [thread overview]
Message-ID: <20260829190749.81C471F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260828-b4-disp-33fac0ed-v3-1-e6d061880ee0@proton.me>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
Pre-existing issues:
- [High] Lockless modification of sk->sk_shutdown and sk->sk_state leads to data races and lost state updates.
- [High] Silent data truncation for SOCK_STREAM over HiperSockets when message size exceeds MTU.
--
commit 9ec78889adee8ffda3665e319fc36af7e52f542f
Author: Bryam Vargas <hexlabsecurity@proton.me>
net/iucv: fix the recvmsg window update
This commit attempts to fix a spurious disconnect in HiperSockets by
properly checking the transport before sending an AF_IUCV_FLAG_WIN
message. It also addresses a counter race by claiming the window credit
after ruling out error exits.
> diff --git a/net/iucv/af_iucv.c b/net/iucv/af_iucv.c
> index 4e5cc9da6e068..db261ecd19af1 100644
> --- a/net/iucv/af_iucv.c
> +++ b/net/iucv/af_iucv.c
> @@ -250,13 +244,22 @@ static int afiucv_hs_send(struct iucv_message *imsg, struct sock *sock,
> }
> skb->protocol = cpu_to_be16(ETH_P_AF_IUCV);
[Severity: High]
This is a pre-existing issue, but just above this point in afiucv_hs_send(),
large buffers are silently truncated:
if (skb->len > skb->dev->mtu) {
if (sock->sk_type == SOCK_SEQPACKET) {
err = -EMSGSIZE;
goto err_free;
}
err = pskb_trim(skb, skb->dev->mtu);
if (err)
goto err_free;
}
If pskb_trim() succeeds for a SOCK_STREAM socket, afiucv_hs_send() returns
success. Does iucv_sock_sendmsg() then return the full original requested
length to user-space instead of the truncated length, masking the truncation
and causing silent data loss?
> + /* Claim the receive credit here, not while building the header: every
> + * way this frame can be dropped has now been ruled out, so the window
> + * is zeroed only for as long as the transmit itself takes.
> + */
> + if (flags == AF_IUCV_FLAG_WIN || !flags) {
> + confirm_recv = atomic_xchg(&iucv->msg_recv, 0);
> + phs_hdr->window = confirm_recv;
> + if (confirm_recv)
> + phs_hdr->flags = phs_hdr->flags | AF_IUCV_FLAG_WIN;
> + }
> +
> atomic_inc(&iucv->skbs_in_xmit);
> err = dev_queue_xmit(skb);
[ ... ]
> @@ -1331,16 +1335,20 @@ static int iucv_sock_recvmsg(struct socket *sock, struct msghdr *msg,
> if (skb_queue_empty(&iucv->backlog_skb_q)) {
> if (!list_empty(&iucv->message_q.list))
> iucv_process_message_q(sk);
> - if (atomic_read(&iucv->msg_recv) >=
> - iucv->msglimit / 2) {
> - err = iucv_send_ctrl(sk, AF_IUCV_FLAG_WIN);
> - if (err) {
> - sk->sk_state = IUCV_DISCONN;
> - sk->sk_state_change(sk);
> - }
> - }
> + if (iucv->transport == AF_IUCV_TRANS_HIPER &&
> + atomic_read(&iucv->msg_recv) >=
> + iucv->msglimit / 2)
> + send_win = true;
> }
> spin_unlock_bh(&iucv->message_q.lock);
> +
> + if (send_win) {
> + err = iucv_send_ctrl(sk, AF_IUCV_FLAG_WIN);
[Severity: High]
This is a pre-existing issue, but does calling iucv_send_ctrl() here without
holding lock_sock() cause data races?
In net/iucv/af_iucv.c:iucv_send_ctrl():
if (sk->sk_shutdown & SEND_SHUTDOWN) {
/* controlling flags should be sent anyway */
shutdown = sk->sk_shutdown;
sk->sk_shutdown &= RCV_SHUTDOWN;
}
[ ... ]
if (shutdown)
sk->sk_shutdown = shutdown;
Could this lockless temporary modification overwrite concurrent updates to
sk_shutdown (e.g., losing a RCV_SHUTDOWN flag set by shutdown()), leading to
an application hanging indefinitely in recvmsg?
> + if (err) {
> + sk->sk_state = IUCV_DISCONN;
[Severity: High]
This is also a pre-existing issue, but is it safe to update sk_state locklessly
here? This appears to violate core socket locking rules, potentially corrupting
the state machine.
> + sk->sk_state_change(sk);
> + }
> + }
> }
>
> done:
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260828-b4-disp-33fac0ed-v3-1-e6d061880ee0@proton.me?part=1
prev parent reply other threads:[~2026-08-29 19:07 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-28 19:07 [PATCH net v3] net/iucv: fix the recvmsg window update Bryam Vargas via B4 Relay
2026-08-29 19:07 ` 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=20260829190749.81C471F000E9@smtp.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