linux-sg2042/drivers/hwtracing/intel_th
Alexander Shishkin 05b686b573 intel_th: msu: Fix window switching without windows
Commit 6cac7866c2 ("intel_th: msu: Add a sysfs attribute to trigger
window switch") adds a NULL pointer dereference in the case when there are
no windows allocated:

> BUG: kernel NULL pointer dereference, address: 0000000000000000
> #PF: supervisor read access in kernel mode
> #PF: error_code(0x0000) - not-present page
> PGD 0 P4D 0
> Oops: 0000 1 SMP
> CPU: 5 PID: 1110 Comm: bash Not tainted 5.5.0-rc1+ #1
> RIP: 0010:msc_win_switch+0xa/0x80 [intel_th_msu]
> Call Trace:
> ? win_switch_store+0x9b/0xc0 [intel_th_msu]
> dev_attr_store+0x17/0x30
> sysfs_kf_write+0x3e/0x50
> kernfs_fop_write+0xda/0x1b0
> __vfs_write+0x1b/0x40
> vfs_write+0xb9/0x1a0
> ksys_write+0x67/0xe0
> __x64_sys_write+0x1a/0x20
> do_syscall_64+0x57/0x1d0
> entry_SYSCALL_64_after_hwframe+0x44/0xa9

Fix that by disallowing window switching with multiwindow buffers without
windows.

Signed-off-by: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Fixes: 6cac7866c2 ("intel_th: msu: Add a sysfs attribute to trigger window switch")
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reported-by: Ammy Yi <ammy.yi@intel.com>
Tested-by: Ammy Yi <ammy.yi@intel.com>
Cc: stable@vger.kernel.org # v5.2+
Link: https://lore.kernel.org/r/20191217115527.74383-5-alexander.shishkin@linux.intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-12-17 15:45:59 +01:00
..
Kconfig treewide: Add SPDX license identifier - Makefile/Kconfig 2019-05-21 10:50:46 +02:00
Makefile intel_th: msu-sink: An example msu buffer "sink" 2019-07-25 13:03:18 +02:00
acpi.c intel_th: Communicate IRQ via resource 2019-05-03 18:14:29 +02:00
core.c intel_th: Fix freeing IRQs 2019-12-17 15:45:58 +01:00
debug.c intel_th: Add SPDX GPL-2.0 header to replace GPLv2 boilerplate 2018-03-28 18:47:19 +03:00
debug.h intel_th: Add SPDX GPL-2.0 header to replace GPLv2 boilerplate 2018-03-28 18:47:19 +03:00
gth.c intel_th: gth: Fix the window switching sequence 2019-11-04 15:01:22 +01:00
gth.h intel_th: Add switch triggering support 2019-05-03 18:16:21 +02:00
intel_th.h intel_th: Fix freeing IRQs 2019-12-17 15:45:58 +01:00
msu-sink.c intel_th: msu-sink: An example msu buffer "sink" 2019-07-25 13:03:18 +02:00
msu.c intel_th: msu: Fix window switching without windows 2019-12-17 15:45:59 +01:00
msu.h Merge 5.3-rc5 into char-misc-next 2019-08-19 07:11:53 +02:00
pci.c intel_th: pci: Add Elkhart Lake SOC support 2019-12-17 15:45:57 +01:00
pti.c intel_th: pti: Use sysfs_match_string() helper 2019-02-21 15:04:36 +02:00
pti.h intel_th: Use the correct style for SPDX License Identifier 2019-07-30 19:41:53 +02:00
sth.c intel_th: Mark expected switch fall-throughs 2019-02-21 15:04:36 +02:00
sth.h intel_th: Add SPDX GPL-2.0 header to replace GPLv2 boilerplate 2018-03-28 18:47:19 +03:00