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>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20251209041218.1583600-3-atomlin@atomlin.com>
Date: Mon,  8 Dec 2025 23:12:18 -0500
From: Aaron Tomlin <atomlin@...mlin.com>
To: akpm@...ux-foundation.org,
	lance.yang@...ux.dev,
	mhiramat@...nel.org,
	gregkh@...uxfoundation.org
Cc: sean@...e.io,
	linux-kernel@...r.kernel.org
Subject: [PATCH 2/2] hung_task: Provide runtime reset interface for hung task detector

This patch introduces a new write-only sysfs file,
hung_task_detect_count_reset, directly under /sys/kernel/.
This file exposes an explicit control point for resetting the
/proc/sys/kernel/hung_task_detect_count counter.

Currently, this counter persists across the lifetime of the running system.
The new interface allows administrators to reset the count after investigating
an incident without requiring a full system reboot, making it easier to track
new hung task events after intervention.

The store handler enforces strict input validation, only accepting the value
"1" to execute the reset operation.

Signed-off-by: Aaron Tomlin <atomlin@...mlin.com>
---
 .../sysfs-kernel-hung_task_detect_count_reset |  8 +++++
 kernel/hung_task.c                            | 31 +++++++++++++++++++
 2 files changed, 39 insertions(+)
 create mode 100644 Documentation/ABI/testing/sysfs-kernel-hung_task_detect_count_reset

diff --git a/Documentation/ABI/testing/sysfs-kernel-hung_task_detect_count_reset b/Documentation/ABI/testing/sysfs-kernel-hung_task_detect_count_reset
new file mode 100644
index 000000000000..41dd30171c9c
--- /dev/null
+++ b/Documentation/ABI/testing/sysfs-kernel-hung_task_detect_count_reset
@@ -0,0 +1,8 @@
+What:		/sys/kernel/hung_task_detect_count_reset
+Date:		Dec 2025
+KernelVersion:	6.19
+Contact:	Linux kernel mailing list <linux-kernel@...r.kernel.org>
+Description:
+        A write-only interface to reset the persistent counter of tasks
+        detected as hung since boot. Write 1 to clear the counter and
+        restart diagnostic tracking without rebooting.
diff --git a/kernel/hung_task.c b/kernel/hung_task.c
index d5109a0994c5..035652dabf10 100644
--- a/kernel/hung_task.c
+++ b/kernel/hung_task.c
@@ -539,6 +539,37 @@ static int watchdog(void *dummy)
 	return 0;
 }
 
+#ifdef CONFIG_SYSFS
+static ssize_t hung_task_detect_count_reset_store(struct kobject *kobj,
+						  struct kobj_attribute *attr,
+						  const char *buf, size_t count)
+{
+	unsigned long val;
+	int ret;
+
+	ret = kstrtoul(buf, 0, &val);
+	if (ret)
+		return ret;
+	if (val != 1)
+		return -EINVAL;
+
+	WRITE_ONCE(sysctl_hung_task_detect_count, 0);
+
+	return count;
+}
+
+static struct kobj_attribute hung_task_detect_count_reset_attr = __ATTR_WO(hung_task_detect_count_reset);
+
+static __init int hung_task_detect_sysfs_init(void)
+{
+	sysfs_add_file_to_group(kernel_kobj,
+				&hung_task_detect_count_reset_attr.attr,
+				NULL);
+	return 0;
+}
+late_initcall(hung_task_detect_sysfs_init);
+#endif
+
 static int __init hung_task_init(void)
 {
 	atomic_notifier_chain_register(&panic_notifier_list, &panic_block);
-- 
2.51.0


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ