Re: [PATCH] kobject: Don't trigger kobject_uevent(KOBJ_REMOVE) twice.
From: Tetsuo Handa
Date: Thu Feb 21 2019 - 05:40:27 EST
On 2019/02/21 4:52, Dmitry Torokhov wrote:
> On Wed, Feb 20, 2019 at 7:07 AM Greg Kroah-Hartman
> <gregkh@xxxxxxxxxxxxxxxxxxx> wrote:
>> But I would argue that this is not ok, as the remove uevent did NOT get
>> sent, and you are saying it did.
> "It is the thought that counts" here. The code was added to catch
> cases where nobody even attempted to send "remove" uevents. It does
> not guarantee that an event will ultimately be sent (we are at the
> point of no return as far as the rest of the kernel is concerned,
> there are no repeats or do-overs).
>> What memory is being used-after-free here when we fail to properly send
>> a uevent? Shouldn't we fix up that problem correctly?
It is explained at 20190219185558.GA210481@dtor-ws">https://lkml.kernel.org/r/20190219185558.GA210481@dtor-ws .
> This is the correct fix (in spirit, we may argue about whether it is
> valid to call the flag "state_add_uevent_sent" now or we should or
> collapse both it and "state_add_uevent_sent" into
> "need_send_remove_uevent"). Other subsystems are in their own right to
> not expect to get uvent callbacks past the point of calling
> device_del() as they are tearing down parts of the device environment
> (even though the device structure may stay in memory for a while).
Which subsystems benefit from commit 0f4dafc0563c6c49 ("Kobject: auto-cleanup
on final unref") ? If there is no such subsystem, it will be better to remove
state_add_uevent_sent and state_remove_uevent_sent logic.