Patch "intel_th: msu: Fix window switching without windows" has been added to the 5.4-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    intel_th: msu: Fix window switching without windows

to the 5.4-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     intel_th-msu-fix-window-switching-without-windows.patch
and it can be found in the queue-5.4 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.


>From 05b686b573cfb35a227c30787083a6631ff0f0c9 Mon Sep 17 00:00:00 2001
From: Alexander Shishkin <alexander.shishkin@xxxxxxxxxxxxxxx>
Date: Tue, 17 Dec 2019 13:55:27 +0200
Subject: intel_th: msu: Fix window switching without windows

From: Alexander Shishkin <alexander.shishkin@xxxxxxxxxxxxxxx>

commit 05b686b573cfb35a227c30787083a6631ff0f0c9 upstream.

Commit 6cac7866c2741 ("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@xxxxxxxxxxxxxxx>
Fixes: 6cac7866c274 ("intel_th: msu: Add a sysfs attribute to trigger window switch")
Reviewed-by: Andy Shevchenko <andriy.shevchenko@xxxxxxxxxxxxxxx>
Reported-by: Ammy Yi <ammy.yi@xxxxxxxxx>
Tested-by: Ammy Yi <ammy.yi@xxxxxxxxx>
Cc: stable@xxxxxxxxxxxxxxx # v5.2+
Link: https://lore.kernel.org/r/20191217115527.74383-5-alexander.shishkin@xxxxxxxxxxxxxxx
Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>

---
 drivers/hwtracing/intel_th/msu.c |   14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

--- a/drivers/hwtracing/intel_th/msu.c
+++ b/drivers/hwtracing/intel_th/msu.c
@@ -1676,10 +1676,13 @@ static int intel_th_msc_init(struct msc
 	return 0;
 }
 
-static void msc_win_switch(struct msc *msc)
+static int msc_win_switch(struct msc *msc)
 {
 	struct msc_window *first;
 
+	if (list_empty(&msc->win_list))
+		return -EINVAL;
+
 	first = list_first_entry(&msc->win_list, struct msc_window, entry);
 
 	if (msc_is_last_win(msc->cur_win))
@@ -1691,6 +1694,8 @@ static void msc_win_switch(struct msc *m
 	msc->base_addr = msc_win_base_dma(msc->cur_win);
 
 	intel_th_trace_switch(msc->thdev);
+
+	return 0;
 }
 
 /**
@@ -2025,16 +2030,15 @@ win_switch_store(struct device *dev, str
 	if (val != 1)
 		return -EINVAL;
 
+	ret = -EINVAL;
 	mutex_lock(&msc->buf_mutex);
 	/*
 	 * Window switch can only happen in the "multi" mode.
 	 * If a external buffer is engaged, they have the full
 	 * control over window switching.
 	 */
-	if (msc->mode != MSC_MODE_MULTI || msc->mbuf)
-		ret = -ENOTSUPP;
-	else
-		msc_win_switch(msc);
+	if (msc->mode == MSC_MODE_MULTI && !msc->mbuf)
+		ret = msc_win_switch(msc);
 	mutex_unlock(&msc->buf_mutex);
 
 	return ret ? ret : size;


Patches currently in stable-queue which might be from alexander.shishkin@xxxxxxxxxxxxxxx are

queue-5.4/perf-jevents-fix-resource-leak-in-process_mapfile-an.patch
queue-5.4/perf-tools-fix-cross-compile-for-arm64.patch
queue-5.4/perf-cs-etm-fix-definition-of-macro-to_cs_queue_nr.patch
queue-5.4/intel_th-pci-add-elkhart-lake-soc-support.patch
queue-5.4/intel_th-pci-add-comet-lake-pch-v-support.patch
queue-5.4/perf-report-add-warning-when-libunwind-not-compiled-.patch
queue-5.4/perf-vendor-events-arm64-fix-hisi-hip08-ddrc-pmu-eve.patch
queue-5.4/perf-session-fix-decompression-of-perf_record_compre.patch
queue-5.4/perf-test-avoid-infinite-loop-for-task-exit-case.patch
queue-5.4/perf-tests-disable-bp_signal-testing-for-arm64.patch
queue-5.4/perf-core-fix-the-mlock-accounting-again.patch
queue-5.4/perf-test-report-failure-for-mmap-events.patch
queue-5.4/perf-parse-fix-potential-memory-leak-when-handling-t.patch
queue-5.4/perf-tools-splice-events-onto-evlist-even-on-error.patch
queue-5.4/intel_th-msu-fix-window-switching-without-windows.patch
queue-5.4/perf-parse-if-pmu-configuration-fails-free-terms.patch
queue-5.4/intel_th-fix-freeing-irqs.patch



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux