]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/commitdiff
5.4-stable patches
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 7 Mar 2021 15:18:37 +0000 (16:18 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 7 Mar 2021 15:18:37 +0000 (16:18 +0100)
added patches:
arm64-ptrace-fix-seccomp-of-traced-syscall-1-no_syscall.patch
crypto-shash-reduce-minimum-alignment-of-shash_desc-structure.patch
usbip-tools-fix-build-error-for-multiple-definition.patch

queue-5.4/arm64-ptrace-fix-seccomp-of-traced-syscall-1-no_syscall.patch [new file with mode: 0644]
queue-5.4/crypto-shash-reduce-minimum-alignment-of-shash_desc-structure.patch [new file with mode: 0644]
queue-5.4/series
queue-5.4/usbip-tools-fix-build-error-for-multiple-definition.patch [new file with mode: 0644]

diff --git a/queue-5.4/arm64-ptrace-fix-seccomp-of-traced-syscall-1-no_syscall.patch b/queue-5.4/arm64-ptrace-fix-seccomp-of-traced-syscall-1-no_syscall.patch
new file mode 100644 (file)
index 0000000..4f94373
--- /dev/null
@@ -0,0 +1,52 @@
+From df84fe94708985cdfb78a83148322bcd0a699472 Mon Sep 17 00:00:00 2001
+From: Timothy E Baldwin <T.E.Baldwin99@members.leeds.ac.uk>
+Date: Sat, 16 Jan 2021 15:18:54 +0000
+Subject: arm64: ptrace: Fix seccomp of traced syscall -1 (NO_SYSCALL)
+
+From: Timothy E Baldwin <T.E.Baldwin99@members.leeds.ac.uk>
+
+commit df84fe94708985cdfb78a83148322bcd0a699472 upstream.
+
+Since commit f086f67485c5 ("arm64: ptrace: add support for syscall
+emulation"), if system call number -1 is called and the process is being
+traced with PTRACE_SYSCALL, for example by strace, the seccomp check is
+skipped and -ENOSYS is returned unconditionally (unless altered by the
+tracer) rather than carrying out action specified in the seccomp filter.
+
+The consequence of this is that it is not possible to reliably strace
+a seccomp based implementation of a foreign system call interface in
+which r7/x8 is permitted to be -1 on entry to a system call.
+
+Also trace_sys_enter and audit_syscall_entry are skipped if a system
+call is skipped.
+
+Fix by removing the in_syscall(regs) check restoring the previous
+behaviour which is like AArch32, x86 (which uses generic code) and
+everything else.
+
+Cc: Oleg Nesterov <oleg@redhat.com>
+Cc: Catalin Marinas<catalin.marinas@arm.com>
+Cc: <stable@vger.kernel.org>
+Fixes: f086f67485c5 ("arm64: ptrace: add support for syscall emulation")
+Reviewed-by: Kees Cook <keescook@chromium.org>
+Reviewed-by: Sudeep Holla <sudeep.holla@arm.com>
+Tested-by: Sudeep Holla <sudeep.holla@arm.com>
+Signed-off-by: Timothy E Baldwin <T.E.Baldwin99@members.leeds.ac.uk>
+Link: https://lore.kernel.org/r/90edd33b-6353-1228-791f-0336d94d5f8c@majoroak.me.uk
+Signed-off-by: Will Deacon <will@kernel.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ arch/arm64/kernel/ptrace.c |    2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+--- a/arch/arm64/kernel/ptrace.c
++++ b/arch/arm64/kernel/ptrace.c
+@@ -1844,7 +1844,7 @@ int syscall_trace_enter(struct pt_regs *
+       if (flags & (_TIF_SYSCALL_EMU | _TIF_SYSCALL_TRACE)) {
+               tracehook_report_syscall(regs, PTRACE_SYSCALL_ENTER);
+-              if (!in_syscall(regs) || (flags & _TIF_SYSCALL_EMU))
++              if (flags & _TIF_SYSCALL_EMU)
+                       return -1;
+       }
diff --git a/queue-5.4/crypto-shash-reduce-minimum-alignment-of-shash_desc-structure.patch b/queue-5.4/crypto-shash-reduce-minimum-alignment-of-shash_desc-structure.patch
new file mode 100644 (file)
index 0000000..d995bdb
--- /dev/null
@@ -0,0 +1,84 @@
+From 660d2062190db131d2feaf19914e90f868fe285c Mon Sep 17 00:00:00 2001
+From: Ard Biesheuvel <ardb@kernel.org>
+Date: Wed, 13 Jan 2021 10:11:35 +0100
+Subject: crypto - shash: reduce minimum alignment of shash_desc structure
+
+From: Ard Biesheuvel <ardb@kernel.org>
+
+commit 660d2062190db131d2feaf19914e90f868fe285c upstream.
+
+Unlike many other structure types defined in the crypto API, the
+'shash_desc' structure is permitted to live on the stack, which
+implies its contents may not be accessed by DMA masters. (This is
+due to the fact that the stack may be located in the vmalloc area,
+which requires a different virtual-to-physical translation than the
+one implemented by the DMA subsystem)
+
+Our definition of CRYPTO_MINALIGN_ATTR is based on ARCH_KMALLOC_MINALIGN,
+which may take DMA constraints into account on architectures that support
+non-cache coherent DMA such as ARM and arm64. In this case, the value is
+chosen to reflect the largest cacheline size in the system, in order to
+ensure that explicit cache maintenance as required by non-coherent DMA
+masters does not affect adjacent, unrelated slab allocations. On arm64,
+this value is currently set at 128 bytes.
+
+This means that applying CRYPTO_MINALIGN_ATTR to struct shash_desc is both
+unnecessary (as it is never used for DMA), and undesirable, given that it
+wastes stack space (on arm64, performing the alignment costs 112 bytes in
+the worst case, and the hole between the 'tfm' and '__ctx' members takes
+up another 120 bytes, resulting in an increased stack footprint of up to
+232 bytes.) So instead, let's switch to the minimum SLAB alignment, which
+does not take DMA constraints into account.
+
+Note that this is a no-op for x86.
+
+Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
+Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ include/crypto/hash.h  |    8 ++++----
+ include/linux/crypto.h |    9 ++++++---
+ 2 files changed, 10 insertions(+), 7 deletions(-)
+
+--- a/include/crypto/hash.h
++++ b/include/crypto/hash.h
+@@ -141,7 +141,7 @@ struct ahash_alg {
+ struct shash_desc {
+       struct crypto_shash *tfm;
+-      void *__ctx[] CRYPTO_MINALIGN_ATTR;
++      void *__ctx[] __aligned(ARCH_SLAB_MINALIGN);
+ };
+ #define HASH_MAX_DIGESTSIZE    64
+@@ -154,9 +154,9 @@ struct shash_desc {
+ #define HASH_MAX_STATESIZE    512
+-#define SHASH_DESC_ON_STACK(shash, ctx)                                 \
+-      char __##shash##_desc[sizeof(struct shash_desc) +         \
+-              HASH_MAX_DESCSIZE] CRYPTO_MINALIGN_ATTR; \
++#define SHASH_DESC_ON_STACK(shash, ctx)                                            \
++      char __##shash##_desc[sizeof(struct shash_desc) + HASH_MAX_DESCSIZE] \
++              __aligned(__alignof__(struct shash_desc));                   \
+       struct shash_desc *shash = (struct shash_desc *)__##shash##_desc
+ /**
+--- a/include/linux/crypto.h
++++ b/include/linux/crypto.h
+@@ -130,9 +130,12 @@
+  * The macro CRYPTO_MINALIGN_ATTR (along with the void * type in the actual
+  * declaration) is used to ensure that the crypto_tfm context structure is
+  * aligned correctly for the given architecture so that there are no alignment
+- * faults for C data types.  In particular, this is required on platforms such
+- * as arm where pointers are 32-bit aligned but there are data types such as
+- * u64 which require 64-bit alignment.
++ * faults for C data types.  On architectures that support non-cache coherent
++ * DMA, such as ARM or arm64, it also takes into account the minimal alignment
++ * that is required to ensure that the context struct member does not share any
++ * cachelines with the rest of the struct. This is needed to ensure that cache
++ * maintenance for non-coherent DMA (cache invalidation in particular) does not
++ * affect data that may be accessed by the CPU concurrently.
+  */
+ #define CRYPTO_MINALIGN ARCH_KMALLOC_MINALIGN
index 67c635a3ea25b1dc1438548897c2b37580d8c936..eade066beecade12a66e6ce2b893aeeab56a37d3 100644 (file)
@@ -10,3 +10,6 @@ pm-runtime-update-device-status-before-letting-suppliers-suspend.patch
 dm-bufio-subtract-the-number-of-initial-sectors-in-dm_bufio_get_device_size.patch
 dm-verity-fix-fec-for-rs-roots-unaligned-to-block-size.patch
 drm-amdgpu-fix-parameter-error-of-rreg32_pcie-in-amdgpu_regs_pcie.patch
+arm64-ptrace-fix-seccomp-of-traced-syscall-1-no_syscall.patch
+crypto-shash-reduce-minimum-alignment-of-shash_desc-structure.patch
+usbip-tools-fix-build-error-for-multiple-definition.patch
diff --git a/queue-5.4/usbip-tools-fix-build-error-for-multiple-definition.patch b/queue-5.4/usbip-tools-fix-build-error-for-multiple-definition.patch
new file mode 100644 (file)
index 0000000..f29f3f0
--- /dev/null
@@ -0,0 +1,36 @@
+From d5efc2e6b98fe661dbd8dd0d5d5bfb961728e57a Mon Sep 17 00:00:00 2001
+From: Antonio Borneo <borneo.antonio@gmail.com>
+Date: Thu, 18 Jun 2020 02:08:44 +0200
+Subject: usbip: tools: fix build error for multiple definition
+
+From: Antonio Borneo <borneo.antonio@gmail.com>
+
+commit d5efc2e6b98fe661dbd8dd0d5d5bfb961728e57a upstream.
+
+With GCC 10, building usbip triggers error for multiple definition
+of 'udev_context', in:
+- libsrc/vhci_driver.c:18 and
+- libsrc/usbip_host_common.c:27.
+
+Declare as extern the definition in libsrc/usbip_host_common.c.
+
+Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
+Acked-by: Shuah Khan <skhan@linuxfoundation.org>
+Link: https://lore.kernel.org/r/20200618000844.1048309-1-borneo.antonio@gmail.com
+Cc: Petr Štetiar <ynezz@true.cz>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ tools/usb/usbip/libsrc/usbip_host_common.c |    2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+--- a/tools/usb/usbip/libsrc/usbip_host_common.c
++++ b/tools/usb/usbip/libsrc/usbip_host_common.c
+@@ -23,7 +23,7 @@
+ #include "list.h"
+ #include "sysfs_utils.h"
+-struct udev *udev_context;
++extern struct udev *udev_context;
+ static int32_t read_attr_usbip_status(struct usbip_usb_device *udev)
+ {