Message ID | 20200206062622.28235-1-oohall@gmail.com (mailing list archive) |
---|---|
State | Accepted |
Commit | d0a72efac89d1c35ac55197895201b7b94c5e6ef |
Headers | show |
Series | [1/2] cpufreq/powernv: Fix use-after-free | expand |
Context | Check | Description |
---|---|---|
snowpatch_ozlabs/apply_patch | success | Successfully applied on branch powerpc/merge (530a1cfd52af0aba1af4b1c9a7bc66a202a459b1) |
snowpatch_ozlabs/checkpatch | success | total: 0 errors, 0 warnings, 0 checks, 12 lines checked |
snowpatch_ozlabs/needsstable | warning | Please consider tagging this patch for stable! |
On Thu, Feb 06, 2020 at 05:26:21PM +1100, Oliver O'Halloran wrote: > The cpufreq driver has a use-after-free that we can hit if: > > a) There's an OCC message pending when the notifier is registered, and > b) The cpufreq driver fails to register with the core. > > When a) occurs the notifier schedules a workqueue item to handle the > message. The backing work_struct is located on chips[].throttle and when b) > happens we clean up by freeing the array. Once we get to the (now free) > queued item and the kernel crashes. > > Cc: Vaidyanathan Srinivasan <svaidy@linux.vnet.ibm.com> > Fixes: c5e29ea ("cpufreq: powernv: Fix bugs in powernv_cpufreq_{init/exit}") > Signed-off-by: Oliver O'Halloran <oohall@gmail.com> Thanks for this fix Oliver. Reviewed-by: Gautham R. Shenoy <ego@linux.vnet.ibm.com> > --- > drivers/cpufreq/powernv-cpufreq.c | 6 ++++++ > 1 file changed, 6 insertions(+) > > diff --git a/drivers/cpufreq/powernv-cpufreq.c b/drivers/cpufreq/powernv-cpufreq.c > index 56f4bc0..1806b1d 100644 > --- a/drivers/cpufreq/powernv-cpufreq.c > +++ b/drivers/cpufreq/powernv-cpufreq.c > @@ -1080,6 +1080,12 @@ static int init_chip_info(void) > > static inline void clean_chip_info(void) > { > + int i; > + > + /* flush any pending work items */ > + if (chips) > + for (i = 0; i < nr_chips; i++) > + cancel_work_sync(&chips[i].throttle); > kfree(chips); > } > > -- > 2.9.5 >
On 6/2/20 5:26 pm, Oliver O'Halloran wrote: > The cpufreq driver has a use-after-free that we can hit if: > > a) There's an OCC message pending when the notifier is registered, and > b) The cpufreq driver fails to register with the core. > > When a) occurs the notifier schedules a workqueue item to handle the > message. The backing work_struct is located on chips[].throttle and when b) > happens we clean up by freeing the array. Once we get to the (now free) > queued item and the kernel crashes. > > Cc: Vaidyanathan Srinivasan <svaidy@linux.vnet.ibm.com> > Fixes: c5e29ea ("cpufreq: powernv: Fix bugs in powernv_cpufreq_{init/exit}") > Signed-off-by: Oliver O'Halloran <oohall@gmail.com> This sounds like it needs to go to stable.
Andrew Donnellan <ajd@linux.ibm.com> writes: > On 6/2/20 5:26 pm, Oliver O'Halloran wrote: >> The cpufreq driver has a use-after-free that we can hit if: >> >> a) There's an OCC message pending when the notifier is registered, and >> b) The cpufreq driver fails to register with the core. >> >> When a) occurs the notifier schedules a workqueue item to handle the >> message. The backing work_struct is located on chips[].throttle and when b) >> happens we clean up by freeing the array. Once we get to the (now free) >> queued item and the kernel crashes. >> >> Cc: Vaidyanathan Srinivasan <svaidy@linux.vnet.ibm.com> >> Fixes: c5e29ea ("cpufreq: powernv: Fix bugs in powernv_cpufreq_{init/exit}") >> Signed-off-by: Oliver O'Halloran <oohall@gmail.com> > > This sounds like it needs to go to stable. I tagged it for stable when applying. cheers
On Thu, 2020-02-06 at 06:26:21 UTC, Oliver O'Halloran wrote: > The cpufreq driver has a use-after-free that we can hit if: > > a) There's an OCC message pending when the notifier is registered, and > b) The cpufreq driver fails to register with the core. > > When a) occurs the notifier schedules a workqueue item to handle the > message. The backing work_struct is located on chips[].throttle and when b) > happens we clean up by freeing the array. Once we get to the (now free) > queued item and the kernel crashes. > > Cc: Vaidyanathan Srinivasan <svaidy@linux.vnet.ibm.com> > Fixes: c5e29ea ("cpufreq: powernv: Fix bugs in powernv_cpufreq_{init/exit}") > Signed-off-by: Oliver O'Halloran <oohall@gmail.com> Series applied to powerpc next, thanks. https://git.kernel.org/powerpc/c/d0a72efac89d1c35ac55197895201b7b94c5e6ef cheers
diff --git a/drivers/cpufreq/powernv-cpufreq.c b/drivers/cpufreq/powernv-cpufreq.c index 56f4bc0..1806b1d 100644 --- a/drivers/cpufreq/powernv-cpufreq.c +++ b/drivers/cpufreq/powernv-cpufreq.c @@ -1080,6 +1080,12 @@ static int init_chip_info(void) static inline void clean_chip_info(void) { + int i; + + /* flush any pending work items */ + if (chips) + for (i = 0; i < nr_chips; i++) + cancel_work_sync(&chips[i].throttle); kfree(chips); }
The cpufreq driver has a use-after-free that we can hit if: a) There's an OCC message pending when the notifier is registered, and b) The cpufreq driver fails to register with the core. When a) occurs the notifier schedules a workqueue item to handle the message. The backing work_struct is located on chips[].throttle and when b) happens we clean up by freeing the array. Once we get to the (now free) queued item and the kernel crashes. Cc: Vaidyanathan Srinivasan <svaidy@linux.vnet.ibm.com> Fixes: c5e29ea ("cpufreq: powernv: Fix bugs in powernv_cpufreq_{init/exit}") Signed-off-by: Oliver O'Halloran <oohall@gmail.com> --- drivers/cpufreq/powernv-cpufreq.c | 6 ++++++ 1 file changed, 6 insertions(+)