Re: [PATCH 000/190] Revertion of all of the umn.edu commits

Jiri Kosina
2021-04-21T15:47:23Z

On Wed, 21 Apr 2021, Qiushi Wu wrote:

> The function description of "kobject_init_and_add()" mentioned that "If
> this function returns an error, kobject_put() must be called to properly
> clean up the memory associated with the object." (see
> https://elixir.bootlin.com/linux/v5.12-rc8/source/lib/kobject.c#L464) So
> we use this patch to fix the issue, and I may miss some context here,
> but I don't see why this cause some issue like NULL dereferences.
>
> The identification methodology for this bug and other similar bugs that
> are error-handling related, is shown in "Understanding and Detecting
> Disordered Error Handling with Precise Function Pairing."
> (https://www.usenix.org/conference/usenixsecurity21/presentation/wu-qiushi)

You are calling kobject_put() if kobject_init_and_add() fails. That will
in turn invoke pci_slot_release() which will try to delete slot->list, but
that hasn't been initialized yet.

Fixed in 4684709bf8, present in two major Linux kernel releases.

--
Jiri Kosina
SUSE Labs