]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
clk: microchip: fix potential UAF in auxdev release callback
authorConor Dooley <conor.dooley@microchip.com>
Thu, 13 Apr 2023 22:20:45 +0000 (23:20 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 11 May 2023 14:11:34 +0000 (23:11 +0900)
commitd7d6dacf39ed102d7667721ca1700022c9c8b11a
tree723244bba58ce7455640c63a8a156a17cd3aa317
parentaa48073c2f993e1b0c0bc66b03ae105cac0130bc
clk: microchip: fix potential UAF in auxdev release callback

commit 7455b7007b9e93bcc2bc9c1c6c73a228e3152069 upstream.

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@vger.kernel.org
Fixes: b56bae2dd6fd ("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>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/clk/microchip/clk-mpfs.c