From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=79.135.106.120 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796269294; b=frux7XrCrTejZbdK//du/tS2LrUPAVDOK8Z5AA9G8wYugmmkBXAlJkcFJRW0qk+v2gNS kql+BtKE8TTkHwAcOtkuiojMsHKQoZFaJZQviIuIc474tsz+zQ89ktMD7+Cp+vAdSap6j GwIXgTGFb2z3JaP9uKWfxdiXxL3jzaSULnwiw2hjTYmW3RHiSEV61796BaN4bDzj05Pfd z9PQshV7exP0pvrQXvMCrJ1ZCAi1EkIj/CsGoXhhFCmo0zvq970+b7FIigaOmxeWNDbxE TsQkiek6BMiEHxVVVCiwSLDWgvvoRpkzvcbIGuwTuJwSgGA1SwzgpBtbhqHpARxgnwQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796269294; h=DMARC-Filter:DKIM-Signature:Date:To:From:Cc:Subject:Message-ID: In-Reply-To:References:Feedback-ID:X-Pm-Message-ID:MIME-Version: Content-Type:Content-Transfer-Encoding; bh=JXCSFwn4p164YBu4ZAdd5BugyuPaIQKDj5JVu9N41Is=; b=QULbKhxq4h3mDIizVM8rwBPX0n4QQFfHhN7KCzjuEb2/i9xYOxVFbWHot3ZDHPd0+F60 CTDloPG7PWbQi3zjpQr4DalH7AS5g+9/+s+lBqfo3/v+eZEf5QIjVPadAuUZhP5+CvoNw 0K5uMBVJtAL01xhXyPBp7DiItjvLZDwhKh298OVEnePmYFgQ2a7TPksk8ZiQsD2xY2KbM QP5izdiY4snY/jGlLPKfzcx7aUUQg2DpCRVD8Ga4qqEOZmRpmCNGSrpJdnSee0y/N1Dok 7/ZdO/XOIDTlzB2gqdppRfL/jMH2FzLo4mLYHrffzOYZOCaFRX41hoEAMDwgw+Vd7uA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=proton.me; spf=pass smtp.mailfrom=proton.me; dkim=pass header.d=proton.me header.i=@proton.me header.a=rsa-sha256 header.s=protonmail2 header.b=DAmavdB9; arc=none smtp.remote-ip=79.135.106.120 Received: from mail-106120.protonmail.ch (mail-106120.protonmail.ch [79.135.106.120]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0DA01606A32F for ; Thu, 3 Dec 2026 03:41:31 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 0DA01606A32F Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=proton.me Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=proton.me Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=proton.me header.i=@proton.me header.a=rsa-sha256 header.s=protonmail2 header.b=DAmavdB9 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=proton.me; s=protonmail2; t=1796269289; x=1796528489; bh=JXCSFwn4p164YBu4ZAdd5BugyuPaIQKDj5JVu9N41Is=; h=Date:To:From:Cc:Subject:Message-ID:In-Reply-To:References: Feedback-ID:From:To:Cc:Date:Subject:Reply-To:Feedback-ID: Message-ID:BIMI-Selector; b=DAmavdB91UNx5R3TTNMB8Z/BlB+ah3ZnDF8w5WLWFWEoyX+a5MX8hggBWMEcxn9dB N5XwyCEkSDPxtgyFcKKxIOJbFL/5+oF5SgGwIGithaxGFxkQLuPal50GGgE6JGU90p QK2CRH6cXbTPukWFwv4kB1ngfWptB4n7I+S2C+uCxmYB2gQqUi4cceE7aQp1M0I+br TpNL6MVaCGMXZwsUWN23n0AHhZvLJfjbA4WQtVZU/6sOiTkXN19LB1lSgB9KOyWpqW KxmKzdja8LMbrN8CnJb98TOg0OTCF/wbQGzSkmQaXc+ELlUssVYcsmgmAXj7CfqHcf yG3PVlfXiHHSA== Date: Thu, 03 Dec 2026 03:41:22 +0000 To: Alexandra Winter From: Bryam Vargas Cc: Jakub Kicinski , Paolo Abeni , "David S . Miller" , Hidayath Khan , Eric Dumazet , Thorsten Winkler , Simon Horman , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Nagamani PV , 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 Message-ID: <20261203034116.338079-1-hexlabsecurity@proton.me> In-Reply-To: <082654a9-aa48-40c0-b8e4-1495d0ac232c@linux.ibm.com> References: <20261114-b4-disp-fc0634a3-v4-0-f96c506447ce@proton.me> <20261114-b4-disp-fc0634a3-v4-1-f96c506447ce@proton.me> <082654a9-aa48-40c0-b8e4-1495d0ac232c@linux.ibm.com> Feedback-ID: 199661219:user:proton X-Pm-Message-ID: 1d486d73ea7e63d5485de08fe0630709472ecc70 X-Mailing-List: netdev@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 01.12.26 18:13, Alexandra Winter wrote: > 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. Thanks for the repro on real HiperSockets. > 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?) [...] > 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? Yes to all of it, and I have it that way here now: one flag, set when the SYN is handed to the device. Once it is set, setting SO_MSGLIMIT fails with -EINVAL, the errno a connected socket already gives. af_iucv(7) says the limit has to be set before connect(). The window field and its helper are gone, and getsockopt() returns the value in use. The patch is 28 lines added and 3 removed, against 33 and 3 in v4. In the emulated setup, with the SYN out and the minimum SO_RCVBUF, net reads 2 of 8 frames when the limit is lowered from 8 to 2, and then fails with -EFAULT and the WARN_ON() in iucv_sock_recvmsg(). When the limit is raised from 2 to 8, the peer's writer stops after 2 frames. With the flag, both setsockopt() calls fail and all 8 frames are read. > Even this situation could check first_syn_sent, right? > And ignore the SYN|ACK if !first_syn_sent. Done, and for a SYN|FIN too. On net, a forged SYN|FIN for a socket that only called bind() leaves it in IUCV_DISCONN, and listen() then fails with -EINVAL. With the check, the frame is dropped and listen() works. > 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? "Further connects" is the part I'd like your call on before I post v5. Not sending a second SYN is clearly right: the listener cannot tell it from the first and makes a second child. A second connect() before the reply comes in gives two children on net and one with the flag. The open question is what that second connect() returns. I ran it both ways. Refusing it, -EALREADY once the SYN is out: - A connect() interrupted by a signal returns -EINTR and is not restarted, because the socket's send timeout is 40 s by default. A caller that retries on EINTR then gets -EALREADY, and the socket connects later, when the SYN|ACK comes in. Same for a retry after the timeout. With SO_SNDTIMEO 0 and SA_RESTART, the kernel itself restarts the call, and the one connect() the caller made returns -EALREADY. - A non-blocking caller that calls connect() again before the reply comes in gets -EAGAIN on net. With the refusal, that becomes -EALREADY. poll() does not help: it reports EPOLLOUT for a socket in IUCV_BOUND. So the caller gets an error for a connect() that then goes through, and poll() cannot tell it when. FWIW, POSIX agrees with the refusal (EALREADY for a later call while the first is in progress), but it counts on poll() to say when the connection is up. Waiting instead: a later connect() that names the same peer sends nothing and waits for the reply to the first SYN, as a second blocking connect() does on TCP. A non-blocking one returns -EAGAIN, as on net. One that names another peer fails with -EALREADY, and the first peer still connects. That is what my draft does now, in 10 lines in connect(). With it, a retry after EINTR or after the timeout waits and returns 0 when the SYN|ACK comes in. So does the restarted call. Each of those ends with one child. Either way, with one SYN per socket the retry is lost: a socket whose SYN got no reply cannot connect any more. By default connect() gives up after 40 s with -EAGAIN, and on net the next call sends a new SYN. When the first SYN is dropped in transit, the second connect() connects on net. With my draft the second connect() times out too, and a new socket bound to the same name connects. With the refusal it would be -EALREADY at once; I did not run that case. IOW the caller has to close the socket and make a new one, which is what POSIX advises after a failed connect(). One case could keep the retry. For a SYN to a user ID that is not on the LAN, af_iucv gets TX_NOTIFY_UNREACHABLE in the emulated setup and ignores it. It ignores every failed-tx notification for a socket in IUCV_BOUND. Clearing the flag there would let the next connect() send a SYN again. That is not in the draft, and I can't tell from here whether a real device reports the same. So: refuse or wait? I'd take waiting, as in the draft, but it's your call. And is the lost retry fine for the users you know of? If something else was behind refusing further connects, I'd like to hear it, so the patch does what you had in mind. > This warning situation could also be prevented with a check for > first_syn_sent? Yes. The forged SYN|ACK is dropped, so the socket stays in IUCV_BOUND and the byte sent after it is never read. Thanks, Bryam