From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796439749; b=UEB1tvnvoyfrxdDi4Ed+wdUEQFgYxcyYNE41EFleGj6oIoMxrLvDhFe7kMkyEoSW5cm8 xtfaQqrzzywjBnhXTTDHLCYHB/MiItSzBTmmFTzYunYkbzT8wwXuEqsIPE9WCZkG0zGA2 SNqd7GSsBrxb/vBQ/Wsa2FfHh9xt5lUuqsGeYM+TbbgNdxSvoIYh9abB5yCpuxyfXQbcK +0g+fej38qr+0vFduEx6ysnJxvdzCS446xzbhZIk4lCWuKJ2WQI3b9W5Im+XAxqtWYX40 nHcswiEk1l2goaFvdmG/h9XNeNS+GO09LDWI3hKWsjXK0V/650LqjvSkjhjIAqgJFKg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796439749; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=AcrPVWoM3BXzu8QQVR2yE2gZ6FJ+tTBX80JC2ocdU3A=; b=D54ZFEmNl2l2iwD6d/8VpP++ynVDHLhsVw2+lLoUvDvUOmAhLbRHTLQVtTwHEyO/y2uf 0vBr4W9BW83JmLNdL6ik0oVrqDzRUiY3CICpHHWKIvdrLY62rJCnmbp8uKyXXnvjCnL6a jgmR4BpCHAAD4LFj/0Gt+Ln5a3nP3azhgDnVy70HFCGDjGtfmCK3YwakQSwqJLSuAgoDb Tnp0cxqkM5Llb/vxdxc2JTwLeq0cXoPvs1F3Y8vz1S/uxcRxMJfYavnDCbSIMDzYhVL33 mM8hRr9I/PqRjh19As8PDbx+4aeWyuMI1kTpc7qoRAdm20z4Dh4cuzhyI2rYH/sj7AQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=NQol4GL4; arc=none smtp.remote-ip=100.103.45.18 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 21B7C606A32D for ; Sat, 5 Dec 2026 03:02:29 +0000 (UTC) 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=NQol4GL4 Received: by smtp.kernel.org (Postfix) with ESMTPSA id AF5FE1F00936; Sat, 5 Dec 2026 03:02:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796439748; bh=AcrPVWoM3BXzu8QQVR2yE2gZ6FJ+tTBX80JC2ocdU3A=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=NQol4GL4HPk6R/frvJLK8FktjFg2ZxHNg/WSvfTAyowgY4HDyWzloSAceS+BPi9pi yGnKcCp11hXeFueNrAP94dH+4jYG7aIH7SQM1W/MotER2gaL5rFpcX0GC2GDTqAkyG nfLdjL/k4TcJMEvoz/6ibKVxW2CXgI4+LTpKeKXYx1NLrWlhNa1PseHOB+EjKS2vAC amXpi/RUkIfQeX8YKJbwu+1b84gmWsxjWbdmCZTNtvElTJ8ZuNs+pwgYPTbgyFwoW/ 435zdmKaMCAHvM/CCV24IiZeM/mCvdtOafLZr5WE38KLHG4HUdfe1ohkgonjJ0z+rX 1TTiFPD7n5T1w== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH RFC net v5 06/10] net/iucv: serialize HiperSockets receive with the socket lock Reply-To: sashiko-reviews@lists.linux.dev To: "Bryam Vargas" Cc: linux-s390@vger.kernel.org, "Heiko Carstens" , "Vasily Gorbik" , "Alexander Gordeev" , "Christian Borntraeger" In-Reply-To: <20261203-b4-disp-8029c32d-v5-6-0bce531e20d0@proton.me> References: <20261203-b4-disp-8029c32d-v5-0-0bce531e20d0@proton.me> <20261203-b4-disp-8029c32d-v5-6-0bce531e20d0@proton.me> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Sat, 05 Dec 2026 03:02:28 +0000 X-Mailing-List: linux-s390@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Thank you for your contribution! Sashiko AI review found 3 potential issues to consider: - [Medium] net/iucv: unsynchronized sk_state access and listen() ordering race - [Medium] net/iucv: unconditional spin_lock_bh() in afiucv_hs_apply_now() - [Medium] net/iucv: unconditional sk_lock.slock in afiucv_hs_apply_now() -- commit 28a4d9fb269c7f73184d3bc11fbe4ca645c81ec9 Author: Bryam Vargas net/iucv: serialize HiperSockets receive with the socket lock This commit takes bh_lock_sock() in afiucv_hs_rcv() and defers HiperSockets control and receive handling while a task owns the socket, recording SYN replies and FINs in iucv_sock.hs_pending and queuing SYNs and dependent data frames onto the socket backlog. Link: https://lore.kernel.org/all/20260724222917.134769-1-hexlabsecurity@pr= oton.me/ > diff --git a/net/iucv/af_iucv.c b/net/iucv/af_iucv.c > index bc60fcaca1b0b..bf97b8c62eb2e 100644 > --- a/net/iucv/af_iucv.c > +++ b/net/iucv/af_iucv.c [ ... ] > @@ -77,10 +78,81 @@ static void afiucv_hs_fin(struct sock *sk) [ ... ] > +static void afiucv_hs_apply_now(struct sock *sk, u8 mask) > +{ > + spin_lock_bh(&sk->sk_lock.slock); > + afiucv_hs_apply(sk, mask); > + spin_unlock_bh(&sk->sk_lock.slock); > +} [Severity: Medium] Does afiucv_hs_apply_now() need to take sk->sk_lock.slock unconditionally when iucv_sk(sk)->hs_pending has no bits matching mask set? In afiucv_hs_backlog_rcv(), __release_sock() invokes this once per queued skb, acquiring and releasing sk->sk_lock.slock on every frame after the fir= st and on every backlogged SYN for a listener even though AF_IUCV_PEND_SYNREPLY is never set there. An unlocked fast-path check on READ_ONCE(iucv_sk(sk)->hs_pending) & mask (paired with WRITE_ONCE() updates to hs_pending) would skip the spinlock and BH disable/enable in the common case. [ ... ] > @@ -214,6 +305,28 @@ static inline int iucv_below_msglim(struct sock *sk) [ ... ] > +static bool iucv_sock_send_ready(struct sock *sk) > +{ > + if (iucv_sk(sk)->transport =3D=3D AF_IUCV_TRANS_HIPER) > + afiucv_hs_apply_now(sk, AF_IUCV_PEND_FIN); > + return iucv_below_msglim(sk) || (sk->sk_shutdown & SEND_SHUTDOWN); > +} [Severity: Medium] Can calling afiucv_hs_apply_now() unconditionally from iucv_sock_send_ready= () add unnecessary sk->sk_lock.slock contention on the HiperSockets TX hot pat= h? iucv_sock_sendmsg() evaluates iucv_sock_send_ready() on every message, and twice before sleeping when the send window is full because iucv_sock_wait() checks its condition in both the outer if and inner while loop. Since a pe= er FIN is recorded at most once at teardown, taking sk->sk_lock.slock on every sendmsg() adds a per-message spin_lock_bh() round-trip that contends with t= he per-packet bh_lock_sock() in afiucv_hs_rcv() on full-duplex streams. [ ... ] > @@ -865,7 +979,8 @@ static int iucv_sock_listen(struct socket *sock, int = backlog) > if (sock->type !=3D SOCK_STREAM && sock->type !=3D SOCK_SEQPACKET) > goto done; > =20 > - sk->sk_max_ack_backlog =3D backlog; > + /* read in softirq by afiucv_hs_backlog_add() */ > + WRITE_ONCE(sk->sk_max_ack_backlog, backlog); > sk->sk_ack_backlog =3D 0; > sk->sk_state =3D IUCV_LISTEN; > err =3D 0; [Severity: Medium] Can sk->sk_state =3D IUCV_LISTEN be reordered ahead of WRITE_ONCE(sk->sk_max_ack_backlog, backlog) here? afiucv_hs_rcv() calls afiucv_hs_stray() under bh_lock_sock() before checking sock_owned_by_user(), so it runs concurrently with iucv_sock_listen() under lock_sock(). A plain non-volatile store to sk->sk_state has no release or compiler barrier against the preceding WRITE_ONCE(): CPU0 (process, lock_sock) CPU1 (softirq, bh_lock_sock) iucv_sock_listen() sk->sk_state =3D IUCV_LISTEN (reordered) afiucv_hs_rcv() afiucv_hs_stray() sk->sk_state =3D=3D IUCV_LISTEN afiucv_hs_backlog_add() READ_ONCE(sk->sk_max_ack_backlog) <-- reads 0, refuses SYNs WRITE_ONCE(sk->sk_max_ack_backlog, backlog) When that happens, valid SYNs beyond the first are spuriously refused while listen() still owns the socket. Separately, plain writes to sk->sk_state under lock_sock() (in iucv_sock_listen(), __iucv_sock_close(), iucv_sock_cleanup_listen(), and iucv_sock_recvmsg()) race with plain reads in afiucv_hs_stray(), afiucv_hs_callback_win(), and afiucv_hs_callback_rx(), and iucv_sock_recv_skb() reads sk->sk_state without READ_ONCE() inside sk_wait_event() after release_sock() while afiucv_hs_fin() writes it in softirq, triggering KCSAN data races. Using smp_store_release(&sk->sk_state, IUCV_LISTEN) paired with smp_load_acquire(&sk->sk_state) in afiucv_hs_stray(), along with READ_ONCE()/WRITE_ONCE() on the other concurrent sk->sk_state accesses, would fix both the ordering race and the data races. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261203-b4-disp-80= 29c32d-v5-0-0bce531e20d0@proton.me?part=3D6