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 8E56BDDAD for ; Sun, 25 Feb 2024 08:16:55 +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=1708849015; cv=none; b=K1/WPM6WefEubuyZhF8T/cQ9+Ray2wrYAVI5I38Jm2slkxdTw9bcDxUp5zaygezFfnoOf1ga6+dgXeHLsNZfBUGbQZ3Iqp2FVDXkVKlWU7PU80NLt4S0dp5Ku4lIXiViQCrj8g9loDgo9WQ8nL7ome6LCWimk/oCdoyKRrgdh4U= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708849015; c=relaxed/simple; bh=Or5uC61ZtwQ9egTv4jzSfQKhkP0M4EQw6wZpXbPNBR0=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=jv/WbwTzpSpOWf8UhkKv+Hleu0YkIFg9XZ+6b7iD0WMDVqCwGSMewk3YqPe4rYuraOd7hRmMVV1342Kr7y9D/TAwvhKXP/tUg9n1ivagmanXxhd+6eDxW5BvHTuopq2KiA6zxQ+AUy08XJhuxWnQF9aEcr7/h42k6B2AQpUrKKw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=VQgmzjHC; 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="VQgmzjHC" Received: by smtp.kernel.org (Postfix) with ESMTPSA id BA3F8C433F1; Sun, 25 Feb 2024 08:16:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1708849015; bh=Or5uC61ZtwQ9egTv4jzSfQKhkP0M4EQw6wZpXbPNBR0=; h=From:To:Cc:Subject:Date:Reply-to:From; b=VQgmzjHCbi5PVHJjo/JDBNUNXFt5dGbpNAgaK7WFF115Cq2GNEd3vOEiWbFDb+doC 5P7gVJmvq9nJ9l2D4yUaYZDtXdANNMltp+vdkp55dw1O+PE3eRioBP+bJukbrpkLQP esHf6Ysx4c9TYg2QVhxVqhFdKQpRwamYsG23kv7U= From: Greg Kroah-Hartman To: linux-cve-announce@vger.kernel.org Cc: Greg Kroah-Hartman Subject: CVE-2023-52468: class: fix use-after-free in class_register() Date: Sun, 25 Feb 2024 09:16:46 +0100 Message-ID: <2024022545-CVE-2023-52468-59a2@gregkh> X-Mailer: git-send-email 2.44.0 Precedence: bulk X-Mailing-List: linux-cve-announce@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Reply-to: , X-Developer-Signature: v=1; a=openpgp-sha256; l=3526; i=gregkh@linuxfoundation.org; h=from:subject:message-id; bh=Or5uC61ZtwQ9egTv4jzSfQKhkP0M4EQw6wZpXbPNBR0=; b=owGbwMvMwCRo6H6F97bub03G02pJDKm3vuee7epM22Bo+Dcj85P7x9nvQxnkSmyYZ82uk0z1i byn/8OsI5aFQZCJQVZMkeXLNp6j+ysOKXoZ2p6GmcPKBDKEgYtTACZSepNhwY6Agydvy35w3ZAe Uymc0Ddli22KPMM8g0uic3R7jHJu9p+9Zybs+Yg38VMaAA== X-Developer-Key: i=gregkh@linuxfoundation.org; a=openpgp; fpr=F4B60CC5BF78C2214A313DCB3147D40DDB2DFB29 Content-Transfer-Encoding: 8bit Description =========== In the Linux kernel, the following vulnerability has been resolved: class: fix use-after-free in class_register() The lock_class_key is still registered and can be found in lock_keys_hash hlist after subsys_private is freed in error handler path.A task who iterate over the lock_keys_hash later may cause use-after-free.So fix that up and unregister the lock_class_key before kfree(cp). On our platform, a driver fails to kset_register because of creating duplicate filename '/class/xxx'.With Kasan enabled, it prints a invalid-access bug report. KASAN bug report: BUG: KASAN: invalid-access in lockdep_register_key+0x19c/0x1bc Write of size 8 at addr 15ffff808b8c0368 by task modprobe/252 Pointer tag: [15], memory tag: [fe] CPU: 7 PID: 252 Comm: modprobe Tainted: G W 6.6.0-mainline-maybe-dirty #1 Call trace: dump_backtrace+0x1b0/0x1e4 show_stack+0x2c/0x40 dump_stack_lvl+0xac/0xe0 print_report+0x18c/0x4d8 kasan_report+0xe8/0x148 __hwasan_store8_noabort+0x88/0x98 lockdep_register_key+0x19c/0x1bc class_register+0x94/0x1ec init_module+0xbc/0xf48 [rfkill] do_one_initcall+0x17c/0x72c do_init_module+0x19c/0x3f8 ... Memory state around the buggy address: ffffff808b8c0100: 8a 8a 8a 8a 8a 8a 8a 8a 8a 8a 8a 8a 8a 8a 8a 8a ffffff808b8c0200: 8a 8a 8a 8a 8a 8a 8a 8a fe fe fe fe fe fe fe fe >ffffff808b8c0300: fe fe fe fe fe fe fe fe fe fe fe fe fe fe fe fe ^ ffffff808b8c0400: 03 03 03 03 03 03 03 03 03 03 03 03 03 03 03 03 As CONFIG_KASAN_GENERIC is not set, Kasan reports invalid-access not use-after-free here.In this case, modprobe is manipulating the corrupted lock_keys_hash hlish where lock_class_key is already freed before. It's worth noting that this only can happen if lockdep is enabled, which is not true for normal system. The Linux kernel CVE team has assigned CVE-2023-52468 to this issue. Affected and fixed versions =========================== Issue introduced in 6.4 with commit dcfbb67e48a2 and fixed in 6.6.14 with commit b57196a5ec5e Issue introduced in 6.4 with commit dcfbb67e48a2 and fixed in 6.7.2 with commit 0f1486dafca3 Issue introduced in 6.4 with commit dcfbb67e48a2 and fixed in 6.8-rc1 with commit 93ec4a3b7640 Please see https://www.kernel.org or a full list of currently supported kernel versions by the kernel community. Unaffected versions might change over time as fixes are backported to older supported kernel versions. The official CVE entry at https://cve.org/CVERecord/?id=CVE-2023-52468 will be updated if fixes are backported, please check that for the most up to date information about this issue. Affected files ============== The file(s) affected by this issue are: drivers/base/class.c Mitigation ========== The Linux kernel CVE team recommends that you update to the latest stable kernel version for this, and many other bugfixes. Individual changes are never tested alone, but rather are part of a larger kernel release. Cherry-picking individual commits is not recommended or supported by the Linux kernel community at all. If however, updating to the latest release is impossible, the individual changes to resolve this issue can be found at these commits: https://git.kernel.org/stable/c/b57196a5ec5e4c0ffecde8348b085b778c7dce04 https://git.kernel.org/stable/c/0f1486dafca3398c4c46b9f6e6452fa27e73b559 https://git.kernel.org/stable/c/93ec4a3b76404bce01bd5c9032bef5df6feb1d62