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-next>] [day] [month] [year] [list]
Message-ID: <44a7007d-9624-8ac7-e0ab-fab8bdd39848@oracle.com>
Date:   Thu, 27 Feb 2020 21:42:02 -0800
From:   Joe Jin <joe.jin@...cle.com>
To:     Thomas Gleixner <tglx@...utronix.de>,
        Marc Zyngier <maz@...nel.org>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Cc:     Joe Jin <joe.jin@...cle.com>
Subject: [PATCH] genirq/debugfs: add new config option for trigger interrupt
 from userspace

commit 536e2e34bd00 ("genirq/debugfs: Triggering of interrupts from
userspace") is allowed developer inject interrupts via irq debugfs, which
is very useful during development phase, but on a production system, this
is very dangerous, add new config option, developers can enable it as
needed instead of enabling it by default when irq debugfs is enabled.

Signed-off-by: Joe Jin <joe.jin@...cle.com>
Cc: Thomas Gleixner <tglx@...utronix.de>
Cc: Marc Zyngier <maz@...nel.org>
---
 kernel/irq/Kconfig   | 15 +++++++++++++++
 kernel/irq/debugfs.c |  9 +++++++++
 2 files changed, 24 insertions(+)

diff --git a/kernel/irq/Kconfig b/kernel/irq/Kconfig
index f92d9a687372..00521e896e6c 100644
--- a/kernel/irq/Kconfig
+++ b/kernel/irq/Kconfig
@@ -135,6 +135,21 @@ config GENERIC_IRQ_DEBUGFS
 
 	  If you don't know what to do here, say N.
 
+config GENERIC_IRQ_DEBUGFS_INJECT_INT
+	bool "Allow trigger interrupts from userspace"
+	depends on DEBUG_FS && GENERIC_IRQ_DEBUGFS
+	default n
+	---help---
+
+	  Allow developers retrigger a (edge-only) interrupt from userspace.
+	  To use this feature:
+
+	  echo -n trigger > /sys/kernel/debug/irq/irqs/IRQNUM
+
+	  WARNING: This is DANGEROUS, and strictly a debug feature.
+
+	  If you don't know what to do here, say N.
+
 endmenu
 
 config GENERIC_IRQ_MULTI_HANDLER
diff --git a/kernel/irq/debugfs.c b/kernel/irq/debugfs.c
index a949bd39e343..56db29bc1acf 100644
--- a/kernel/irq/debugfs.c
+++ b/kernel/irq/debugfs.c
@@ -178,6 +178,7 @@ static int irq_debug_open(struct inode *inode, struct file *file)
 	return single_open(file, irq_debug_show, inode->i_private);
 }
 
+#ifdef CONFIG_GENERIC_IRQ_DEBUGFS_INJECT_INT
 static ssize_t irq_debug_write(struct file *file, const char __user *user_buf,
 			       size_t count, loff_t *ppos)
 {
@@ -223,10 +224,13 @@ static ssize_t irq_debug_write(struct file *file, const char __user *user_buf,
 
 	return count;
 }
+#endif
 
 static const struct file_operations dfs_irq_ops = {
 	.open		= irq_debug_open,
+#ifdef CONFIG_GENERIC_IRQ_DEBUGFS_INJECT_INT
 	.write		= irq_debug_write,
+#endif
 	.read		= seq_read,
 	.llseek		= seq_lseek,
 	.release	= single_release,
@@ -249,8 +253,13 @@ void irq_add_debugfs_entry(unsigned int irq, struct irq_desc *desc)
 		return;
 
 	sprintf(name, "%d", irq);
+#ifdef CONFIG_GENERIC_IRQ_DEBUGFS_INJECT_INT
 	desc->debugfs_file = debugfs_create_file(name, 0644, irq_dir, desc,
 						 &dfs_irq_ops);
+#else
+	desc->debugfs_file = debugfs_create_file(name, 0444, irq_dir, desc,
+						 &dfs_irq_ops);
+#endif
 }
 
 static int __init irq_debugfs_init(void)
-- 
2.21.1 (Apple Git-122.3)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ