Skip to content

Commit

Permalink
clk: microchip: fix potential UAF in auxdev release callback
Browse files Browse the repository at this point in the history
Similar to commit 1c11289 ("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@vger.kernel.org
Fixes: b56bae2 ("clk: microchip: mpfs: add reset controller")
Signed-off-by: Conor Dooley <conor.dooley@microchip.com>
Link: https://lore.kernel.org/r/20230413-critter-synopsis-dac070a86cb4@spud
Signed-off-by: Stephen Boyd <sboyd@kernel.org>
  • Loading branch information
Conor Dooley authored and Stephen Boyd committed Apr 13, 2023
1 parent fb8b9d2 commit 7455b70
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions drivers/clk/microchip/clk-mpfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -374,14 +374,13 @@ static void mpfs_reset_unregister_adev(void *_adev)
struct auxiliary_device *adev = _adev;

auxiliary_device_delete(adev);
auxiliary_device_uninit(adev);
}

static void mpfs_reset_adev_release(struct device *dev)
{
struct auxiliary_device *adev = to_auxiliary_dev(dev);

auxiliary_device_uninit(adev);

kfree(adev);
}

Expand Down

0 comments on commit 7455b70

Please sign in to comment.