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 NULL deref in afiucv_hs_callback_syn()
Date: Mon,  6 Jul 2026 11:40:19 +0200	[thread overview]
Message-ID: <20260706094019.6600-1-hidayath@linux.ibm.com> (raw)

afiucv_hs_callback_syn() allocates the child socket with GFP_ATOMIC,
which can fail and return NULL. The connection-refused branch is
entered when the listen state check fails, the accept backlog is
full, or nsk is NULL - and unconditionally calls iucv_sock_kill(nsk).
When entered due to allocation failure, iucv_sock_kill() dereferences
the NULL pointer at the sock_flag(sk, SOCK_ZAPPED) check, causing a
NULL pointer dereference in softirq context.

Only kill the child socket if it was actually allocated.

Fixes: 3881ac441f64 ("af_iucv: add HiperSockets transport")
Cc: stable@vger.kernel.org
Signed-off-by: Hidayath Khan <hidayath@linux.ibm.com>
---
 net/iucv/af_iucv.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/net/iucv/af_iucv.c b/net/iucv/af_iucv.c
index 890d9df5ae36..a471fbe178e8 100644
--- a/net/iucv/af_iucv.c
+++ b/net/iucv/af_iucv.c
@@ -1875,7 +1875,8 @@ static int afiucv_hs_callback_syn(struct sock *sk, struct sk_buff *skb)
 		afiucv_swap_src_dest(skb);
 		trans_hdr->flags = AF_IUCV_FLAG_SYN | AF_IUCV_FLAG_FIN;
 		err = dev_queue_xmit(skb);
-		iucv_sock_kill(nsk);
+		if (nsk)
+			iucv_sock_kill(nsk);
 		bh_unlock_sock(sk);
 		goto out;
 	}
-- 
2.52.0


                 reply	other threads:[~2026-07-06  9:40 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20260706094019.6600-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