Article View: linux.kernel.netdev
Article #14385[PATCH RFC net v3 2/7] net/iucv: fail sendmsg() with EPIPE once sending is shut down
From: Bryam Vargas via B4 Relay
Date: Wed, 11 Nov 2026 04:44
Date: Wed, 11 Nov 2026 04:44
73 lines
13677 bytes
13677 bytes
From: Bryam Vargas <hexlabsecurity@proton.me>
sendmsg() tests SEND_SHUTDOWN on entry only, then waits for the peer's
window without the socket lock. When sending is shut down during that
wait, by shutdown(SHUT_WR) in another thread or by the peer's quiesce
over z/VM, the wait does not end and the call does not fail: the writer
waits out SO_SNDTIMEO, or, when the window opens first, sends its
record after the socket's SHT and the peer reads data after EOF. With
the peer's FIN in as well it returns -ECONNRESET for a stream its own
socket shut down.
End the wait when sending is shut down and test SEND_SHUTDOWN again
after it, ahead of the sk_state test, so the call fails with -EPIPE as
it does on entry.
Fixes: 0ea920d211e0 ("af_iucv: Return -EAGAIN if iucv msg limit is exceeded")
Cc: stable@vger.kernel.org # 6.18.x
Signed-off-by: Bryam Vargas <hexlabsecurity@proton.me>
---
New in v3 as a patch of its own: the new condition of sendmsg()'s
window wait and the test after it, placed ahead of the state test, were
in the lock patch. It goes before 3/7, which lets sendmsg() wait for
send memory without the socket lock and would otherwise open the same
gap a second time.
Three of the 53 default tests are about this, and net fails all three.
A writer parked on a full window sends its record after the socket's
own SHT when the window opens, so the peer reads data after EOF; it
waits out SO_SNDTIMEO when the window stays shut; and with the peer's
FIN in as well it gets -ECONNRESET. With this patch the first and the
third pass and the second returns -EPIPE; that test still fails, as its
SHT finds no room in sk_sndbuf (one of the five in the cover letter).
With only the wait changed the writer sends after the shutdown in the
first two and gets -ECONNRESET in the third; with only the test after
it, it waits out SO_SNDTIMEO again; with the test placed after the
state test it gets -ECONNRESET again.
Not changed: iucv_send_ctrl() still clears SEND_SHUTDOWN while it
allocates a control frame, so a caller without the socket lock can make
the new test miss a shutdown. On a connected socket there are two:
recvmsg()'s window update, until 3/7 puts recvmsg() under the lock, and
the NETDEV_GOING_DOWN notifier, which sets IUCV_DISCONN right after, so
the call then fails with -ECONNRESET.
---
net/iucv/af_iucv.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/net/iucv/af_iucv.c b/net/iucv/af_iucv.c
index 657c61161dbd..133c1d1886b2 100644
--- a/net/iucv/af_iucv.c
+++ b/net/iucv/af_iucv.c
@@ -1055,10 +1055,16 @@ static int iucv_sock_sendmsg(struct socket *sock, struct msghdr *msg,
/* wait if outstanding messages for iucv path has reached */
timeo = sock_sndtimeo(sk, noblock);
- err = iucv_sock_wait(sk, iucv_below_msglim(sk), timeo);
+ err = iucv_sock_wait(sk, iucv_below_msglim(sk) ||
+ (sk->sk_shutdown & SEND_SHUTDOWN), timeo);
if (err)
goto fail;
+ /* return -EPIPE if sending has been shut down meanwhile */
+ if (sk->sk_shutdown & SEND_SHUTDOWN) {
+ err = -EPIPE;
+ goto fail;
+ }
/* return -ECONNRESET if the socket is no longer connected */
if (sk->sk_state != IUCV_CONNECTED) {
err = -ECONNRESET;
--
2.56.0
Technical Details
Message-ID:
<20261110-b4-disp-2a6b4364-v3-2-35677b68e697@proton.me>Path:
mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-360858-linux-kernel-netdev=dewy.ruReferences:
<20261110-b4-disp-2a6b4364-v3-0-35677b68e697@proton.me>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-360858-linux-kernel-netdev=dewy.ru From: devnull+hexlabsecurity.proton.me@kernel.org (Bryam Vargas via B4 Relay) Newsgroups: linux.kernel.netdev Subject: [PATCH RFC net v3 2/7] net/iucv: fail sendmsg() with EPIPE once sending is shut down Date: Tue, 10 Nov 2026 23:44:27 -0500 Organization: Usenet Network Message-ID: <20261110-b4-disp-2a6b4364-v3-2-35677b68e697@proton.me> References: <20261110-b4-disp-2a6b4364-v3-0-35677b68e697@proton.me> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Injection-Info: usenet.network; logging-data="776320"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:doYZy0FJFu0Q/red4Xu6nlXwghk= sha256:GzjFJNW4P2sEBjHyJJFEjLsv3OFaKamsxhPaVa3HWKI= sha1:/+ydNEJtnOvd//XS21CT2Z9i5sQ= sha256:5PYDEfhq2ACAo85mlRSpmf07K90ebd93REHPJWTeubA= List-ID: <netdev.vger.kernel.org> X-Mailpost-Empty-Hdrs: X-Spam-Level X-Received: from localhost (localhost [127.0.0.1]) by mail.dewy.ru (Postfix) with ESMTP id A5D43113BB1; Wed, 11 Nov 2026 07:45:04 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.501 X-Spam-Status: No, score=-3.501 tagged_above=-9999 required=6.31 tests=[DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001] autolearn=ham autolearn_force=no X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key) header.d=kernel.org X-Received: from mail.dewy.ru ([127.0.0.1]) by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 71N_zH1Bz2MX; Wed, 11 Nov 2026 07:44:57 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.232.135.74; helo=sto.lore.kernel.org; envelope-from=netdev+bounces-360858-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org X-Received: from sto.lore.kernel.org (sto.lore.kernel.org [172.232.135.74]) by mail.dewy.ru (Postfix) with ESMTPS id 02672113E07; Wed, 11 Nov 2026 07:44:48 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by sto.lore.kernel.org (Postfix) with ESMTP id 85A7C643348; Wed, 11 Nov 2026 04:44:41 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-ARC-Seal: i=3; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1794372270; b=CvwmHtvZ67vpbAuoBqf4d9O1YosvYJmCtdMtWZUU26YM/WftcolmZ/1lz5k9NqNjGb6S Vn+dcYPvRrdKYQ4RqajT6B0XShOCj1+8NCdYXE91jKEAyOhBVEssPpU0pfBGMYc9kpJeS Rvfb+88UhigDcR38i92fGBPS5kGBZqwxNFHKxsOzlop++9JFEtRzOrPf2tzw2sd9qzgaN 7NhgErP1X7QmO9Z1wOflBdyL267dYpi6PRSpG+bHf8cN0h0YwqxSRnsRiwEVmF8owBMwb K19u1RMq+JJMcJGdgwZx6nMmHdhYywJ0gY0yc/hhCZoSJTQOQNvn6uCUTnOt6FW0ATg== X-ARC-Message-Signature: i=3; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794372270; h=X-Original-To:Received:Received:DKIM-Signature:Received:From:Date: Subject:X-Mailing-List:List-Id:List-Post:List-Help:List-Subscribe: List-Unsubscribe:List-Owner:Precedence:MIME-Version:Content-Type: Message-Id:References:In-Reply-To:To:Cc:X-Mailer: X-Developer-Signature:X-Developer-Key:X-Endpoint-Received: X-Original-From:Reply-To:Content-Transfer-Encoding; bh=n7Ml7fuo5YQNy3RP7RmS1mPqd8y/+2cm5W2qNSpp1bk=; b=PrAgKOBW4kjRA8fz+8wJXS/4GN+5ETadHa5Myg1vi9WOUOvGDvkGgUnwDag1wVyDFkeT bIoJeoK0r3kaO5GIl4lrsH5KHIZbTYUywz0X2OY5/CmUizRgrerM1v3sdCYPt+Vv6RtuL tHMRBIOboVqt47T1N3iBF6sWvBbmnDBByPwXdp/BTneX5m9ISruJEA6nkGNL9Q0xQUDGU /MW3C+x0WTdxxvc/gf/qBmMmbkDq8EledwKVpwjS8tpmKJVWVmv/WbN5Rany6dLtP+sTf Yfgz5ZVfCqIWU7wNdXD9Yb1PKL22q8e35aySNeqI9rWpwzCtWFKsn+eqzJIXcq8j7tA== X-ARC-Authentication-Results: i=3; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=QXFDFXme; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1A81760A260B; Wed, 11 Nov 2026 04:44:30 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=QXFDFXme X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=100.103.45.18 X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1794372269; b=e2fXDApc3MStFQt9/CmTSoA+95T//dvsZF8kniDPDU+nh/y5LSwkdN9Wo7bY1nzFb8Hn fsJzmkNb7rYOxCq+5iULlqpEWKeE3/7FU0LUJ15+5Nwc2EDp5obnUmAbZJitZ8EA70BBX otT8rVvPsmqd70g5drPRbmpXvKYyJk+a7OWltMv/UBjqnFBeUOBHoFMfTWiqxR9TVAGK2 ziGaqqEb3BPHS1Qgp3+YeZnsBk5iXaOBz6cAHygwpnTQpF2ZwkC+2gJzgdUwqXyaH2fXo 5J9Amq6+nAwpYfyj1mz+qr+/5OYR06Qw6uhbYhHfzK/2l//LpFUpnq/qXDRW8Ek8s8Q== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794372269; h=Received:DKIM-Signature:Received:From:Date:Subject:MIME-Version: Content-Type:Message-Id:References:In-Reply-To:To:Cc:X-Mailer: X-Developer-Signature:X-Developer-Key:X-Endpoint-Received: X-Original-From:Reply-To:Content-Transfer-Encoding; bh=n7Ml7fuo5YQNy3RP7RmS1mPqd8y/+2cm5W2qNSpp1bk=; b=ASJQDCi5eS8YCFnc3TfmafRds8lqjhMTWKhphRCF+Phrk9mm8D8jS7X+2abDs61Hn1jn SllX5iUD+PU4xWv2rXwbOdUjoIGjp2KtGb3TbIEkRpM4MyFQJ1AZDgiS2eAW0a+9Y4zSa qTJPCDZV9gmYL8EnYhW4Yx0eoFCx5BAzSCB3O0B4LjPaT93W1GDB1RpgMxCU24KI5hSmX F3s4m8b3D4LT+72YT/dXHqSlRP3L1rh3Ra+Ju+CntIB0j/wvf4gJCW6fTZO3gkHxafNzI fKhSgiHfxjHDN/WlwOUuo1SE9owvSZiLZGI2zXdpfR5JEmhhOJnfKtBe3Pl54bE1PEw== X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=QXFDFXme; arc=pass header.oldest-pass=0 smtp.remote-ip=100.103.45.18 X-Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 33EB8606A32E; Wed, 11 Nov 2026 04:44:29 +0000 (UTC) X-Authentication-Results: smtp.kernel.org; arc=none smtp.remote-ip=100.80.115.77 X-ARC-Seal: i=1; d=kernel.org; s=arc20260519; a=rsa-sha256; cv=none; t=1794372269; b=QkgffZIPVC8+LcoJyRhJ9w4qJOlhiX5UEv7doO4Kc4PUU+TS77yg2UbnFjX+zVP2ziKC +h4fuyi7VHl0r9bV7J62CthZmU2hP2Qljt5cneX50gWudbphiFSDCFns+Mmn3PFT8HNW4 qRkqFsOtUtcst4WKtHu7VfpcWFwiYvr7+sHy2doxpyDy94dKGLQNNrl5rtW53CU+C+3DQ 3UZaUeKDYCS5wiltsp+M034y89ZfA8cvPYwmmKD72NtapdFNTcRtB7A3/BIxFER4KbzqY X2/k7iD1KUVMTmDPHwlwOnTHqy4eToc7Ka9v0+g77uqtsr9DAq/PLPOiIcb3iNwrf7Q== X-ARC-Message-Signature: i=1; d=kernel.org; s=arc20260519; a=rsa-sha256; c=relaxed/relaxed; t=1794372269; h=DKIM-Signature:Received:From:Date:Subject:MIME-Version:Content-Type: Message-Id:References:In-Reply-To:To:Cc:X-Mailer: X-Developer-Signature:X-Developer-Key:X-Endpoint-Received: X-Original-From:Reply-To:Content-Transfer-Encoding; bh=n7Ml7fuo5YQNy3RP7RmS1mPqd8y/+2cm5W2qNSpp1bk=; b=Qfk28FHecvskZQ6sHY7xNniacnrKreQ4ydxfL+jk78qreMKGznVVFnKmSyOKfwZ/Ccjv SF0azEFCIZcD/R6NtcxsV7FU/KPFO4wP7BU8IgqbXwNWji8edF3z4mJaGRQVdcS+Ajkwp 3MJnH7ybn8NFMb6rxlO1jOA5zchrVkP4X/IhnqdOXC60aKRM0bESDspnGOYnfl05qmPWS BHXvC07wK4oXiEc3JObNVzDerz+6uBa79ny4hKCztqVw/qIAqDHzv4B2leI+oxpPCrCty fjJzTTyVwZIS58gwlqf66h3h/e0jTt3qJOdyA6ikwQ453wQZ8OAHbbQeY9je4BZ2j/A== X-ARC-Authentication-Results: i=1; smtp.kernel.org; arc=none smtp.remote-ip=100.80.115.77 X-Received: from lkml.kernel.org (nexus.subspace.kernel.org [100.80.115.77]) (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.kernel.org (Postfix) with ESMTPS id 8CBEF1F00A00; Wed, 11 Nov 2026 04:44:27 +0000 (UTC) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1794372269; bh=n7Ml7fuo5YQNy3RP7RmS1mPqd8y/+2cm5W2qNSpp1bk=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To; b=QXFDFXmeHmRtpwiurKu1A0Uzrwy8+V/qzdA68FRb2yGNOpuosfHOpownV1JdRfgn2 dCpQvxLdmKOQ7Ahht0kRqdwQ45O8XhhoSv+iuu0kQHnAKXBIYWSsQ0ZoGh2uP+QHSZ fnOLBdMAj+gvKzD9kRgQk1FiuvILcdhVxZ00p68T/ZXWP0g2xDfRqLL38QwfPb22eY cBKX1YreyLe6HiL+gNGMo3S5OpU2fDxHvS5w/bp4nI3WrcDTP3LqgBX0k5TZPXO0Vf g6jVhecxjTPURba8UWCRxk3qUwtv4jj2sRs8cif2lW7OolQQ0FkZPQTQrKpvXwuCFT BSwk5cRsPSXpQ== X-Received: from nexus.subspace.kernel.org (localhost [IPv6:::1]) by lkml.kernel.org (Postfix) with ESMTP id 1B36F48D8F; Wed, 11 Nov 2026 04:44:27 +0000 (UTC) X-Mailing-List: netdev@vger.kernel.org X-List-Post: <mailto:netdev@vger.kernel.org> X-List-Help: <mailto:netdev+help@vger.kernel.org> X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org> X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org> X-List-Owner: <mailto:netdev+owner@vger.kernel.org> X-Precedence: list X-In-Reply-To: <20261110-b4-disp-2a6b4364-v3-0-35677b68e697@proton.me> X-Cc: linux-kernel@vger.kernel.org, Thorsten Winkler <twinkler@linux.ibm.com>, Nagamani PV <nagamani@linux.ibm.com>, Simon Horman <horms@kernel.org>, netdev@vger.kernel.org, linux-s390@vger.kernel.org X-Mailer: b4 0.15.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1794372266; l=3220; i=hexlabsecurity@proton.me; s=default; h=from:subject:message-id; bh=7649mWdFyPHHdznp9ibYDQHg6sWSCfctd7MGqW+sc1A=; b=i7P/l0LC962NTn0Fm3gYmrcALMUuHVrQ1hbwWls5Cz9PfsuKudOUOg0naDAJydSSgNCs4+9Xf tyUMcD6oLtYC6DNDxv+166xH2+WbC2mFjaeFEd/enIv2kAOscxzhikq X-Developer-Key: i=hexlabsecurity@proton.me; a=ed25519; pk=xw1AhCtQdvuoQc+bOQIYy9o8G++cp4/VniI2G/tc3G8= X-Endpoint-Received: by B4 Relay for hexlabsecurity@proton.me/default with auth_id=893 X-Original-From: Bryam Vargas <hexlabsecurity@proton.me> X-Reply-To: hexlabsecurity@proton.me