Re: Race condition between driver_probe_device and device_shutdownâ

From: Eric W. Biederman
Date: Tue May 22 2012 - 15:16:24 EST


Alan Stern <stern@xxxxxxxxxxxxxxxxxxx> writes:

> On Tue, 22 May 2012, Ming Lei wrote:
>
>> On Tue, May 22, 2012 at 2:29 AM, Alan Stern <stern@xxxxxxxxxxxxxxxxxxx> wrote:
>> > On Mon, 21 May 2012, Ming Lei wrote:
>> >> Another candidate fix is to register a reboot notifier in driver core to prevent
>> >> driver from being bound or unbound from start of reboot/shutdown, but looks
>> >> not easy as the way of holding device locks.

You might also be able to look at system_state and simply not do any
hotplug work if the state is neither SYSTEM_BOOTING or SYSTEM_RUNNING.

>> > I'd guess it was done this way so that the shutdown task wouldn't have
>> > to wait for a buggy driver that didn't want to release the device lock
>> > (or that crashed while holding the lock).
>>
>> Maybe, so I understand you agree on adding the device lock as did
>> in the patch, don't I?
>
> I don't know. It depends on the intention behind the shutdown
> callback. Maybe each driver is supposed to be responsible for doing
> its own locking.
>
> Do you think that a buggy driver should be able to prevent the system
> from shutting down?

The original intent of the shutdown callback was to just the hardware
part of the device shutdown and not do muck with kernel data structures
because just the device portion should be more reliable and was all
that is needed.

Given the current minimal usage of the device shutdown callback I'm not
convinced the original reasoning made sense but shrug. So we might
want to reorg things and merge remove and shutdown. I missed the start
of this thread so I don't know how ambitious everyone is.

Eric

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