lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Message-Id: <20250912161338.1079085-1-kaushlendra.kumar@intel.com>
Date: Fri, 12 Sep 2025 21:43:38 +0530
From: Kaushlendra Kumar <kaushlendra.kumar@...el.com>
To: mingo@...hat.com,
	peterz@...radead.org,
	juri.lelli@...hat.com,
	vincent.guittot@...aro.org,
	dietmar.eggemann@....com,
	rostedt@...dmis.org
Cc: linux-kernel@...r.kernel.org,
	Kaushlendra Kumar <kaushlendra.kumar@...el.com>
Subject: [PATCH] sched/deadline: Set cp->elements to NULL after kfree() in cpudl_init()

Set cp->elements to NULL after kfree() in the error path of cpudl_init()
to prevent potential use-after-free issues. This ensures that the pointer
is properly invalidated when memory allocation fails for cp->free_cpus,
making the code more robust against accidental access to freed memory.

Setting pointers to NULL after freeing helps debugging tools like kdgb,
drgn, and other kernel debuggers by providing clear indication that the
memory has been freed and the pointer is no longer valid.

Signed-off-by: Kaushlendra Kumar <kaushlendra.kumar@...el.com>
---
 kernel/sched/cpudeadline.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/kernel/sched/cpudeadline.c b/kernel/sched/cpudeadline.c
index cdd740b3f774..0f7127b3a05c 100644
--- a/kernel/sched/cpudeadline.c
+++ b/kernel/sched/cpudeadline.c
@@ -276,6 +276,7 @@ int cpudl_init(struct cpudl *cp)
 
 	if (!zalloc_cpumask_var(&cp->free_cpus, GFP_KERNEL)) {
 		kfree(cp->elements);
+		cp->elements = NULL;
 		return -ENOMEM;
 	}
 
-- 
2.34.1


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ