浏览代码

[PATCH] x86: do_IRQ(): check irq number

We recently changed x86 to handle more than 256 IRQs.  Add a check in do_IRQ()
just to make sure that nothing went wrong with that implementation.

[chrisw@sous-sol.org: do x86_64 too]
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Rusty Russell <rusty@rustcorp.com.au>
Cc: Andi Kleen <ak@muc.de>
Cc: Chris Wright <chrisw@sous-sol.org>
Cc: "Protasevich, Natalie" <Natalie.Protasevich@UNISYS.com>
Cc: <Christian.Limpach@cl.cam.ac.uk>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Andrew Morton 19 年之前
父节点
当前提交
a052b68b1e
共有 2 个文件被更改,包括 12 次插入0 次删除
  1. 6 0
      arch/i386/kernel/irq.c
  2. 6 0
      arch/x86_64/kernel/irq.c

+ 6 - 0
arch/i386/kernel/irq.c

@@ -60,6 +60,12 @@ fastcall unsigned int do_IRQ(struct pt_regs *regs)
 	u32 *isp;
 	u32 *isp;
 #endif
 #endif
 
 
+	if (unlikely((unsigned)irq >= NR_IRQS)) {
+		printk(KERN_EMERG "%s: cannot handle IRQ %d\n",
+					__FUNCTION__, irq);
+		BUG();
+	}
+
 	irq_enter();
 	irq_enter();
 #ifdef CONFIG_DEBUG_STACKOVERFLOW
 #ifdef CONFIG_DEBUG_STACKOVERFLOW
 	/* Debugging check for stack overflow: is there less than 1KB free? */
 	/* Debugging check for stack overflow: is there less than 1KB free? */

+ 6 - 0
arch/x86_64/kernel/irq.c

@@ -118,6 +118,12 @@ asmlinkage unsigned int do_IRQ(struct pt_regs *regs)
 	/* high bit used in ret_from_ code  */
 	/* high bit used in ret_from_ code  */
 	unsigned irq = ~regs->orig_rax;
 	unsigned irq = ~regs->orig_rax;
 
 
+	if (unlikely(irq >= NR_IRQS)) {
+		printk(KERN_EMERG "%s: cannot handle IRQ %d\n",
+					__FUNCTION__, irq);
+		BUG();
+	}
+
 	exit_idle();
 	exit_idle();
 	irq_enter();
 	irq_enter();
 #ifdef CONFIG_DEBUG_STACKOVERFLOW
 #ifdef CONFIG_DEBUG_STACKOVERFLOW