Linux kernel -stable discussions
 help / color / mirror / Atom feed
From: Hidayath Khan <hidayath@linux.ibm.com>
To: aswin@linux.ibm.com, wintera@linux.ibm.com, pasic@linux.ibm.com,
	nagamani@linux.ibm.com
Cc: wenjia@linux.ibm.com, gbayer@linux.ibm.com,
	linux390-list@tuxmaker.boeblingen.de.ibm.com,
	mjambigi@linux.ibm.com, sidraya@linux.ibm.com,
	hidayath@linux.ibm.com, stable@vger.kernel.org
Subject: [PATCH net] net/af_iucv: fix use-after-free of listen sock in iucv_callback_connreq()
Date: Mon,  6 Jul 2026 10:48:25 +0200	[thread overview]
Message-ID: <20260706084825.6231-1-hidayath@linux.ibm.com> (raw)

iucv_callback_connreq() looks up the listening socket in iucv_sk_list
under read_lock(&iucv_sk_list.lock), drops the lock, and only then
uses the socket (bh_lock_sock() and the following connection setup).
No reference is taken on the socket before the lock is released.

The callback runs from the iucv tasklet. A concurrent close of the
listening socket does not synchronize with it.
Between read_unlock() and bh_lock_sock() a concurrent close on another
CPU can free the socket.

Fixes: eac3731bd04c ("[S390]: Add AF_IUCV socket support")
Cc: stable@vger.kernel.org
Signed-off-by: Hidayath Khan <hidayath@linux.ibm.com>
---
 net/iucv/af_iucv.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/net/iucv/af_iucv.c b/net/iucv/af_iucv.c
index fed240b453bd..890d9df5ae36 100644
--- a/net/iucv/af_iucv.c
+++ b/net/iucv/af_iucv.c
@@ -1616,6 +1616,8 @@ static int iucv_callback_connreq(struct iucv_path *path,
 			iucv = iucv_sk(sk);
 			break;
 		}
+	if (iucv)
+		sock_hold(sk);
 	read_unlock(&iucv_sk_list.lock);
 	if (!iucv)
 		/* No socket found, not one of our paths. */
@@ -1684,6 +1686,7 @@ static int iucv_callback_connreq(struct iucv_path *path,
 	err = 0;
 fail:
 	bh_unlock_sock(sk);
+	sock_put(sk);
 	return 0;
 }
 
-- 
2.52.0


             reply	other threads:[~2026-07-06  8:48 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-06  8:48 Hidayath Khan [this message]
2026-07-09 14:47 ` [PATCH net] net/af_iucv: fix use-after-free of listen sock in iucv_callback_connreq() Alexandra Winter

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=20260706084825.6231-1-hidayath@linux.ibm.com \
    --to=hidayath@linux.ibm.com \
    --cc=aswin@linux.ibm.com \
    --cc=gbayer@linux.ibm.com \
    --cc=linux390-list@tuxmaker.boeblingen.de.ibm.com \
    --cc=mjambigi@linux.ibm.com \
    --cc=nagamani@linux.ibm.com \
    --cc=pasic@linux.ibm.com \
    --cc=sidraya@linux.ibm.com \
    --cc=stable@vger.kernel.org \
    --cc=wenjia@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