[PATCH] crash in pcmcia_access_configuration_register

From: Pavel Roskin (proski@gnu.org)
Date: Mon Mar 03 2003 - 23:23:08 EST


Hello!

As promised, here's the patch to fix an oops in the kernel PCMCIA driver.
The patch should be applied both to 2.4 and 2.5 series.

How to reproduce the bug:

1) Compile and install HostAP (http://hostap.epitest.fi/) - any recent
version (CVS version is OK).

2) Insert a card supported by HostAP.

3) Remove (physically) the card. The kernel oopses.

Explanation:

While doing a reset, HostAP used AccessConfigurationRegister request to
preserve the value of the configuration register. The reset is triggered
by the removal of the card.

I do believe that HostAP can be improved to avoid reset if the socket
configuration has been released. Nevertheless, oops is not a reputable
behavior when the driver merely requests a configuration register.

The pcmcia-cs driver already has a slightly different protection, but the
following patch is simpler and addresses the problem right before it
happens.

====================================
--- drivers/pcmcia/cs.c
+++ drivers/pcmcia/cs.c
@@ -882,6 +882,10 @@ int pcmcia_access_configuration_register
         c = &s->config[reg->Function];
     } else
         c = CONFIG(handle);
+
+ if (c == NULL)
+ return CS_NO_CARD;
+
     if (!(c->state & CONFIG_LOCKED))
         return CS_CONFIGURATION_LOCKED;

====================================

-- 
Regards,
Pavel Roskin
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Fri Mar 07 2003 - 22:00:23 EST