From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=148.163.156.1 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796145253; b=ejLXQftM3hN2A/fMl3+tsjXMvfnYfG+Q780nyl7o+vm49fzVcdZRWhLFdFY8JnMxkcLi 6cbpitFc+6+ewY6ZIWSZB9l2n6epi5TN0ZJYzIRB2Ug6QvctY9AFmuvUgeTDFZfhNnTLd qBpZ3eqSkUTOocV6K6eYXJVkuI/jmPCAv698mzg0MA7Ow52lDzq6GoOVZ+rbUgDxQCJ4J h9nSaB5Ivo3q2fyiu/JyELvtlw5aPFcN8Dmk/QIzMPyoQ6oXfSY79xUtU3M735a5CPFKR p6jLiIM8J86/1J1A2pLgaxXGEUd4Uy/EYeoTeDiiaB5RsyAcUjAzaaAakNC3nZfE+Vg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796145253; h=DMARC-Filter:Received:DKIM-Signature:Received:Received:Received: Received:Received:Received:Received:Message-ID:Date:MIME-Version: User-Agent:From:Subject:To:Cc:References:Content-Language:In-Reply-To: Content-Type:Content-Transfer-Encoding:X-TM-AS-GCONF: X-Proofpoint-GUID:X-Proofpoint-Spam-Info: X-Proofpoint-Spam-Details-Enc:X-Authority-Analysis: X-Proofpoint-ORIG-GUID:X-Proofpoint-Virus-Version: X-Proofpoint-Spam-Details; bh=wAbwn5lOVs3HWjLUFjw9gTZfABWSWFvAlX/vU2Tna64=; b=N7xM6vkYJBiGJnAQZlDQge+EIHDz+3C709tlikhuuCyQoCLY8dtVB9KypSyjt6xkTS70 hJqYS39clB/HhI5avKUV0HTzl4p3OaXcwXAfvntrjlbDMvO09UvsK16JdNwj/jL5KjMwz PPFKdArt12GcdhYZZNxl3QCxDEMhNNngMdPACsTBoXaZnB7enWsrSMooU9NLAOPoC0Tvm 0GmovjMk6Jz3b4Bl0RjtOXT1I3MkDd0Z1IDu2IWkSurojS8Hv+CautBBzaPaNMqg9RDh8 wb4FizF7kt5QlW+2x6zmHlXpb3bNrD0zrzxjVWV67l9MkP025z4Gc9pR54629Z5BOvQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=linux.ibm.com; spf=pass smtp.mailfrom=linux.ibm.com; dkim=pass header.d=ibm.com header.i=@ibm.com header.a=rsa-sha256 header.s=pp1 header.b=k9uhx7jo; arc=none smtp.remote-ip=148.163.156.1 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (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 C7C79606A31A; Tue, 1 Dec 2026 17:14:12 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org C7C79606A31A Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.a=rsa-sha256 header.s=pp1 header.b=k9uhx7jo Received: from pps.filterd (m0356517.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 6B1F5wAt2132452; Tue, 1 Dec 2026 17:13:28 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=pp1; bh=wAbwn5 lOVs3HWjLUFjw9gTZfABWSWFvAlX/vU2Tna64=; b=k9uhx7jo0ZXLdIyBshsKFd lNMXd2NCJiVn33J+HtB6PmA3anZqL3Arj3sM9rym1XRIAV4/0dNVUISgvX7xXTGY IZcQQ617yNEx7ieqRdO9RtTxubZCLy5j+H9/6sxZkPBteIyQ4TaKd+/980LG2R7p Y7zKcthE+3CCyHOnBSPWt/ExCZJDExzHTOL2j58l+OysB0rJ994YGjZZM+/5C1AM MJ3SY9wkKwaVMMjN+9ggjdBKROCrtElgvggFmlzk8HwoidyiK/gGHDtTSA2WRP6x AOvx7AFq/f7hw0TOHEhz11mJ3LItwWC1sdIuR9uWUpl4ZAbcsup7xyRUwS0Mb/xQ == Received: from ppma12.dal12v.mail.ibm.com (dc.9e.1632.ip4.static.sl-reverse.com [50.22.158.220]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4j7pp5wstx-1 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Tue, 01 Dec 2026 17:13:28 +0000 (GMT) Received: from pps.filterd (ppma12.dal12v.mail.ibm.com [127.0.0.1]) by ppma12.dal12v.mail.ibm.com (8.18.1.11/8.18.1.11) with ESMTP id 6B1F8p6T1655430; Tue, 1 Dec 2026 17:13:27 GMT Received: from smtprelay07.fra02v.mail.ibm.com ([9.218.2.229]) by ppma12.dal12v.mail.ibm.com (PPS) with ESMTPS id 4j9ujnhhfr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 01 Dec 2026 17:13:27 +0000 (GMT) Received: from smtpav05.fra02v.mail.ibm.com (smtpav05.fra02v.mail.ibm.com [10.20.54.104]) by smtprelay07.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 6B1HDNL349283436 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 1 Dec 2026 17:13:23 GMT Received: from smtpav05.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 7481420043; Tue, 1 Dec 2026 17:13:23 +0000 (GMT) Received: from smtpav05.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 36B0820040; Tue, 1 Dec 2026 17:13:23 +0000 (GMT) Received: from [9.68.25.8] (unknown [9.68.25.8]) by smtpav05.fra02v.mail.ibm.com (Postfix) with ESMTP; Tue, 1 Dec 2026 17:13:23 +0000 (GMT) Message-ID: <082654a9-aa48-40c0-b8e4-1495d0ac232c@linux.ibm.com> Date: Tue, 1 Dec 2026 18:13:22 +0100 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 User-Agent: Mozilla Thunderbird From: Alexandra Winter Subject: Re: [PATCH RFC net v4 1/8] net/iucv: keep the window given to the peer in a field of its own To: hexlabsecurity@proton.me, Jakub Kicinski , Paolo Abeni , "David S. Miller" , Hidayath Khan , Eric Dumazet Cc: Thorsten Winkler , Simon Horman , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Nagamani PV , linux-s390@vger.kernel.org References: <20261114-b4-disp-fc0634a3-v4-0-f96c506447ce@proton.me> <20261114-b4-disp-fc0634a3-v4-1-f96c506447ce@proton.me> Content-Language: en-US In-Reply-To: <20261114-b4-disp-fc0634a3-v4-1-f96c506447ce@proton.me> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-TM-AS-GCONF: 00 X-Proofpoint-GUID: E5D0msM9sf4Wf5UUO9McPPvGSm2URkU5 X-Proofpoint-Spam-Info: AW1haW4tMjYxMjAxMDA2OCBTYWx0ZWRfX8Gvhpnfx0fCq bIie5ePe1gPyylFP8ZYKZ+3LvORex5qyo9qXX9hEmDI0S931pC+Guym0OiKCdBsUBP3YFRfdFeg xbtPrQ4rNTA6SZ3ksm7bROu5YstLkLc= X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYxMjAxMDA2OCBTYWx0ZWRfX0sRelN5rzx8X aDiA8uuEdpP3VAYBKFtEZzllBRWGfSTBRekB6lXAIhyak/fl/JR6OjEy8j29ZnuaLpU00lWiLMz ZXR7vzbx40xvbDFPmcWf6kO11VXRQtWXWbfCLzLoX38ylrf560RWzJIuOaqnMmbd1Mvil+xya+F 4YsQvbsxEa0GUAMwNsmhLAjaN89+tXlM78KmzIc/BI9x0suvY5T/l5GgCiDUoDhfb7om9ty5ww0 kwhZIozBTtQvnSehzpP3CPEwe17FQAmsyJh06ORF/Mga0u8aISM1Z7b77Oj8ueQu1quy15ZsfRh TlzbBGx4BXq0VBt/W2yT/8v20MlGNWSnisFKDLVYjYUwapNCgEEPuyayyLmIE9cBuAEyu5SJZF9 Z5NIn2FGT4RVpkA6Cxx9tuTCfrye5nhXLv4GZB0fMn++ctYRdLJtXmIHXKpCP/HQypwh84B5oNL cngNE/5NaF6cPwU6G4g== X-Authority-Analysis: v=2.4 cv=Ae8kjHXG c=1 sm=1 tr=0 ts=6b0f0038 cx=c_pps a=bLidbwmWQ0KltjZqbj+ezA==:117 a=bLidbwmWQ0KltjZqbj+ezA==:17 a=REPgES4Tcxp0NRTW:21 a=IkcTkHD0fZMA:10 a=pUM-KoujPXoA:10 a=VkNPw1HP01LnGYTKEx00:22 a=RnoormkPH1_aCDwRdu11:22 a=U7nrCbtTmkRpXpFmAIza:22 a=VwQbUJbxAAAA:8 a=m2tTG0KZdilh3pPaxIwA:9 a=QEXdDO2ut3YA:10 X-Proofpoint-ORIG-GUID: E5D0msM9sf4Wf5UUO9McPPvGSm2URkU5 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1176,Hydra:6.1.138,FMLib:17.12.100.49 definitions=2026-12-01_03,2026-12-01_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 adultscore=0 spamscore=0 malwarescore=0 phishscore=0 lowpriorityscore=0 bulkscore=0 priorityscore=1501 impostorscore=0 clxscore=1015 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2611040001 definitions=main-2612010068 On 15.11.26 02:29, Bryam Vargas via B4 Relay wrote: > From: Bryam Vargas > > 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 > --- > 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. > ---