From: Greg Kroah-Hartman Date: Wed, 9 Oct 2019 09:50:54 +0000 (+0200) Subject: 4.14-stable patches X-Git-Tag: v4.14.149~13 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=d942f33023a7201ae5c4a62fccc4493bfea36612;p=thirdparty%2Fkernel%2Fstable-queue.git 4.14-stable patches added patches: coresight-etm4x-use-explicit-barriers-on-enable-disable.patch vfs-fix-eoverflow-testing-in-put_compat_statfs64.patch --- diff --git a/queue-4.14/coresight-etm4x-use-explicit-barriers-on-enable-disable.patch b/queue-4.14/coresight-etm4x-use-explicit-barriers-on-enable-disable.patch new file mode 100644 index 00000000000..805c6b9cb02 --- /dev/null +++ b/queue-4.14/coresight-etm4x-use-explicit-barriers-on-enable-disable.patch @@ -0,0 +1,72 @@ +From 1004ce4c255fc3eb3ad9145ddd53547d1b7ce327 Mon Sep 17 00:00:00 2001 +From: Andrew Murray +Date: Thu, 29 Aug 2019 14:28:35 -0600 +Subject: coresight: etm4x: Use explicit barriers on enable/disable + +From: Andrew Murray + +commit 1004ce4c255fc3eb3ad9145ddd53547d1b7ce327 upstream. + +Synchronization is recommended before disabling the trace registers +to prevent any start or stop points being speculative at the point +of disabling the unit (section 7.3.77 of ARM IHI 0064D). + +Synchronization is also recommended after programming the trace +registers to ensure all updates are committed prior to normal code +resuming (section 4.3.7 of ARM IHI 0064D). + +Let's ensure these syncronization points are present in the code +and clearly commented. + +Note that we could rely on the barriers in CS_LOCK and +coresight_disclaim_device_unlocked or the context switch to user +space - however coresight may be of use in the kernel. + +On armv8 the mb macro is defined as dsb(sy) - Given that the etm4x is +only used on armv8 let's directly use dsb(sy) instead of mb(). This +removes some ambiguity and makes it easier to correlate the code with +the TRM. + +Signed-off-by: Andrew Murray +Reviewed-by: Suzuki K Poulose +[Fixed capital letter for "use" in title] +Signed-off-by: Mathieu Poirier +Link: https://lore.kernel.org/r/20190829202842.580-11-mathieu.poirier@linaro.org +Cc: stable@vger.kernel.org # 4.9+ +Signed-off-by: Mathieu Poirier +Signed-off-by: Greg Kroah-Hartman + +--- + drivers/hwtracing/coresight/coresight-etm4x.c | 14 ++++++++++++-- + 1 file changed, 12 insertions(+), 2 deletions(-) + +--- a/drivers/hwtracing/coresight/coresight-etm4x.c ++++ b/drivers/hwtracing/coresight/coresight-etm4x.c +@@ -181,6 +181,12 @@ static void etm4_enable_hw(void *info) + if (coresight_timeout(drvdata->base, TRCSTATR, TRCSTATR_IDLE_BIT, 0)) + dev_err(drvdata->dev, + "timeout while waiting for Idle Trace Status\n"); ++ /* ++ * As recommended by section 4.3.7 ("Synchronization when using the ++ * memory-mapped interface") of ARM IHI 0064D ++ */ ++ dsb(sy); ++ isb(); + + CS_LOCK(drvdata->base); + +@@ -331,8 +337,12 @@ static void etm4_disable_hw(void *info) + /* EN, bit[0] Trace unit enable bit */ + control &= ~0x1; + +- /* make sure everything completes before disabling */ +- mb(); ++ /* ++ * Make sure everything completes before disabling, as recommended ++ * by section 7.3.77 ("TRCVICTLR, ViewInst Main Control Register, ++ * SSTATUS") of ARM IHI 0064D ++ */ ++ dsb(sy); + isb(); + writel_relaxed(control, drvdata->base + TRCPRGCTLR); + diff --git a/queue-4.14/series b/queue-4.14/series index 969babd083c..fd3f4e6bc9d 100644 --- a/queue-4.14/series +++ b/queue-4.14/series @@ -53,3 +53,5 @@ perf-tools-fix-segfault-in-cpu_cache_level__read.patch perf-stat-fix-a-segmentation-fault-when-using-repeat.patch perf-stat-reset-previous-counts-on-repeat-with-inter.patch drm-i915-userptr-acquire-the-page-lock-around-set_pa.patch +vfs-fix-eoverflow-testing-in-put_compat_statfs64.patch +coresight-etm4x-use-explicit-barriers-on-enable-disable.patch diff --git a/queue-4.14/vfs-fix-eoverflow-testing-in-put_compat_statfs64.patch b/queue-4.14/vfs-fix-eoverflow-testing-in-put_compat_statfs64.patch new file mode 100644 index 00000000000..7a6b5747e9e --- /dev/null +++ b/queue-4.14/vfs-fix-eoverflow-testing-in-put_compat_statfs64.patch @@ -0,0 +1,62 @@ +From cc3a7bfe62b947b423fcb2cfe89fcba92bf48fa3 Mon Sep 17 00:00:00 2001 +From: Eric Sandeen +Date: Wed, 2 Oct 2019 16:17:54 -0500 +Subject: vfs: Fix EOVERFLOW testing in put_compat_statfs64 + +From: Eric Sandeen + +commit cc3a7bfe62b947b423fcb2cfe89fcba92bf48fa3 upstream. + +Today, put_compat_statfs64() disallows nearly any field value over +2^32 if f_bsize is only 32 bits, but that makes no sense. +compat_statfs64 is there for the explicit purpose of providing 64-bit +fields for f_files, f_ffree, etc. And f_bsize is always only 32 bits. + +As a result, 32-bit userspace gets -EOVERFLOW for i.e. large file +counts even with -D_FILE_OFFSET_BITS=64 set. + +In reality, only f_bsize and f_frsize can legitimately overflow +(fields like f_type and f_namelen should never be large), so test +only those fields. + +This bug was discussed at length some time ago, and this is the proposal +Al suggested at https://lkml.org/lkml/2018/8/6/640. It seemed to get +dropped amid the discussion of other related changes, but this +part seems obviously correct on its own, so I've picked it up and +sent it, for expediency. + +Fixes: 64d2ab32efe3 ("vfs: fix put_compat_statfs64() does not handle errors") +Signed-off-by: Eric Sandeen +Signed-off-by: Linus Torvalds +Signed-off-by: Greg Kroah-Hartman + +--- + fs/statfs.c | 17 ++++------------- + 1 file changed, 4 insertions(+), 13 deletions(-) + +--- a/fs/statfs.c ++++ b/fs/statfs.c +@@ -304,19 +304,10 @@ COMPAT_SYSCALL_DEFINE2(fstatfs, unsigned + static int put_compat_statfs64(struct compat_statfs64 __user *ubuf, struct kstatfs *kbuf) + { + struct compat_statfs64 buf; +- if (sizeof(ubuf->f_bsize) == 4) { +- if ((kbuf->f_type | kbuf->f_bsize | kbuf->f_namelen | +- kbuf->f_frsize | kbuf->f_flags) & 0xffffffff00000000ULL) +- return -EOVERFLOW; +- /* f_files and f_ffree may be -1; it's okay +- * to stuff that into 32 bits */ +- if (kbuf->f_files != 0xffffffffffffffffULL +- && (kbuf->f_files & 0xffffffff00000000ULL)) +- return -EOVERFLOW; +- if (kbuf->f_ffree != 0xffffffffffffffffULL +- && (kbuf->f_ffree & 0xffffffff00000000ULL)) +- return -EOVERFLOW; +- } ++ ++ if ((kbuf->f_bsize | kbuf->f_frsize) & 0xffffffff00000000ULL) ++ return -EOVERFLOW; ++ + memset(&buf, 0, sizeof(struct compat_statfs64)); + buf.f_type = kbuf->f_type; + buf.f_bsize = kbuf->f_bsize;