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 EDB457461 for ; Mon, 18 Dec 2023 06:52:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="Kcf71oHu" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 24BE5C433C8; Mon, 18 Dec 2023 06:52:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1702882341; bh=llh1Y16tgU5GVwSkmJ1KisMeuRqZAgd9EWfxj3tYCnE=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Kcf71oHuLCTBdRo+/clmZ8oXoWXFp5SAfo7y+b/I+f+9BE36gxpz9SlxMeq5jQyzB L5RwYSj26n1ZJCyTfPm8buY844AxadGtjGVJUT5f1kfhguUFQNkQV2AqLBEr5CmnH8 tbt0SLWyH3zP+C30Ehy1NLlXMezCXbH0mWx0UZpI= Date: Mon, 18 Dec 2023 07:52:18 +0100 From: Greg Kroah-Hartman To: Chunyan Zhang Cc: "Rafael J . Wysocki" , LKML , Jing Xia , Jing Xia , Xuewen Yan , Ke Wang , Chunyan Zhang Subject: Re: [PATCH] class: fix use-after-free in class_register() Message-ID: <2023121830-proxy-washed-ae4d@gregkh> References: <20231218024403.1076134-1-chunyan.zhang@unisoc.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231218024403.1076134-1-chunyan.zhang@unisoc.com> On Mon, Dec 18, 2023 at 10:44:03AM +0800, Chunyan Zhang wrote: > From: Jing Xia > > 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). What task iterates over all hashes? And can you put ' ' after your '.'? And how was this found? > > Signed-off-by: Jing Xia > Signed-off-by: Xuewen Yan What commit id does this fix? Also note in the changelog that this only can happen if lockdep is enabled, which is not true for normal systems. thanks, greg k-h