[tip:irq/urgent] genirq: Prevent access beyond irq resend bitmap as well

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Commit-ID:  74e810ccdb88cd0a26c27eb9a668f4c2e8c88fc8
Gitweb:     http://git.kernel.org/tip/74e810ccdb88cd0a26c27eb9a668f4c2e8c88fc8
Author:     Thomas Gleixner <tglx@xxxxxxxxxxxxx>
AuthorDate: Wed, 16 Feb 2011 15:43:15 +0100
Committer:  Thomas Gleixner <tglx@xxxxxxxxxxxxx>
CommitDate: Wed, 16 Feb 2011 17:08:25 +0100

genirq: Prevent access beyond irq resend bitmap as well

commit d1a084e2 (genirq: Prevent access beyond allocated_irqs bitmap)
fixed the possible access beyond the compiled in bitmap size only for
the allocation bitmap, but the irq resend bitmap has the same issue.

Allocate it dynamically as well.

Signed-off-by: Thomas Gleixner <tglx@xxxxxxxxxxxxx>
Cc: Lars-Peter Clausen <lars@xxxxxxxxxx>
Cc: stable@xxxxxxxxxx # .37
Cc: Haojian Zhuang <haojian.zhuang@xxxxxxxxxxx>
Cc: Eric Miao <eric.y.miao@xxxxxxxxx>
Cc: Peter Zijlstra <peterz@xxxxxxxxxxxxx>

---
 kernel/irq/internals.h |    5 +++++
 kernel/irq/irqdesc.c   |    5 ++++-
 kernel/irq/resend.c    |    9 +++++++++
 3 files changed, 18 insertions(+), 1 deletions(-)

diff --git a/kernel/irq/internals.h b/kernel/irq/internals.h
index 4571ae7..2f5f7c4 100644
--- a/kernel/irq/internals.h
+++ b/kernel/irq/internals.h
@@ -22,6 +22,11 @@ extern void init_kstat_irqs(struct irq_desc *desc, int node, int nr);
 
 /* Resending of interrupts :*/
 void check_irq_resend(struct irq_desc *desc, unsigned int irq);
+#ifdef CONFIG_HARDIRQS_SW_RESEND
+void irq_resend_alloc_bitmap(size_t mapsize);
+#else
+static inline void irq_resend_alloc_bitmap(size_t mapsize) { }
+#endif
 
 #ifdef CONFIG_PROC_FS
 extern void register_irq_proc(unsigned int irq, struct irq_desc *desc);
diff --git a/kernel/irq/irqdesc.c b/kernel/irq/irqdesc.c
index c595827..4ed4885 100644
--- a/kernel/irq/irqdesc.c
+++ b/kernel/irq/irqdesc.c
@@ -212,6 +212,7 @@ int __init early_irq_init(void)
 {
 	int i, initcnt, node = first_online_node;
 	struct irq_desc *desc;
+	size_t mapsize;
 
 	init_irq_default_affinity();
 
@@ -221,8 +222,10 @@ int __init early_irq_init(void)
 
 	BUG_ON(nr_irqs > NR_IRQS_LIMIT || initcnt > nr_irqs);
 
-	allocated_irqs = kzalloc(BITS_TO_LONGS(nr_irqs) * sizeof(long), GFP_KERNEL);
+	mapsize = BITS_TO_LONGS(nr_irqs) * sizeof(long);
+	allocated_irqs = kzalloc(mapsize, GFP_KERNEL);
 	BUG_ON(!allocated_irqs);
+	irq_resend_alloc_bitmap(mapsize);
 
 	for (i = 0; i < initcnt; i++) {
 		desc = alloc_desc(i, node);
diff --git a/kernel/irq/resend.c b/kernel/irq/resend.c
index 891115a..f8f983d 100644
--- a/kernel/irq/resend.c
+++ b/kernel/irq/resend.c
@@ -23,7 +23,16 @@
 #ifdef CONFIG_HARDIRQS_SW_RESEND
 
 /* Bitmap to handle software resend of interrupts: */
+#ifdef CONFIG_SPARSE_IRQ
+static unsigned long *irq_resend;
+void __init irq_resend_alloc_bitmap(size_t mapsize)
+{
+	irq_resend = kzalloc(mapsize, GFP_KERNEL);
+	BUG_ON(!irq_resend);
+}
+#else
 static DECLARE_BITMAP(irqs_resend, NR_IRQS);
+#endif
 
 /*
  * Run software resends of IRQ's
--
To unsubscribe from this list: send the line "unsubscribe linux-tip-commits" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Stable Commits]     [Linux Stable Kernel]     [Linux Kernel]     [Linux USB Devel]     [Linux Video &Media]     [Linux Audio Users]     [Yosemite News]     [Linux SCSI]

  Powered by Linux