Commit 203824be authored by Dominik Brodowski's avatar Dominik Brodowski Committed by Greg Kroah-Hartman

pcmcia: avoid buffer overflow in pcmcia_setup_isa_irq

commit 127c03cd upstream.

NR_IRQS may be as low as 16, causing a (harmless?) buffer overflow in
pcmcia_setup_isa_irq():

static u8 pcmcia_used_irq[NR_IRQS];

...

		if ((try < 32) && pcmcia_used_irq[irq])
			continue;

This is read-only, so if this address would be non-zero, it would just
mean we would not attempt an IRQ >= NR_IRQS -- which would fail anyway!
And as request_irq() fails for an irq >= NR_IRQS, the setting code path:

			pcmcia_used_irq[irq]++;

is never reached as well.
Reported-by: default avatarChristoph Fritz <chf.fritz@googlemail.com>
Signed-off-by: default avatarDominik Brodowski <linux@dominikbrodowski.net>
Signed-off-by: default avatarChristoph Fritz <chf.fritz@googlemail.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent 4fbb306c
...@@ -651,7 +651,7 @@ EXPORT_SYMBOL(__pcmcia_request_exclusive_irq); ...@@ -651,7 +651,7 @@ EXPORT_SYMBOL(__pcmcia_request_exclusive_irq);
#ifdef CONFIG_PCMCIA_PROBE #ifdef CONFIG_PCMCIA_PROBE
/* mask of IRQs already reserved by other cards, we should avoid using them */ /* mask of IRQs already reserved by other cards, we should avoid using them */
static u8 pcmcia_used_irq[NR_IRQS]; static u8 pcmcia_used_irq[32];
static irqreturn_t test_action(int cpl, void *dev_id) static irqreturn_t test_action(int cpl, void *dev_id)
{ {
...@@ -674,6 +674,9 @@ static int pcmcia_setup_isa_irq(struct pcmcia_device *p_dev, int type) ...@@ -674,6 +674,9 @@ static int pcmcia_setup_isa_irq(struct pcmcia_device *p_dev, int type)
for (try = 0; try < 64; try++) { for (try = 0; try < 64; try++) {
irq = try % 32; irq = try % 32;
if (irq > NR_IRQS)
continue;
/* marked as available by driver, not blocked by userspace? */ /* marked as available by driver, not blocked by userspace? */
if (!((mask >> irq) & 1)) if (!((mask >> irq) & 1))
continue; continue;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment