From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 67DEA43DA35; Thu, 30 Jul 2026 14:59:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785423593; cv=none; b=uokVcSLoyF/tM4nU6vy0sTw23eoqC4Gc1U6ch8PlUWrfI/QbnsYVWZPqL4U65OYgEvf9O7gFfhB7gCx0ahxQghq7JgOPcojTPyi0bCsrI2B36tQ3zQfamW2uLK6/m7nBzjE9SCbZMU0/wNmL9NRv6y3drsW6wdsTr6GJHqDGtd4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785423593; c=relaxed/simple; bh=E23ZecO53fC10SeM2DLdqXUoYkIDrfoXRI6/dfRFBRQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=OWrcc7P2agh8jUYiPoTS1g+eh8i1ZVvu5bynZ5suY0xAEQfd48Kc8x6hOTeDbyJNyhViVRM7uEhp9Dgwx9hkiTs6A/VnhRLbA/5ikwfVs7h0+uCgM6O5IAHQBSRwFIIBh0XrrscM6XHTKjGPAyyOu5pm+8ga7AruMAcAwY2BamU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=YanGCHMh; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="YanGCHMh" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7ACB71F000E9; Thu, 30 Jul 2026 14:59:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1785423592; bh=w+CYxyoi7rp4nmHGx4oXvjPgyBPpi+lpeK+AEQi6KeE=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=YanGCHMh7lunApY/UlCuLXbEKWHIQCJluoasxsVE3SSCtGbhF772W8FC2ymXYKfYd J0RtxKCLEYl3S7wWXx/PyygUrdhhtKR/Ph4P2ci8MVSqEPmhAvrVr4k3NHamKrXfz1 2EUFLl0NrD/hGYjuDDOtI0bcHxM1AVcTmFDihvcw= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Bryam Vargas , Hidayath Khan , Paolo Abeni , Sasha Levin Subject: [PATCH 6.18 098/675] net/iucv: take a reference on the socket found in afiucv_hs_rcv() Date: Thu, 30 Jul 2026 16:07:08 +0200 Message-ID: <20260730141447.212356408@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260730141445.110192266@linuxfoundation.org> References: <20260730141445.110192266@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Bryam Vargas [ Upstream commit 4fa349156043dc119721d067329714179f501749 ] afiucv_hs_rcv() looks up the destination socket under iucv_sk_list.lock, drops the lock, and then passes the socket to the afiucv_hs_callback_*() handlers without holding a reference. AF_IUCV sockets are not RCU-protected and are freed synchronously by iucv_sock_kill() -> sock_put(), so a concurrent close can free the socket in the window between read_unlock() and the handler, which then dereferences freed memory (for example sk->sk_data_ready() in afiucv_hs_callback_syn()). Take a reference with sock_hold() while the socket is still on the list and release it with sock_put() once the handler has run. Fixes: 3881ac441f64 ("af_iucv: add HiperSockets transport") Signed-off-by: Bryam Vargas Reviewed-by: Hidayath Khan Link: https://patch.msgid.link/20260705-b4-disp-fc79c0dc-v1-1-d2cdcb57afa9@proton.me Signed-off-by: Paolo Abeni Signed-off-by: Sasha Levin --- net/iucv/af_iucv.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/net/iucv/af_iucv.c b/net/iucv/af_iucv.c index c66b90c912e78e..bd0405373c5e97 100644 --- a/net/iucv/af_iucv.c +++ b/net/iucv/af_iucv.c @@ -2089,6 +2089,8 @@ static int afiucv_hs_rcv(struct sk_buff *skb, struct net_device *dev, } } } + if (sk) + sock_hold(sk); read_unlock(&iucv_sk_list.lock); if (!iucv) sk = NULL; @@ -2138,6 +2140,8 @@ static int afiucv_hs_rcv(struct sk_buff *skb, struct net_device *dev, kfree_skb(skb); } + if (sk) + sock_put(sk); return err; } -- 2.53.0