From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 D184733EAF9; Mon, 20 Apr 2026 16:02:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776700946; cv=none; b=UufzPCHCRhZJ9equZy0VIXsm7e2HhitxzbtPxzIrcxh+Q/n95/B3QyH6EwOECIdw5w3ciJfG/XBmX8kqZnyahNfthWcDR2cGv7vDkLYVweghUO2+uBAdxQktE/ytWw8of4v+Qof2tbUykIK00JytPIBr+FqJyRZtoaCn4DXiWqk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776700946; c=relaxed/simple; bh=nwt22t0nK3r42Ot6R2b+7kc6v2OuPUDYv6sZ/r8Kc88=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ehZaOFLdg9EThIt9y54JaoNTW7XSosDTFv2ZhmdUnyh4jYsbP1MiQf1WgaMKG8mDXexn76OVM5dWiU7Pm4MZYT0YJLoEozL2PxehFjRmev9grFdK2AMWypmposYC268OuGmEJwVFO5sxo8Jf/UyeTLGJUV0oZORPU3gltog60us= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=wRAAFHDZ; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="wRAAFHDZ" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6A6B2C19425; Mon, 20 Apr 2026 16:02:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1776700946; bh=nwt22t0nK3r42Ot6R2b+7kc6v2OuPUDYv6sZ/r8Kc88=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=wRAAFHDZDmlyovdv/715uM+tf0b/FZ3810jwMTOHjiY4YmwixBsQxznGAjDOD2bV7 yNValR2Qzzrs7u3rwVqWEEmeg3QS8wcOIOnG4oT1DLqgiVXd3PM+MpHdn3Z3t1eJQp Iyg9xNmzB+T1LmS39dr384O9XtPLay3FRHBEM4Io= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Junxi Qian , Eric Dumazet , Jakub Kicinski Subject: [PATCH 6.18 122/198] nfc: llcp: add missing return after LLCP_CLOSED checks Date: Mon, 20 Apr 2026 17:41:41 +0200 Message-ID: <20260420153939.998212567@linuxfoundation.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260420153935.605963767@linuxfoundation.org> References: <20260420153935.605963767@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: Junxi Qian commit 2b5dd4632966c39da6ba74dbc8689b309065e82c upstream. In nfc_llcp_recv_hdlc() and nfc_llcp_recv_disc(), when the socket state is LLCP_CLOSED, the code correctly calls release_sock() and nfc_llcp_sock_put() but fails to return. Execution falls through to the remainder of the function, which calls release_sock() and nfc_llcp_sock_put() again. This results in a double release_sock() and a refcount underflow via double nfc_llcp_sock_put(), leading to a use-after-free. Add the missing return statements after the LLCP_CLOSED branches in both functions to prevent the fall-through. Fixes: d646960f7986 ("NFC: Initial LLCP support") Signed-off-by: Junxi Qian Reviewed-by: Eric Dumazet Link: https://patch.msgid.link/20260408081006.3723-1-qjx1298677004@gmail.com Signed-off-by: Jakub Kicinski Signed-off-by: Greg Kroah-Hartman --- net/nfc/llcp_core.c | 2 ++ 1 file changed, 2 insertions(+) --- a/net/nfc/llcp_core.c +++ b/net/nfc/llcp_core.c @@ -1091,6 +1091,7 @@ static void nfc_llcp_recv_hdlc(struct nf if (sk->sk_state == LLCP_CLOSED) { release_sock(sk); nfc_llcp_sock_put(llcp_sock); + return; } /* Pass the payload upstream */ @@ -1182,6 +1183,7 @@ static void nfc_llcp_recv_disc(struct nf if (sk->sk_state == LLCP_CLOSED) { release_sock(sk); nfc_llcp_sock_put(llcp_sock); + return; } if (sk->sk_state == LLCP_CONNECTED) {