[PATCH net v2 0/2] net/iucv: two fixes in the HiperSockets receive path

From: Bryam Vargas via B4 Relay

Date: Thu Oct 29 2026 - 00:48:14 EST


Two bugs in the HiperSockets receive path that predate the socket-locking
rework [1]; review and testing of that rework turned them up. Neither
depends on it.

1/2 clears hs_dev before the socket drops its reference on the device and
marks the accesses that race with it: afiucv_hs_rcv() compares hs_dev
under iucv_sk_list.lock while close() clears it under lock_sock().
Hidayath Khan caught the racing pair with KCSAN under z/VM [2] and
suggested the fix. The listener's child now takes its device from the
frame instead of reading the listener's field in softirq. This is an
ordering fix with no known crash.

2/2 stops counting the SHT's empty frame against the receive window (the
peer does not count it) and drops the WARN_ON on the overrun path, which
a peer reaches from the network by sending past its window. Only frames
with data count now; a zero-length data frame, which already ends the
stream for its reader, is no longer counted either. 2/2 applies on its
own and goes to stable.

Based on net at fcc00b15cb21, after the net-next merge (iucv_sock_close()
is split into __iucv_sock_close() there). The same two patches apply on
mainline. Tested on an s390x guest under QEMU TCG with KASAN and lockdep
on, on net f4377bf85887 and net-next 8df0638138d3; the base moved to
fcc00b15cb21 afterwards, same hunks. QEMU has no HiperSockets adapter:
the one here is mine, under the real qeth and qdio drivers, on a QEMU
with my own patches to the s390x machine (the adapter's interruptions
through the FLIC, a z/VM CP model), and there is no IBM Z to compare
against. With 2/2 an SHT read while frames wait in backlog_skb_q gives
EOF instead of WARN plus -EFAULT. 1/2 does not change any result in the
rework's test set; its race shows under KCSAN, not here. Logs on
request.

v2:
- 2/2: an empty frame read after the close over the window reached
iucv_send_ctrl() with hs_dev already cleared (the AI review of v1
[3]); the window update now goes out only while the socket is
connected. Repro on the same machine (SO_MSGLIMIT 2, SO_RCVBUF 6144,
two sends, one frame injected over the window, the SHT, 16 more
behind it; the parameters are below 2/2), counting iucv_send_ctrl()
entries and the frames at the adapter: v1 attempts one update after
the close and nothing leaves; v2 attempts none. The reads are the same
on both (1, 1, -EFAULT, -ECONNRESET, 0, -EFAULT; the last is a data
frame behind the SHT closing again); net without the patch reads
-EFAULT at the SHT with its WARN.
- 2/2: the commit message now says "a zero-length data frame that
reaches recvmsg()": a zero-length send with a piggybacked credit is a
window update and never reaches it [3].
- 1/2: code unchanged. The review's point on it (the child's device
reference when a SYN races the listener's close) is the pre-existing
orphan the notes below 1/2 describe; the rework [1] closes that race.
- Both commit messages say how the patch was tested.
- Rebased on net after the net-next merge.

v1: https://lore.kernel.org/netdev/20261022-b4-disp-b35a9153-v1-0-d74645876195@xxxxxxxxx/

[1] https://lore.kernel.org/netdev/20261022-b4-disp-1d26b87a-v2-0-7ee1264d812a@xxxxxxxxx/
[2] https://lore.kernel.org/netdev/b3fea2ca-25ff-42c0-812c-f8cc6bb6667e@xxxxxxxxxxxxx/
[3] https://lore.kernel.org/netdev/179306942509.3134.1109951482403010755@xxxxxxxxxx/

---
Bryam Vargas (2):
net/iucv: clear hs_dev before dropping its reference
net/iucv: do not count the SHT frame against the receive window

net/iucv/af_iucv.c | 45 ++++++++++++++++++++++++++++++++++-----------
1 file changed, 34 insertions(+), 11 deletions(-)
---
base-commit: fcc00b15cb21a6de76826e5012b2c758505f5e65
change-id: 20261028-b4-disp-dd3e4ebb-fe118f9d09aa

Best regards,
--
bryamzxz <hexlabsecurity@xxxxxxxxx>