From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796387576; b=OWydkMjt58V+6w5CddIxwFf5dloWHw0c365CNmiUVF41hq5RTGPNlXjmoABitAvQkug6 baa9JzFvM1fbH7ZPrz3jsQkyJJONPAZH3Zu0NC8BssLYBDO7Z5BcSDA/ZgpuPGdsktdfY rkvLvD8satEG+c3UoHMWpuh73AOsEPv/SkXRdhjeqNj1J/Q2gIkuSW+O4a4Dbu6VOgKDn S9gmtOpykckZcYfEwRAXujqC7ZkZQRr2HtEL7Q9xW9AxYZqyxysrNdfxLNWhfXvD6UpvS KbqVFXva76d5zhzMhNmNdp3IBCE3nvPJ0iVpf9rbKXI2gwYSv7xur3jWH0qA96JsVJg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796387576; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=FKj/J+6UsIvHjySBzIT+1NZIV3P4iR85Z3gN6RPJwms=; b=Kldmhtv5R1MOhGp0hazO65Wfxeg2Ovmm/ReerB9GLfhtaDEz8KnUoz8pNswnn9qwQpRO Zp1wmIXYXMgoXAFF+Ga1L8hepNnIUfm9Hi5m+4UvwxRYsa5swe1Jb2aZGDbldY7caMt7m eVUXXy6MhWMdawcwbBfGmhpApJmB/hO4Z+ywaisvTCIlqqO+nC7gGiivLOwM8LxHeFLPi Heg95X1tHqx3jxGpI6BtuBYOqTH3uXSllDRVnqtmYEILPX1T7pauyhpKkwc1H4op5OljI 6TirX93qVYyMqUHBQVGWCZwFT53j4TFWgx0ABH1C5MnRRVt9bNrO7f0gAS6LdADi5ZQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=YSE8+39Q; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 09447606A322; Fri, 4 Dec 2026 12:32:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=YSE8+39Q Received: by smtp.kernel.org (Postfix) with ESMTPSA id 75E8A1F000CE; Fri, 4 Dec 2026 12:32:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796387575; bh=FKj/J+6UsIvHjySBzIT+1NZIV3P4iR85Z3gN6RPJwms=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=YSE8+39QXLyj/4WykZZMe/HrUlOHEtX1EUUhz7YeTI9H2FwFcbwS8eYEowjFbsBMA zwr6Q8zeMx+xz2EChjUvD2tKPvSyW6hBKRx8SFj06KJ0hvfl3Kw1ioDrmUiMM5jOI/ zqb+O2ia6G+7ceuL1MBd0gHlzvcCVGX586zHUgyI= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Yibo Tan , Joel Granados , Sasha Levin Subject: [PATCH 6.1 0302/1059] sysctl: unregister tables before freeing bitmap Date: Fri, 4 Dec 2026 18:57:13 +0900 Message-ID: <20261204100652.093668222@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100643.980430235@linuxfoundation.org> References: <20261204100643.980430235@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: stable@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.1-stable review patch. If anyone has any objections, please let me know. ------------------ From: Yibo Tan [ Upstream commit 238dfe02fb0a9f72d7fd275d74ce80f13923ef31 ] The table registered for bitmap_0001 retains a pointer to test_data.bitmap_0001. unregister_sysctl_table() prevents new handlers from starting and waits for active handlers to finish. test_sysctl_exit() currently frees the bitmap before unregistering the table. A concurrent read during module removal can therefore enter proc_do_large_bitmap() while the bitmap is freed. KASAN reports a slab-use-after-free in _find_next_bit(). Unregister all tables before freeing the bitmap so the unregister rundown provides the required lifetime boundary. The unmodified module reproduced the use-after-free in three KASAN runs. With this change, three runs each completed 100 load, read and unload race rounds without a kernel diagnostic. Fixes: 2ea622b887e7 ("tools/testing/selftests/sysctl/sysctl.sh: add proc_do_large_bitmap() test case") Assisted-by: LLM Signed-off-by: Yibo Tan Signed-off-by: Joel Granados Signed-off-by: Sasha Levin --- lib/test_sysctl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/test_sysctl.c b/lib/test_sysctl.c index 9a564971f539a..fea5748d116a7 100644 --- a/lib/test_sysctl.c +++ b/lib/test_sysctl.c @@ -178,9 +178,9 @@ module_init(test_sysctl_init); static void __exit test_sysctl_exit(void) { - kfree(test_data.bitmap_0001); if (test_sysctl_header) unregister_sysctl_table(test_sysctl_header); + kfree(test_data.bitmap_0001); } module_exit(test_sysctl_exit); -- 2.53.0