Linux s390 Architecture development
 help / color / mirror / Atom feed
From: Hidayath Khan <hidayath@linux.ibm.com>
To: Bryam Vargas <hexlabsecurity@proton.me>,
	Alexandra Winter <wintera@linux.ibm.com>,
	Thorsten Winkler <twinkler@linux.ibm.com>
Cc: Heiko Carstens <hca@linux.ibm.com>,
	Vasily Gorbik <gor@linux.ibm.com>,
	Alexander Gordeev <agordeev@linux.ibm.com>,
	"David S . Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	Simon Horman <horms@kernel.org>,
	linux-s390@vger.kernel.org, netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [RFC] net/iucv: af_iucv socket locking - accounting, and a staged plan
Date: Wed, 2 Sep 2026 20:39:18 +0530	[thread overview]
Message-ID: <12b16822-bb3b-4730-8d54-9a50eb50cdda@linux.ibm.com> (raw)
In-Reply-To: <20260828183431.21830-1-hexlabsecurity@proton.me>


On 29/08/26 12:04 am, Bryam Vargas wrote:
> Hidayath,
>
>> Let me know how you'd like to sequence it.
> Don't sequence them behind me. Send the accept_q_lock patch now, and take
> iucv_callback_connreq() back. I asked for it on the 21st assuming the rework
> would move, and it won't for a while: I'm in the middle of a larger project and
> have only a few hours a week for this at the moment. Holding two patches and a
> leak fix for that is a bad trade for you.
I appreciate the advice, but I am going to hold onto these patches for 
the time being.
The consensus is that we land your core socket locking rework first before
tackling the remaining gaps. We want to avoid sending partial fixes that 
merely
narrow race windows, as that will make the underlying bugs harder to 
reproduce and
add confusion.

It also gives me time to properly rework the patch:
[PATCH net] net/af_iucv: fix use-after-free of listen sock in 
iucv_callback_connreq()
and confirm all reproducers.

>
> One thing worth having before the walk fix goes out. The lock on the walk is
> necessary and it isn't sufficient. Both producers link the child and set its
> state afterwards: iucv_accept_enqueue() at af_iucv.c:1916, then
> nsk->sk_state = IUCV_CONNECTED at :1917, and the same order at :1693 and :1696.
> So the state store sits outside accept_q_lock, and a walker holding that lock
> still reads sk_state at :1372 with nothing ordering the two. iucv_accept_poll()
> tests exactly that field to decide EPOLLIN, so a poll landing between :1916 and
> :1917 sees a child that is on the queue and not yet CONNECTED. Moving the state
> store ahead of the enqueue in both producers closes it. The lock alone narrows
> the window.
Agreed. The planned accept_q series incorporates your feedback
to ensure the state ordering and walk serialization close the race 
completely.

- Patch 1: Takes accept_q_lock inside iucv_accept_poll().
- Patch 2: Explicitly reorders the producers (iucv_callback_connreq and
   afiucv_hs_callback_syn) to set nsk->sk_state = IUCV_CONNECTED before
   calling iucv_accept_enqueue(), ensuring a locked walker never reads
   an un-updated state.
- Patch 3: Extends proper accept_q_lock serialization to the sleeping
   walk inside iucv_accept_dequeue().

>
>> while iucv_accept_enqueue() appends from the IUCV tasklet and the
>> HiperSockets softirq under bh_lock_sock(parent)
> Small correction that doesn't change your conclusion: the append's own lock is
> spin_lock_irqsave(&par->accept_q_lock) at :516-518, not bh_lock_sock. The walk
> takes neither, so the finding stands either way -- it matters only for where
> the fix goes.
Thanks for pointing out the distinction on accept_q_lock vs bh_lock_sock 
- noted.
>
> You're right about iucv_accept_dequeue() too. Its walk at :542 is equally
> unlocked and can't be wrapped the same way, because the loop body sleeps in
> lock_sock() at :544.
>
> All of that is source plus a model, not a run. I have no Z.
I will rebase these patches on top of Stage 1 once it lands.

Thanks,
Hidayath
>
> Thanks,
> Bryam

  reply	other threads:[~2026-09-02 15:09 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-24 22:29 [RFC] net/iucv: af_iucv socket locking - accounting, and a staged plan Bryam Vargas
2026-07-28 12:52 ` Alexandra Winter
2026-08-09  1:49   ` Bryam Vargas
2026-08-10  7:47     ` Alexandra Winter
2026-08-22 19:08   ` Hidayath Khan
2026-08-28 18:34     ` Bryam Vargas
2026-09-02 15:09       ` Hidayath Khan [this message]
2026-08-21 15:28 ` 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=12b16822-bb3b-4730-8d54-9a50eb50cdda@linux.ibm.com \
    --to=hidayath@linux.ibm.com \
    --cc=agordeev@linux.ibm.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=gor@linux.ibm.com \
    --cc=hca@linux.ibm.com \
    --cc=hexlabsecurity@proton.me \
    --cc=horms@kernel.org \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-s390@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=twinkler@linux.ibm.com \
    --cc=wintera@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