Re: [PATCH v1] clk: microchip: fix potential UAF in auxdev release callback
From: Stephen Boyd
Date: Thu Apr 13 2023 - 18:43:53 EST
Quoting Conor Dooley (2023-04-13 15:20:45)
> From: Conor Dooley <conor.dooley@xxxxxxxxxxxxx>
>
> Similar to commit 1c11289b34ab ("peci: cpu: Fix use-after-free in
> adev_release()"), the auxiliary device is not torn down in the correct
> order. If auxiliary_device_add() fails, the release callback will be
> called twice, resulting in a UAF. Due to timing, the auxdev code in this
> driver "took inspiration" from the aforementioned commit, and thus its
> bugs too!
>
> Moving auxiliary_device_uninit() to the unregister callback instead
> avoids the issue.
>
> CC: stable@xxxxxxxxxxxxxxx
> Fixes: b56bae2dd6fd ("clk: microchip: mpfs: add reset controller")
> Signed-off-by: Conor Dooley <conor.dooley@xxxxxxxxxxxxx>
> ---
Applied to clk-next