From: Sasha Levin Date: Sun, 24 Nov 2024 14:13:05 +0000 (-0500) Subject: Fixes for 5.10 X-Git-Tag: v4.19.325~134 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=5b26d0a3ac0c97fbe20e2b81d0c918220bcd8b9c;p=thirdparty%2Fkernel%2Fstable-queue.git Fixes for 5.10 Signed-off-by: Sasha Levin --- diff --git a/queue-5.10/cifs-fix-buffer-overflow-when-parsing-nfs-reparse-po.patch b/queue-5.10/cifs-fix-buffer-overflow-when-parsing-nfs-reparse-po.patch new file mode 100644 index 00000000000..e9d383897cd --- /dev/null +++ b/queue-5.10/cifs-fix-buffer-overflow-when-parsing-nfs-reparse-po.patch @@ -0,0 +1,60 @@ +From 45ce9475b0f944f7160c6565e980a46e00af4bcb Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Fri, 22 Nov 2024 16:29:43 +0100 +Subject: cifs: Fix buffer overflow when parsing NFS reparse points +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +From: Pali Rohár + +commit e2a8910af01653c1c268984855629d71fb81f404 upstream. + +ReparseDataLength is sum of the InodeType size and DataBuffer size. +So to get DataBuffer size it is needed to subtract InodeType's size from +ReparseDataLength. + +Function cifs_strndup_from_utf16() is currentlly accessing buf->DataBuffer +at position after the end of the buffer because it does not subtract +InodeType size from the length. Fix this problem and correctly subtract +variable len. + +Member InodeType is present only when reparse buffer is large enough. Check +for ReparseDataLength before accessing InodeType to prevent another invalid +memory access. + +Major and minor rdev values are present also only when reparse buffer is +large enough. Check for reparse buffer size before calling reparse_mkdev(). + +Fixes: d5ecebc4900d ("smb3: Allow query of symlinks stored as reparse points") +Reviewed-by: Paulo Alcantara (Red Hat) +Signed-off-by: Pali Rohár +Signed-off-by: Steve French +[use variable name symlink_buf, the other buf->InodeType accesses are +not used in current version so skip] +Signed-off-by: Mahmoud Adam +Signed-off-by: Sasha Levin +--- + fs/cifs/smb2ops.c | 6 ++++++ + 1 file changed, 6 insertions(+) + +diff --git a/fs/cifs/smb2ops.c b/fs/cifs/smb2ops.c +index b2a7238a34221..68f93de2b1527 100644 +--- a/fs/cifs/smb2ops.c ++++ b/fs/cifs/smb2ops.c +@@ -2807,6 +2807,12 @@ parse_reparse_posix(struct reparse_posix_data *symlink_buf, + + /* See MS-FSCC 2.1.2.6 for the 'NFS' style reparse tags */ + len = le16_to_cpu(symlink_buf->ReparseDataLength); ++ if (len < sizeof(symlink_buf->InodeType)) { ++ cifs_dbg(VFS, "srv returned malformed nfs buffer\n"); ++ return -EIO; ++ } ++ ++ len -= sizeof(symlink_buf->InodeType); + + if (le64_to_cpu(symlink_buf->InodeType) != NFS_SPECFILE_LNK) { + cifs_dbg(VFS, "%lld not a supported symlink type\n", +-- +2.43.0 + diff --git a/queue-5.10/rcu-tasks-idle-tasks-on-offline-cpus-are-in-quiescen.patch b/queue-5.10/rcu-tasks-idle-tasks-on-offline-cpus-are-in-quiescen.patch new file mode 100644 index 00000000000..c176a9eefdc --- /dev/null +++ b/queue-5.10/rcu-tasks-idle-tasks-on-offline-cpus-are-in-quiescen.patch @@ -0,0 +1,43 @@ +From 4e19541020703c4914948cae077e305a62031787 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Fri, 22 Nov 2024 00:48:03 -0800 +Subject: rcu-tasks: Idle tasks on offline CPUs are in quiescent states + +From: Paul E. McKenney + +commit 5c9a9ca44fda41c5e82f50efced5297a9c19760d upstream. + +Any idle task corresponding to an offline CPU is in an RCU Tasks Trace +quiescent state. This commit causes rcu_tasks_trace_postscan() to ignore +idle tasks for offline CPUs, which it can do safely due to CPU-hotplug +operations being disabled. + +Signed-off-by: Paul E. McKenney +Cc: Neeraj Upadhyay +Cc: Eric Dumazet +Cc: Alexei Starovoitov +Cc: Andrii Nakryiko +Cc: Martin KaFai Lau +Cc: KP Singh +Signed-off-by: Krister Johansen +Signed-off-by: Sasha Levin +--- + kernel/rcu/tasks.h | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/kernel/rcu/tasks.h b/kernel/rcu/tasks.h +index bede3a4f108e3..ea45a2d53a99e 100644 +--- a/kernel/rcu/tasks.h ++++ b/kernel/rcu/tasks.h +@@ -1007,7 +1007,7 @@ static void rcu_tasks_trace_postscan(struct list_head *hop) + { + int cpu; + +- for_each_possible_cpu(cpu) ++ for_each_online_cpu(cpu) + rcu_tasks_trace_pertask(idle_task(cpu), hop); + + // Re-enable CPU hotplug now that the tasklist scan has completed. +-- +2.43.0 + diff --git a/queue-5.10/series b/queue-5.10/series index 459c668a2b2..8b55c299147 100644 --- a/queue-5.10/series +++ b/queue-5.10/series @@ -36,3 +36,6 @@ asoc-stm-prevent-potential-division-by-zero-in-stm32.patch-9969 proc-softirqs-replace-seq_printf-with-seq_put_decima.patch alsa-usb-audio-fix-yamaha-p-125-quirk-entry.patch ipmr-fix-access-to-mfc_cache_list-without-lock-held.patch +rcu-tasks-idle-tasks-on-offline-cpus-are-in-quiescen.patch +x86-stackprotector-work-around-strict-clang-tls-symb.patch +cifs-fix-buffer-overflow-when-parsing-nfs-reparse-po.patch diff --git a/queue-5.10/x86-stackprotector-work-around-strict-clang-tls-symb.patch b/queue-5.10/x86-stackprotector-work-around-strict-clang-tls-symb.patch new file mode 100644 index 00000000000..714da7ee6fe --- /dev/null +++ b/queue-5.10/x86-stackprotector-work-around-strict-clang-tls-symb.patch @@ -0,0 +1,138 @@ +From 97faa51a302d85d2a395731e6d8c880f21571bd5 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Thu, 21 Nov 2024 09:29:54 -0500 +Subject: x86/stackprotector: Work around strict Clang TLS symbol requirements + +From: Ard Biesheuvel + +[ Upstream commit 577c134d311b9b94598d7a0c86be1f431f823003 ] + +GCC and Clang both implement stack protector support based on Thread Local +Storage (TLS) variables, and this is used in the kernel to implement per-task +stack cookies, by copying a task's stack cookie into a per-CPU variable every +time it is scheduled in. + +Both now also implement -mstack-protector-guard-symbol=, which permits the TLS +variable to be specified directly. This is useful because it will allow to +move away from using a fixed offset of 40 bytes into the per-CPU area on +x86_64, which requires a lot of special handling in the per-CPU code and the +runtime relocation code. + +However, while GCC is rather lax in its implementation of this command line +option, Clang actually requires that the provided symbol name refers to a TLS +variable (i.e., one declared with __thread), although it also permits the +variable to be undeclared entirely, in which case it will use an implicit +declaration of the right type. + +The upshot of this is that Clang will emit the correct references to the stack +cookie variable in most cases, e.g., + + 10d: 64 a1 00 00 00 00 mov %fs:0x0,%eax + 10f: R_386_32 __stack_chk_guard + +However, if a non-TLS definition of the symbol in question is visible in the +same compilation unit (which amounts to the whole of vmlinux if LTO is +enabled), it will drop the per-CPU prefix and emit a load from a bogus +address. + +Work around this by using a symbol name that never occurs in C code, and emit +it as an alias in the linker script. + +Fixes: 3fb0fdb3bbe7 ("x86/stackprotector/32: Make the canary into a regular percpu variable") +Signed-off-by: Ard Biesheuvel +Signed-off-by: Brian Gerst +Signed-off-by: Borislav Petkov (AMD) +Reviewed-by: Nathan Chancellor +Tested-by: Nathan Chancellor +Cc: stable@vger.kernel.org +Link: https://github.com/ClangBuiltLinux/linux/issues/1854 +Link: https://lore.kernel.org/r/20241105155801.1779119-2-brgerst@gmail.com +Signed-off-by: Sasha Levin +--- + arch/x86/Makefile | 3 ++- + arch/x86/entry/entry.S | 15 +++++++++++++++ + arch/x86/include/asm/asm-prototypes.h | 3 +++ + arch/x86/kernel/cpu/common.c | 2 ++ + arch/x86/kernel/vmlinux.lds.S | 3 +++ + 5 files changed, 25 insertions(+), 1 deletion(-) + +diff --git a/arch/x86/Makefile b/arch/x86/Makefile +index 8b9fa777f513b..dcd8c6f676cac 100644 +--- a/arch/x86/Makefile ++++ b/arch/x86/Makefile +@@ -90,7 +90,8 @@ ifeq ($(CONFIG_X86_32),y) + + ifeq ($(CONFIG_STACKPROTECTOR),y) + ifeq ($(CONFIG_SMP),y) +- KBUILD_CFLAGS += -mstack-protector-guard-reg=fs -mstack-protector-guard-symbol=__stack_chk_guard ++ KBUILD_CFLAGS += -mstack-protector-guard-reg=fs \ ++ -mstack-protector-guard-symbol=__ref_stack_chk_guard + else + KBUILD_CFLAGS += -mstack-protector-guard=global + endif +diff --git a/arch/x86/entry/entry.S b/arch/x86/entry/entry.S +index f4419afc7147d..23f9efbe9d705 100644 +--- a/arch/x86/entry/entry.S ++++ b/arch/x86/entry/entry.S +@@ -48,3 +48,18 @@ EXPORT_SYMBOL_GPL(mds_verw_sel); + + .popsection + ++#ifndef CONFIG_X86_64 ++/* ++ * Clang's implementation of TLS stack cookies requires the variable in ++ * question to be a TLS variable. If the variable happens to be defined as an ++ * ordinary variable with external linkage in the same compilation unit (which ++ * amounts to the whole of vmlinux with LTO enabled), Clang will drop the ++ * segment register prefix from the references, resulting in broken code. Work ++ * around this by avoiding the symbol used in -mstack-protector-guard-symbol= ++ * entirely in the C code, and use an alias emitted by the linker script ++ * instead. ++ */ ++#ifdef CONFIG_STACKPROTECTOR ++EXPORT_SYMBOL(__ref_stack_chk_guard); ++#endif ++#endif +diff --git a/arch/x86/include/asm/asm-prototypes.h b/arch/x86/include/asm/asm-prototypes.h +index 5cdccea455544..390b13db24b81 100644 +--- a/arch/x86/include/asm/asm-prototypes.h ++++ b/arch/x86/include/asm/asm-prototypes.h +@@ -18,3 +18,6 @@ + extern void cmpxchg8b_emu(void); + #endif + ++#if defined(__GENKSYMS__) && defined(CONFIG_STACKPROTECTOR) ++extern unsigned long __ref_stack_chk_guard; ++#endif +diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c +index bdcf1e9375ee2..f8e5598408bfd 100644 +--- a/arch/x86/kernel/cpu/common.c ++++ b/arch/x86/kernel/cpu/common.c +@@ -1974,8 +1974,10 @@ EXPORT_PER_CPU_SYMBOL(cpu_current_top_of_stack); + + #ifdef CONFIG_STACKPROTECTOR + DEFINE_PER_CPU(unsigned long, __stack_chk_guard); ++#ifndef CONFIG_SMP + EXPORT_PER_CPU_SYMBOL(__stack_chk_guard); + #endif ++#endif + + #endif /* CONFIG_X86_64 */ + +diff --git a/arch/x86/kernel/vmlinux.lds.S b/arch/x86/kernel/vmlinux.lds.S +index 740f87d8aa481..60fb61dffe98e 100644 +--- a/arch/x86/kernel/vmlinux.lds.S ++++ b/arch/x86/kernel/vmlinux.lds.S +@@ -490,6 +490,9 @@ SECTIONS + ASSERT(SIZEOF(.rela.dyn) == 0, "Unexpected run-time relocations (.rela) detected!") + } + ++/* needed for Clang - see arch/x86/entry/entry.S */ ++PROVIDE(__ref_stack_chk_guard = __stack_chk_guard); ++ + #ifdef CONFIG_X86_32 + /* + * The ASSERT() sink to . is intentional, for binutils 2.14 compatibility: +-- +2.43.0 +