]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/commitdiff
5.3-stable patches
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 9 Oct 2019 09:51:36 +0000 (11:51 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 9 Oct 2019 09:51:36 +0000 (11:51 +0200)
added patches:
coresight-etm4x-use-explicit-barriers-on-enable-disable.patch
vfs-fix-eoverflow-testing-in-put_compat_statfs64.patch

queue-5.3/coresight-etm4x-use-explicit-barriers-on-enable-disable.patch [new file with mode: 0644]
queue-5.3/series
queue-5.3/vfs-fix-eoverflow-testing-in-put_compat_statfs64.patch [new file with mode: 0644]

diff --git a/queue-5.3/coresight-etm4x-use-explicit-barriers-on-enable-disable.patch b/queue-5.3/coresight-etm4x-use-explicit-barriers-on-enable-disable.patch
new file mode 100644 (file)
index 0000000..1ccff48
--- /dev/null
@@ -0,0 +1,72 @@
+From 1004ce4c255fc3eb3ad9145ddd53547d1b7ce327 Mon Sep 17 00:00:00 2001
+From: Andrew Murray <andrew.murray@arm.com>
+Date: Thu, 29 Aug 2019 14:28:35 -0600
+Subject: coresight: etm4x: Use explicit barriers on enable/disable
+
+From: Andrew Murray <andrew.murray@arm.com>
+
+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 <andrew.murray@arm.com>
+Reviewed-by: Suzuki K Poulose <suzuki.poulose@arm.com>
+[Fixed capital letter for "use" in title]
+Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
+Link: https://lore.kernel.org/r/20190829202842.580-11-mathieu.poirier@linaro.org
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ drivers/hwtracing/coresight/coresight-etm4x.c |   15 +++++++++++++--
+ 1 file changed, 13 insertions(+), 2 deletions(-)
+
+--- a/drivers/hwtracing/coresight/coresight-etm4x.c
++++ b/drivers/hwtracing/coresight/coresight-etm4x.c
+@@ -188,6 +188,13 @@ static int etm4_enable_hw(struct etmv4_d
+               dev_err(etm_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();
++
+ done:
+       CS_LOCK(drvdata->base);
+@@ -453,8 +460,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);
index df4d379f8687ab8bdf496c48960a06ecd919c99d..a6d6c56c7a5074e1f4bcb2a669e540a189cf24b6 100644 (file)
@@ -138,3 +138,5 @@ kvm-nvmx-fix-consistency-check-on-injected-exception.patch
 tick-broadcast-hrtimer-fix-a-race-in-bc_set_next.patch
 perf-stat-reset-previous-counts-on-repeat-with-inter.patch
 riscv-avoid-interrupts-being-erroneously-enabled-in-.patch
+vfs-fix-eoverflow-testing-in-put_compat_statfs64.patch
+coresight-etm4x-use-explicit-barriers-on-enable-disable.patch
diff --git a/queue-5.3/vfs-fix-eoverflow-testing-in-put_compat_statfs64.patch b/queue-5.3/vfs-fix-eoverflow-testing-in-put_compat_statfs64.patch
new file mode 100644 (file)
index 0000000..2f1f553
--- /dev/null
@@ -0,0 +1,62 @@
+From cc3a7bfe62b947b423fcb2cfe89fcba92bf48fa3 Mon Sep 17 00:00:00 2001
+From: Eric Sandeen <sandeen@redhat.com>
+Date: Wed, 2 Oct 2019 16:17:54 -0500
+Subject: vfs: Fix EOVERFLOW testing in put_compat_statfs64
+
+From: Eric Sandeen <sandeen@redhat.com>
+
+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 <sandeen@redhat.com>
+Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+
+---
+ fs/statfs.c |   17 ++++-------------
+ 1 file changed, 4 insertions(+), 13 deletions(-)
+
+--- a/fs/statfs.c
++++ b/fs/statfs.c
+@@ -318,19 +318,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;