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 0AC4C4189DA; Tue, 21 Jul 2026 21:56:59 +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=1784671020; cv=none; b=lm7ofWMZCwIf3gwSTEOR2t+V677jggRDu6zdE1fcH60xTYQcy0MIXj77IoziRFM9k1gab33Mkpo/lwGhNXBEG1E439gPb/c6zfnXABovXrcFfsqFpDG0cjAO489H2ar/wq50dJjRxMuH62ILtio01xQy5lTs+eYW7OftQpTCzDE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784671020; c=relaxed/simple; bh=uoKZbQfHbpbzpdJLE+jEc0AN4xXBVuK3IuxmDo4GpBs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=BOCjtMtzYehGKprvpv0MLctT57c6zTHwaKWUHv6iuqlpQ6eLI+fjtSkO5BqSL+lHY/6AWA6jLaj7HrTnYBtgm8Zf9JfpFaDSwYTerI//OFPBZr7l2sRNaht5WLh5QPCmphE3KbxMwZFo3/HjMoGnHQZZ6QVqkQv+SZ5cuukCy8c= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=ERy80mpV; 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="ERy80mpV" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 782261F000E9; Tue, 21 Jul 2026 21:56:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1784671018; bh=kz3t3wySaHS0AEPe5WSog1vCdMxnI1/q6ARcuB/SWkA=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=ERy80mpVyc2wpIBNGgBaw1IJg0GR5xmx268NZE3N8kM5EDLKYog7CHOOU+tvOXnD/ HS0negv4WVn6muc88CBhZplWvBD7DbKYhAVcXXnOj2AM4kjQO0rq82eQAOsEPe0xA+ B5Zo7qqGoy33i1SslIUm5y6z0+3H4LW2HO/qpnxo= 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.15 089/843] 6lowpan: fix NHC entry use-after-free on error path Date: Tue, 21 Jul 2026 17:15:24 +0200 Message-ID: <20260721152408.002357453@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260721152405.946368001@linuxfoundation.org> References: <20260721152405.946368001@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.15-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 {