From: Alexandra Winter <wintera@linux.ibm.com>
To: hexlabsecurity@proton.me, Jakub Kicinski <kuba@kernel.org>,
Paolo Abeni <pabeni@redhat.com>,
"David S. Miller" <davem@davemloft.net>,
Hidayath Khan <hidayath@linux.ibm.com>,
Eric Dumazet <edumazet@kernel.org>
Cc: Thorsten Winkler <twinkler@linux.ibm.com>,
Simon Horman <horms@kernel.org>,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
Nagamani PV <nagamani@linux.ibm.com>,
linux-s390@vger.kernel.org
Subject: Re: [PATCH RFC net v4 1/8] net/iucv: keep the window given to the peer in a field of its own
Date: Tue, 1 Dec 2026 18:13:22 +0100 [thread overview]
Message-ID: <082654a9-aa48-40c0-b8e4-1495d0ac232c@linux.ibm.com> (raw)
In-Reply-To: <20261114-b4-disp-fc0634a3-v4-1-f96c506447ce@proton.me>
On 15.11.26 02:29, Bryam Vargas via B4 Relay wrote:
> From: Bryam Vargas <hexlabsecurity@proton.me>
>
> A HiperSockets SYN carries msglimit as the receive window, and
> SO_MSGLIMIT is accepted while the socket is IUCV_BOUND, which it is
> until the SYN|ACK arrives. A msglimit changed in between leaves the peer
> with the window the SYN carried, while recvmsg() counts the frames it
> reads against the new value:
>
> - Lowered, a peer that keeps to its window has the socket closed on it
> once the receive buffer is full and frames wait in backlog_skb_q,
> where no window update resets the count: WARN_ON(), -EFAULT, the rest
> of the stream lost.
> - Raised far enough, the threshold of the window update lies above the
> window: the count never reaches it, the peer uses up its window and
> its writer waits for an update that only a data frame from us would
> carry.
>
I reproduced both scenarios via real HiperSockets connection, and
both issues went away with this patch:
Without the patch the fail immediately;
with the patch: ran 100x without the issue.
My understanding:
`As AF_IUCV_TRANS_HIPER currently has no SS_CONNECTING state, a second
connect can send another SYN before SYN|ACK is received and the socket
state becomes IUCV_CONNECTED.`
> Record the window when the first SYN of a socket leaves, and in a
> listener's SYN|ACK, and let recvmsg() count frames against it and take
> the window-update threshold from it. A SYN that is not sent records
> nothing, and a later SYN of the socket carries the recorded window. A> msglimit set after the first SYN no longer changes anything for that
> socket; getsockopt() still returns it.
Would it be more consistent to reject a set_msglimit after first SYN has
been sent, if you introduce special handling of this case anyhow?
(Noticing, that this first-SYN recording already provides some logic of
a CONNECTING state, right?)
Sounds suboptimal that getsockopt returns the value that is not used
anywhere.
If you just reject the set_msglimit, maybe you don't even need to record
the msglimit, just record first_syn_sent?
Maybe that would even be a smaller patch?
My understanding:
'As AF_IUCV_TRANS_HIPER currently does not check whether connect() has
been called, a socket in IUCV_BOUND state can be connected by an
unsolicited SYN|ACK, if the *name and *user_id fields match.'
A socket connected by a SYN|ACK
> without having sent a SYN keeps msglimit as its window.
Even this situation could check first_syn_sent, right?
And ignore the SYN|ACK if !first_syn_sent.
>
> Fixes: 3881ac441f64 ("af_iucv: add HiperSockets transport")
> Fixes: 800c5eb7b5eb ("af_iucv: change net_device handling for HS transport")
> Cc: stable@vger.kernel.org # 6.18.x
> Signed-off-by: Bryam Vargas <hexlabsecurity@proton.me>
> ---
> v4 (AI review of v3, [3] in the cover letter):
> - a later SYN of the socket carries the window the first one gave and
> records nothing. v3 wrote the field for every SYN, so a second
> connect() in IUCV_BOUND after a SO_MSGLIMIT change left the peer of
> the first SYN with a window the socket no longer counted against
> - the window is recorded when the first SYN is handed to the device,
> after the device and MTU tests, and forgotten if that transmit fails.
> v3 recorded it while building the header: a connect() that failed
> with -ENETDOWN left a window nobody had received
> - not changed: connect() still tests sk_state before lock_sock(), the
> last case of that review. A SYN sent that way does not move the
> window: it is recorded by then, or the socket was connected by a
> SYN|ACK it never asked for and the SYN records the msglimit the
> socket already counts against
> v3: https://lore.kernel.org/netdev/20261110-b4-disp-2a6b4364-v3-1-35677b68e697@proton.me/
>
> It goes first because the backlog of 6/8 counts against this window: on
> the live msglimit it would drop data without a trace, as in Hidayath's
> SO_MSGLIMIT scenario on v1.
>
> Both cases in the message repro in the emulated setup, with the SYN|ACK
> held back in the adapter while the limit changes:
>
> - SO_MSGLIMIT 8 when the SYN goes out, lowered to 2, minimum SO_RCVBUF,
> the peer sends its 8 frames. net reads 2, then takes the WARN_ON() in
> iucv_sock_recvmsg() and returns -EFAULT; with this patch all 8 arrive.
> With the default SO_RCVBUF net delivers the 8 as well: a window update
> goes out after each read and resets the count.
> - SO_MSGLIMIT 2 when the SYN goes out, raised to 8. The peer sends 2 and
> the socket reads both. On net no window update leaves and the peer's
> next send returns -EAGAIN; with this patch the update leaves and the
> send goes through. With the limit left at 2 both kernels send the
> update.
>
> The v4 items, same setup:
>
> - The lowered case with a second connect() after the limit changed, so
> that a second SYN leaves with the SYN|ACK of the first still held. The
> child the first SYN made sends its 8 frames: net reads 2, WARN_ON()
> and -EFAULT; this patch reads all 8. With the field written by every
> SYN again the socket reads 2 and takes the -EFAULT whichever child
> sends. net and this patch read all 8 from the child the second SYN
> made; with the second SYN carrying the live msglimit that child stops
> after 2 frames, as the socket counts against 8 and owes it no update.
> - connect() with the interface down and SO_MSGLIMIT 1: -ENETDOWN, no SYN
> leaves. Interface up, the limit raised to 8, then a forged SYN|ACK and
> three frames. net and this patch read all three; with the window
> recorded ahead of the device test, as in v3, the socket reads one and
> the next read takes the WARN_ON() and returns -EFAULT.
> - For a transmit that fails after the record I have no qdisc that drops
> on demand, so a test kernel drops the SYN to a destination name that
> begins with DSY: it frees the skb where dev_queue_xmit() would be
> called and hands back NET_XMIT_DROP. The sequence above with that
> SYN: the three frames are read; with the record left in place the
> second read fails as above.
>
> Not changed, and for the maintainers to call: once a first SYN has
> left, SO_MSGLIMIT is still accepted while the socket is IUCV_BOUND and
> no longer moves the window, even when the next connect() names another
> peer. The window given and the window counted agree, which is all this
> patch is after. Refusing SO_MSGLIMIT once a SYN has left, or forgetting
> the window when the destination changes, would each be a change of its
> own.
See above. Recording first_syn_sent and then refusing further
SO_MSGLIMIT and further connects, would make this patch uneccessary and
would not be more complex than this, would it?
>
> The last sentence of the message is the third item of the AI review of
> v2. net connects an IUCV_BOUND socket on any SYN|ACK, whether or not it
> sent a SYN. The series leaves that as it is. With a forged SYN|ACK and
> one byte for a socket that never called connect(), net and this patch
> return the byte; with the window left at 0, as in v2, the read takes
> the WARN_ON() and returns -EFAULT.
>
Understood. AF_IUCV_TRANS_HIPER doesn't authenticate the sender (except
that it has to have access to this HS segment), so with a forged packet
all kind of things can be done.
This warning situation could also be prevented with a check for
first_syn_sent?
> With afiucv_hs_window() back on the live msglimit, the lowered case
> loses data in the backlog of 6/8 and the raised one stalls as on net.
> None of this shows in the 53 default tests: with this patch the same
> eight fail as on net, with the same result.
> ---
next prev parent reply other threads:[~2026-12-01 17:14 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-15 1:29 [PATCH RFC net v4 0/8] net/iucv: serialize the HiperSockets receive path with the socket lock Bryam Vargas via B4 Relay
2026-11-15 1:29 ` [PATCH RFC net v4 1/8] net/iucv: keep the window given to the peer in a field of its own Bryam Vargas via B4 Relay
2026-12-01 17:13 ` Alexandra Winter [this message]
2026-11-15 1:29 ` [PATCH RFC net v4 2/8] net/iucv: do not clear SEND_SHUTDOWN to send a control frame Bryam Vargas via B4 Relay
2026-11-15 1:29 ` [PATCH RFC net v4 3/8] net/iucv: fail sendmsg() with EPIPE once sending is shut down Bryam Vargas via B4 Relay
2026-11-15 1:29 ` [PATCH RFC net v4 4/8] net/iucv: run recvmsg() under the socket lock Bryam Vargas via B4 Relay
2026-11-15 1:29 ` [PATCH RFC net v4 5/8] net/iucv: factor out the HiperSockets frame dispatch and state changes Bryam Vargas via B4 Relay
2026-11-15 1:29 ` [PATCH RFC net v4 6/8] net/iucv: serialize HiperSockets receive with the socket lock Bryam Vargas via B4 Relay
2026-11-15 1:29 ` [PATCH RFC net v4 7/8] net/iucv: set RCV_SHUTDOWN under the socket spinlock Bryam Vargas via B4 Relay
2026-11-15 1:29 ` [PATCH RFC net v4 8/8] net/iucv: return EOF to a reader parked when the peer closes Bryam Vargas via B4 Relay
2026-11-30 8:34 ` [PATCH RFC net v4 0/8] net/iucv: serialize the HiperSockets receive path with the socket lock Hidayath Khan
2026-11-30 15:44 ` Hidayath Khan
2026-12-01 5:45 ` Hidayath Khan
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=082654a9-aa48-40c0-b8e4-1495d0ac232c@linux.ibm.com \
--to=wintera@linux.ibm.com \
--cc=davem@davemloft.net \
--cc=edumazet@kernel.org \
--cc=hexlabsecurity@proton.me \
--cc=hidayath@linux.ibm.com \
--cc=horms@kernel.org \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-s390@vger.kernel.org \
--cc=nagamani@linux.ibm.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=twinkler@linux.ibm.com \
/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