]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/commitdiff
5.18-stable patches
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 30 Jun 2022 11:31:12 +0000 (13:31 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 30 Jun 2022 11:31:12 +0000 (13:31 +0200)
added patches:
hinic-replace-memcpy-with-direct-assignment.patch
powerpc-ftrace-remove-ftrace-init-tramp-once-kernel-init-is-complete.patch

queue-5.18/hinic-replace-memcpy-with-direct-assignment.patch [new file with mode: 0644]
queue-5.18/powerpc-ftrace-remove-ftrace-init-tramp-once-kernel-init-is-complete.patch [new file with mode: 0644]
queue-5.18/series

diff --git a/queue-5.18/hinic-replace-memcpy-with-direct-assignment.patch b/queue-5.18/hinic-replace-memcpy-with-direct-assignment.patch
new file mode 100644 (file)
index 0000000..36eea57
--- /dev/null
@@ -0,0 +1,49 @@
+From 1e70212e031528918066a631c9fdccda93a1ffaa Mon Sep 17 00:00:00 2001
+From: Kees Cook <keescook@chromium.org>
+Date: Wed, 15 Jun 2022 22:23:12 -0700
+Subject: hinic: Replace memcpy() with direct assignment
+
+From: Kees Cook <keescook@chromium.org>
+
+commit 1e70212e031528918066a631c9fdccda93a1ffaa upstream.
+
+Under CONFIG_FORTIFY_SOURCE=y and CONFIG_UBSAN_BOUNDS=y, Clang is bugged
+here for calculating the size of the destination buffer (0x10 instead of
+0x14). This copy is a fixed size (sizeof(struct fw_section_info_st)), with
+the source and dest being struct fw_section_info_st, so the memcpy should
+be safe, assuming the index is within bounds, which is UBSAN_BOUNDS's
+responsibility to figure out.
+
+Avoid the whole thing and just do a direct assignment. This results in
+no change to the executable code.
+
+[This is a duplicate of commit 2c0ab32b73cf ("hinic: Replace memcpy()
+ with direct assignment") which was applied to net-next.]
+
+Cc: Nick Desaulniers <ndesaulniers@google.com>
+Cc: Tom Rix <trix@redhat.com>
+Cc: llvm@lists.linux.dev
+Link: https://github.com/ClangBuiltLinux/linux/issues/1592
+Signed-off-by: Kees Cook <keescook@chromium.org>
+Reviewed-by: Gustavo A. R. Silva <gustavoars@kernel.org>
+Tested-by: Nathan Chancellor <nathan@kernel.org> # build
+Link: https://lore.kernel.org/r/20220616052312.292861-1-keescook@chromium.org
+Signed-off-by: Jakub Kicinski <kuba@kernel.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ drivers/net/ethernet/huawei/hinic/hinic_devlink.c |    4 +---
+ 1 file changed, 1 insertion(+), 3 deletions(-)
+
+--- a/drivers/net/ethernet/huawei/hinic/hinic_devlink.c
++++ b/drivers/net/ethernet/huawei/hinic/hinic_devlink.c
+@@ -43,9 +43,7 @@ static bool check_image_valid(struct hin
+       for (i = 0; i < fw_image->fw_info.fw_section_cnt; i++) {
+               len += fw_image->fw_section_info[i].fw_section_len;
+-              memcpy(&host_image->image_section_info[i],
+-                     &fw_image->fw_section_info[i],
+-                     sizeof(struct fw_section_info_st));
++              host_image->image_section_info[i] = fw_image->fw_section_info[i];
+       }
+       if (len != fw_image->fw_len ||
diff --git a/queue-5.18/powerpc-ftrace-remove-ftrace-init-tramp-once-kernel-init-is-complete.patch b/queue-5.18/powerpc-ftrace-remove-ftrace-init-tramp-once-kernel-init-is-complete.patch
new file mode 100644 (file)
index 0000000..8b555ce
--- /dev/null
@@ -0,0 +1,98 @@
+From 84ade0a6655bee803d176525ef457175cbf4df22 Mon Sep 17 00:00:00 2001
+From: "Naveen N. Rao" <naveen.n.rao@linux.vnet.ibm.com>
+Date: Mon, 16 May 2022 12:44:22 +0530
+Subject: powerpc/ftrace: Remove ftrace init tramp once kernel init is complete
+
+From: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
+
+commit 84ade0a6655bee803d176525ef457175cbf4df22 upstream.
+
+Stop using the ftrace trampoline for init section once kernel init is
+complete.
+
+Fixes: 67361cf8071286 ("powerpc/ftrace: Handle large kernel configs")
+Cc: stable@vger.kernel.org # v4.20+
+Signed-off-by: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
+Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
+Link: https://lore.kernel.org/r/20220516071422.463738-1-naveen.n.rao@linux.vnet.ibm.com
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ arch/powerpc/include/asm/ftrace.h  |    4 +++-
+ arch/powerpc/kernel/trace/ftrace.c |   15 ++++++++++++---
+ arch/powerpc/mm/mem.c              |    2 ++
+ 3 files changed, 17 insertions(+), 4 deletions(-)
+
+--- a/arch/powerpc/include/asm/ftrace.h
++++ b/arch/powerpc/include/asm/ftrace.h
+@@ -86,7 +86,7 @@ static inline bool arch_syscall_match_sy
+ #endif /* PPC64_ELF_ABI_v1 */
+ #endif /* CONFIG_FTRACE_SYSCALLS */
+-#ifdef CONFIG_PPC64
++#if defined(CONFIG_PPC64) && defined(CONFIG_FUNCTION_TRACER)
+ #include <asm/paca.h>
+ static inline void this_cpu_disable_ftrace(void)
+@@ -110,11 +110,13 @@ static inline u8 this_cpu_get_ftrace_ena
+       return get_paca()->ftrace_enabled;
+ }
++void ftrace_free_init_tramp(void);
+ #else /* CONFIG_PPC64 */
+ static inline void this_cpu_disable_ftrace(void) { }
+ static inline void this_cpu_enable_ftrace(void) { }
+ static inline void this_cpu_set_ftrace_enabled(u8 ftrace_enabled) { }
+ static inline u8 this_cpu_get_ftrace_enabled(void) { return 1; }
++static inline void ftrace_free_init_tramp(void) { }
+ #endif /* CONFIG_PPC64 */
+ #endif /* !__ASSEMBLY__ */
+--- a/arch/powerpc/kernel/trace/ftrace.c
++++ b/arch/powerpc/kernel/trace/ftrace.c
+@@ -306,9 +306,7 @@ static int setup_mcount_compiler_tramp(u
+       /* Is this a known long jump tramp? */
+       for (i = 0; i < NUM_FTRACE_TRAMPS; i++)
+-              if (!ftrace_tramps[i])
+-                      break;
+-              else if (ftrace_tramps[i] == tramp)
++              if (ftrace_tramps[i] == tramp)
+                       return 0;
+       /* Is this a known plt tramp? */
+@@ -863,6 +861,17 @@ void arch_ftrace_update_code(int command
+ extern unsigned int ftrace_tramp_text[], ftrace_tramp_init[];
++void ftrace_free_init_tramp(void)
++{
++      int i;
++
++      for (i = 0; i < NUM_FTRACE_TRAMPS && ftrace_tramps[i]; i++)
++              if (ftrace_tramps[i] == (unsigned long)ftrace_tramp_init) {
++                      ftrace_tramps[i] = 0;
++                      return;
++              }
++}
++
+ int __init ftrace_dyn_arch_init(void)
+ {
+       int i;
+--- a/arch/powerpc/mm/mem.c
++++ b/arch/powerpc/mm/mem.c
+@@ -22,6 +22,7 @@
+ #include <asm/kasan.h>
+ #include <asm/svm.h>
+ #include <asm/mmzone.h>
++#include <asm/ftrace.h>
+ #include <mm/mmu_decl.h>
+@@ -312,6 +313,7 @@ void free_initmem(void)
+       ppc_md.progress = ppc_printk_progress;
+       mark_initmem_nx();
+       free_initmem_default(POISON_FREE_INITMEM);
++      ftrace_free_init_tramp();
+ }
+ /*
index 0030134f59068b3e65cf982aa2bd2099bd7cb069..680a72db6c69dede94ba5626c4e4b11ea5ae40e1 100644 (file)
@@ -1,3 +1,5 @@
 tick-nohz-unexport-__init-annotated-tick_nohz_full_setup.patch
 clocksource-drivers-ixp4xx-drop-boardfile-probe-path.patch
 bcache-memset-on-stack-variables-in-bch_btree_check-and-bch_sectors_dirty_init.patch
+hinic-replace-memcpy-with-direct-assignment.patch
+powerpc-ftrace-remove-ftrace-init-tramp-once-kernel-init-is-complete.patch