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 1DFCA3603EE; Tue, 21 Jul 2026 22:33:13 +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=1784673194; cv=none; b=ocFcZkUkuKNOnnYuY6qCCERzLDQ2AKA6saO6IhEwZPHuHZ5E4oyeSL3l/UDEoiURJN9lrKt3OLJXtuQgE1hW1iWLea4N/cakeW+QIvRkLsDD52HEvg385mti9iZJNj1BqSpRTcKslD+oJW6WZE8ZWpaLhISCWK+1Lt+uIzFyMR8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784673194; c=relaxed/simple; bh=ES+LQsFPXD1HnRVTgDLHCgs6nUWk/p/CAUWTutG4CoE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=eoMgH9Um4SnCpWITO8B+hS+V0Rezjz3qNlAieBe8crOmt5X/xArJnzBRJgVG/V6Ohjvinoyxt0srgjWo23kIesw2LLyPhW6bPTmUfICmxRcCaUI8VeIWhGfJQRVbIRkdpKnNMlFZ633K+A8TDHhQjnq8J23CnKWleKEAHYpxgiA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=l+UPf4+C; 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="l+UPf4+C" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8B3111F000E9; Tue, 21 Jul 2026 22:33:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1784673193; bh=Tly2R38YxPoVLkeO+gM6br4qtwS3NKwwyBhWRIsg1wA=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=l+UPf4+C8hIWO8zUlf9R4TxOONRpe6TTsOeBSjM/FK3igfWpqhuVMz6jVuIB9cjhb H385mLXMAwWEiBTRWkEOFgqggYobv2T8aSKPpgi5B6D3JNqO9dcyN/Mh3CpL/4iL7m 91+/6hCHYHZQ9L0582ldA4Em3oyiRghK1vCZBW3M= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Yizhou Zhao , Yuxiang Yang , Ao Wang , Xuewei Feng , Qi Li , Ke Xu , Alexander Aring , Jakub Kicinski Subject: [PATCH 5.10 069/699] 6lowpan: fix NHC entry use-after-free on error path Date: Tue, 21 Jul 2026 17:17:08 +0200 Message-ID: <20260721152357.260975905@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260721152355.667394603@linuxfoundation.org> References: <20260721152355.667394603@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 5.10-stable review patch. If anyone has any objections, please let me know. ------------------ From: Yizhou Zhao commit 1720db928e5a58ca7d75ac1d514c3b73fd7061a7 upstream. lowpan_nhc_do_uncompression() looks up an NHC descriptor while holding lowpan_nhc_lock. If the descriptor has no uncompress callback, the error path drops the lock before printing nhc->name. lowpan_nhc_del() removes descriptors under the same lock and then relies on synchronize_net() before the owning module can be unloaded. That only waits for net RX RCU readers. lowpan_header_decompress() is also exported and can be reached from callers that are not necessarily covered by the net core RX critical section, for example the Bluetooth 6LoWPAN L2CAP receive path. This leaves a race where one task drops lowpan_nhc_lock in the error path, another task unregisters and frees the matching descriptor after synchronize_net() returns, and the first task then dereferences nhc->name for the warning. With the post-unlock window widened, KASAN reports: BUG: KASAN: slab-use-after-free in lowpan_nhc_do_uncompression+0x1f4/0x220 Read of size 8 lowpan_nhc_do_uncompression lowpan_header_decompress Fix this by printing the warning before dropping lowpan_nhc_lock, so the descriptor name is read while unregister is still excluded. The malformed packet is still rejected with -ENOTSUPP. Fixes: 92aa7c65d295 ("6lowpan: add generic nhc layer interface") Cc: stable@vger.kernel.org Reported-by: Yizhou Zhao Reported-by: Yuxiang Yang Reported-by: Ao Wang Reported-by: Xuewei Feng Reported-by: Qi Li Reported-by: Ke Xu Signed-off-by: Yizhou Zhao Acked-by: Alexander Aring Link: https://patch.msgid.link/20260609080054.4541-1-zhaoyz24@mails.tsinghua.edu.cn Signed-off-by: Jakub Kicinski Signed-off-by: Greg Kroah-Hartman --- net/6lowpan/nhc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/net/6lowpan/nhc.c +++ b/net/6lowpan/nhc.c @@ -168,9 +168,9 @@ int lowpan_nhc_do_uncompression(struct s return ret; } } else { - spin_unlock_bh(&lowpan_nhc_lock); netdev_warn(dev, "received nhc id for %s which is not implemented.\n", nhc->name); + spin_unlock_bh(&lowpan_nhc_lock); return -ENOTSUPP; } } else {