James Morse
ea4bbe1a04
cpufreq: schedutil: Destroy mutex before kobject_put() frees the memory
[ Upstream commit cdef119660 ]
Since commit e5c6b312ce ("cpufreq: schedutil: Use kobject release()
method to free sugov_tunables") kobject_put() has kfree()d the
attr_set before gov_attr_set_put() returns.
kobject_put() isn't the last user of attr_set in gov_attr_set_put(),
the subsequent mutex_destroy() triggers a use-after-free:
| BUG: KASAN: use-after-free in mutex_is_locked+0x20/0x60
| Read of size 8 at addr ffff000800ca4250 by task cpuhp/2/20
|
| CPU: 2 PID: 20 Comm: cpuhp/2 Not tainted 5.15.0-rc1 #12369
| Hardware name: ARM LTD ARM Juno Development Platform/ARM Juno Development
| Platform, BIOS EDK II Jul 30 2018
| Call trace:
| dump_backtrace+0x0/0x380
| show_stack+0x1c/0x30
| dump_stack_lvl+0x8c/0xb8
| print_address_description.constprop.0+0x74/0x2b8
| kasan_report+0x1f4/0x210
| kasan_check_range+0xfc/0x1a4
| __kasan_check_read+0x38/0x60
| mutex_is_locked+0x20/0x60
| mutex_destroy+0x80/0x100
| gov_attr_set_put+0xfc/0x150
| sugov_exit+0x78/0x190
| cpufreq_offline.isra.0+0x2c0/0x660
| cpuhp_cpufreq_offline+0x14/0x24
| cpuhp_invoke_callback+0x430/0x6d0
| cpuhp_thread_fun+0x1b0/0x624
| smpboot_thread_fn+0x5e0/0xa6c
| kthread+0x3a0/0x450
| ret_from_fork+0x10/0x20
Swap the order of the calls.
Fixes: e5c6b312ce ("cpufreq: schedutil: Use kobject release() method to free sugov_tunables")
Cc: 4.7+ <stable@vger.kernel.org> # 4.7+
Signed-off-by: James Morse <james.morse@arm.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2023-05-16 11:53:41 +09:00
..
2023-05-16 09:45:13 +09:00
2016-07-07 00:14:27 +02:00
2016-05-05 01:40:04 +02:00
2017-02-17 17:18:46 +08:00
2016-05-05 01:40:04 +02:00
2014-04-07 14:31:33 +02:00
2015-12-28 01:51:36 +01:00
2018-05-30 07:50:44 +02:00
2017-06-27 10:43:56 +02:00
2023-05-16 11:53:41 +09:00
2023-05-15 13:00:00 +09:00
2016-06-02 23:24:39 +02:00
2020-02-04 13:48:58 +09:00
2016-07-07 00:14:27 +02:00
2016-06-09 00:58:06 +02:00
2017-01-31 10:46:03 -08:00
2017-01-31 10:46:03 -08:00
2023-05-15 09:10:24 +09:00
2018-07-18 13:22:08 +00:00
2017-01-31 10:46:03 -08:00
2016-09-16 23:57:04 +02:00
2023-05-15 09:19:38 +09:00
2016-09-13 02:39:12 +02:00
2016-04-09 01:35:18 +02:00
2023-05-15 16:19:37 +09:00
2014-04-07 14:43:50 +02:00
2014-04-07 14:43:50 +02:00
2016-06-09 00:58:07 +02:00
2014-10-20 16:20:24 +02:00
2016-04-27 22:42:34 +02:00
2016-04-09 01:35:18 +02:00
2015-09-15 02:03:16 +02:00
2016-07-07 00:13:20 +02:00
2015-06-15 15:46:15 +02:00
2023-05-16 09:57:46 +09:00
2016-04-09 01:35:18 +02:00
2023-05-15 09:57:51 +09:00
2015-09-25 23:29:35 +02:00
2023-05-15 12:46:28 +09:00
2018-04-03 11:15:30 -07:00
2018-08-01 22:37:29 -07:00
2015-03-18 22:35:16 +01:00
2016-04-28 01:01:39 +02:00
2016-09-26 15:10:58 +02:00
2018-02-22 15:43:55 +01:00
2013-07-14 19:36:57 -04:00
2013-10-16 00:50:23 +02:00
2023-05-16 09:57:49 +09:00
2016-04-09 01:35:18 +02:00
2018-08-01 22:37:29 -07:00
2016-04-09 01:35:18 +02:00
2016-05-26 09:23:43 -07:00
2016-06-13 23:49:43 +02:00
2016-05-27 15:26:11 -07:00
2018-02-22 15:43:55 +01:00
2023-05-15 14:17:02 +09:00
2016-07-22 23:51:06 +02:00
2023-05-15 13:35:19 +09:00
2016-04-09 01:35:18 +02:00
2016-04-09 01:35:18 +02:00
2018-02-22 15:43:55 +01:00
2011-05-19 18:51:07 -04:00
2023-05-16 10:26:09 +09:00
2014-05-17 01:27:01 +02:00
2023-05-16 09:38:54 +09:00
2013-04-10 13:19:26 +02:00
2016-06-09 00:58:05 +02:00
2023-05-15 13:35:16 +09:00
2016-04-27 22:42:34 +02:00
2023-05-15 12:06:06 +09:00
2014-03-12 01:06:00 +01:00
2016-04-25 16:07:02 +02:00
2016-04-09 01:35:18 +02:00
2018-03-11 16:21:28 +01:00
2014-04-30 00:06:21 +02:00
2014-07-19 04:24:59 +09:00
2016-04-09 01:35:18 +02:00
2017-07-05 14:40:30 +02:00
2016-04-09 01:35:18 +02:00
2016-08-01 18:36:01 -04:00
2014-01-06 14:17:25 +01:00
2016-08-23 10:25:17 +01:00
2016-04-09 01:35:18 +02:00
2023-05-16 09:57:50 +09:00
2015-09-01 15:51:15 +02:00
2018-03-24 11:00:10 +01:00
2014-03-12 01:06:00 +01:00
2014-03-12 01:06:00 +01:00
2014-10-20 16:20:24 +02:00
2018-02-22 15:43:55 +01:00
2016-04-09 01:35:18 +02:00
2018-02-22 15:43:55 +01:00
2011-05-19 18:51:07 -04:00
2016-04-09 01:35:18 +02:00
2023-05-16 09:57:48 +09:00
2015-09-26 03:00:57 +02:00
2023-05-15 12:06:05 +09:00
2014-04-21 23:42:27 +02:00
2016-05-05 01:40:04 +02:00