]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
genirq/proc: Size interrupt directory names for 10-digit interrupt numbers
authorPengpeng Hou <pengpeng@iscas.ac.cn>
Fri, 3 Apr 2026 08:55:56 +0000 (16:55 +0800)
committerThomas Gleixner <tglx@kernel.org>
Mon, 11 May 2026 14:32:30 +0000 (16:32 +0200)
/proc/irq/<n>/ directory names are built in `char name[10]` buffers
with `sprintf(name, "%u", irq)`.

Ten-digit IRQ numbers already need 11 bytes including the trailing NUL, and
current sparse-IRQ configurations allow interrupt numbers in that range.

Size the temporary name buffer for the current decimal form and switch
to bounded formatting when creating or removing the proc entry.

Signed-off-by: Pengpeng Hou <pengpeng@iscas.ac.cn>
Signed-off-by: Thomas Gleixner <tglx@kernel.org>
Link: https://patch.msgid.link/20260404101001.1-genirq-proc-pengpeng@iscas.ac.cn
kernel/irq/proc.c

index b0999a4f1f6883c046d4d93322be3d8721a87d59..dfa0b07236429f97cdebca0fdc987a7e0c8f9f03 100644 (file)
@@ -10,6 +10,7 @@
 #include <linux/proc_fs.h>
 #include <linux/seq_file.h>
 #include <linux/interrupt.h>
+#include <linux/kernel.h>
 #include <linux/kernel_stat.h>
 #include <linux/mutex.h>
 #include <linux/string.h>
@@ -326,7 +327,7 @@ void register_handler_proc(unsigned int irq, struct irqaction *action)
 
 #undef MAX_NAMELEN
 
-#define MAX_NAMELEN 10
+#define MAX_NAMELEN 11
 
 void register_irq_proc(unsigned int irq, struct irq_desc *desc)
 {
@@ -348,7 +349,7 @@ void register_irq_proc(unsigned int irq, struct irq_desc *desc)
                return;
 
        /* create /proc/irq/1234 */
-       sprintf(name, "%u", irq);
+       snprintf(name, MAX_NAMELEN, "%u", irq);
        desc->dir = proc_mkdir(name, root_irq_dir);
        if (!desc->dir)
                return;
@@ -401,7 +402,7 @@ void unregister_irq_proc(unsigned int irq, struct irq_desc *desc)
 #endif
        remove_proc_entry("spurious", desc->dir);
 
-       sprintf(name, "%u", irq);
+       snprintf(name, MAX_NAMELEN, "%u", irq);
        remove_proc_entry(name, root_irq_dir);
 }