From 03a7179cb7d22454b422d0fbc935b1bd42cec5fb Mon Sep 17 00:00:00 2001 From: Sasha Levin Date: Wed, 19 Jun 2024 08:25:05 -0400 Subject: [PATCH] Fixes for 5.10 Signed-off-by: Sasha Levin --- ...-functionality-flags-of-the-slave-on.patch | 44 ++++++ ...ix-the-functionality-flags-of-the-sl.patch | 46 ++++++ ...id-tif_ia32-when-checking-64bit-mode.patch | 82 +++++++++++ queue-5.10/series | 8 + ...da-check-whether-the-media-is-initia.patch | 61 ++++++++ ...ify-compat-syscall-userspace-allocat.patch | 53 +++++++ ...chine-to-select-start_thread-for-x32.patch | 65 +++++++++ ...mu-context-ia32_compat-into-a-proper.patch | 137 ++++++++++++++++++ ...sses-clear-tif_notify_signal-along-w.patch | 61 ++++++++ 9 files changed, 557 insertions(+) create mode 100644 queue-5.10/i2c-at91-fix-the-functionality-flags-of-the-slave-on.patch create mode 100644 queue-5.10/i2c-designware-fix-the-functionality-flags-of-the-sl.patch create mode 100644 queue-5.10/perf-x86-avoid-tif_ia32-when-checking-64bit-mode.patch create mode 100644 queue-5.10/usb-storage-alauda-check-whether-the-media-is-initia.patch create mode 100644 queue-5.10/x86-compat-simplify-compat-syscall-userspace-allocat.patch create mode 100644 queue-5.10/x86-elf-use-e_machine-to-select-start_thread-for-x32.patch create mode 100644 queue-5.10/x86-mm-convert-mmu-context-ia32_compat-into-a-proper.patch create mode 100644 queue-5.10/zap_pid_ns_processes-clear-tif_notify_signal-along-w.patch diff --git a/queue-5.10/i2c-at91-fix-the-functionality-flags-of-the-slave-on.patch b/queue-5.10/i2c-at91-fix-the-functionality-flags-of-the-slave-on.patch new file mode 100644 index 00000000000..9fef6324621 --- /dev/null +++ b/queue-5.10/i2c-at91-fix-the-functionality-flags-of-the-slave-on.patch @@ -0,0 +1,44 @@ +From 2c5613132efdcabe41204a5e8f1ca704096f164c Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Fri, 31 May 2024 11:19:14 +0200 +Subject: i2c: at91: Fix the functionality flags of the slave-only interface + +From: Jean Delvare + +[ Upstream commit d6d5645e5fc1233a7ba950de4a72981c394a2557 ] + +When an I2C adapter acts only as a slave, it should not claim to +support I2C master capabilities. + +Fixes: 9d3ca54b550c ("i2c: at91: added slave mode support") +Signed-off-by: Jean Delvare +Cc: Juergen Fitschen +Cc: Ludovic Desroches +Cc: Codrin Ciubotariu +Cc: Andi Shyti +Cc: Nicolas Ferre +Cc: Alexandre Belloni +Cc: Claudiu Beznea +Signed-off-by: Andi Shyti +Signed-off-by: Sasha Levin +--- + drivers/i2c/busses/i2c-at91-slave.c | 3 +-- + 1 file changed, 1 insertion(+), 2 deletions(-) + +diff --git a/drivers/i2c/busses/i2c-at91-slave.c b/drivers/i2c/busses/i2c-at91-slave.c +index d6eeea5166c04..131a67d9d4a68 100644 +--- a/drivers/i2c/busses/i2c-at91-slave.c ++++ b/drivers/i2c/busses/i2c-at91-slave.c +@@ -106,8 +106,7 @@ static int at91_unreg_slave(struct i2c_client *slave) + + static u32 at91_twi_func(struct i2c_adapter *adapter) + { +- return I2C_FUNC_SLAVE | I2C_FUNC_I2C | I2C_FUNC_SMBUS_EMUL +- | I2C_FUNC_SMBUS_READ_BLOCK_DATA; ++ return I2C_FUNC_SLAVE; + } + + static const struct i2c_algorithm at91_twi_algorithm_slave = { +-- +2.43.0 + diff --git a/queue-5.10/i2c-designware-fix-the-functionality-flags-of-the-sl.patch b/queue-5.10/i2c-designware-fix-the-functionality-flags-of-the-sl.patch new file mode 100644 index 00000000000..1ff3e3e7cd5 --- /dev/null +++ b/queue-5.10/i2c-designware-fix-the-functionality-flags-of-the-sl.patch @@ -0,0 +1,46 @@ +From 6f6e8de658eee22b1db29c983b0a8abf8b7f7fb6 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Fri, 31 May 2024 11:17:48 +0200 +Subject: i2c: designware: Fix the functionality flags of the slave-only + interface + +From: Jean Delvare + +[ Upstream commit cbf3fb5b29e99e3689d63a88c3cddbffa1b8de99 ] + +When an I2C adapter acts only as a slave, it should not claim to +support I2C master capabilities. + +Fixes: 5b6d721b266a ("i2c: designware: enable SLAVE in platform module") +Signed-off-by: Jean Delvare +Cc: Luis Oliveira +Cc: Jarkko Nikula +Cc: Andy Shevchenko +Cc: Mika Westerberg +Cc: Jan Dabros +Cc: Andi Shyti +Reviewed-by: Andy Shevchenko +Acked-by: Jarkko Nikula +Tested-by: Jarkko Nikula +Signed-off-by: Andi Shyti +Signed-off-by: Sasha Levin +--- + drivers/i2c/busses/i2c-designware-slave.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/drivers/i2c/busses/i2c-designware-slave.c b/drivers/i2c/busses/i2c-designware-slave.c +index 0d15f4c1e9f7e..5b54a9b9ed1a3 100644 +--- a/drivers/i2c/busses/i2c-designware-slave.c ++++ b/drivers/i2c/busses/i2c-designware-slave.c +@@ -232,7 +232,7 @@ static const struct i2c_algorithm i2c_dw_algo = { + + void i2c_dw_configure_slave(struct dw_i2c_dev *dev) + { +- dev->functionality = I2C_FUNC_SLAVE | DW_IC_DEFAULT_FUNCTIONALITY; ++ dev->functionality = I2C_FUNC_SLAVE; + + dev->slave_cfg = DW_IC_CON_RX_FIFO_FULL_HLD_CTRL | + DW_IC_CON_RESTART_EN | DW_IC_CON_STOP_DET_IFADDRESSED; +-- +2.43.0 + diff --git a/queue-5.10/perf-x86-avoid-tif_ia32-when-checking-64bit-mode.patch b/queue-5.10/perf-x86-avoid-tif_ia32-when-checking-64bit-mode.patch new file mode 100644 index 00000000000..1d54ab5418b --- /dev/null +++ b/queue-5.10/perf-x86-avoid-tif_ia32-when-checking-64bit-mode.patch @@ -0,0 +1,82 @@ +From 1757c2e8b089fd9dccf96b0e0cdf34c8600d7da6 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Sat, 3 Oct 2020 23:25:27 -0400 +Subject: perf/x86: Avoid TIF_IA32 when checking 64bit mode + +From: Gabriel Krisman Bertazi + +[ Upstream commit 375d4bfda57392f0865dae051e1c4bd2700e8d71 ] + +In preparation to remove TIF_IA32, stop using it in perf events code. + +Tested by running perf on 32-bit, 64-bit and x32 applications. + +Suggested-by: Andy Lutomirski +Signed-off-by: Gabriel Krisman Bertazi +Signed-off-by: Thomas Gleixner +Acked-by: Peter Zijlstra (Intel) +Link: https://lore.kernel.org/r/20201004032536.1229030-2-krisman@collabora.com +Stable-dep-of: 7fea700e04bd ("zap_pid_ns_processes: clear TIF_NOTIFY_SIGNAL along with TIF_SIGPENDING") +Signed-off-by: Sasha Levin +--- + arch/x86/events/core.c | 2 +- + arch/x86/events/intel/ds.c | 2 +- + arch/x86/events/intel/lbr.c | 2 +- + arch/x86/kernel/perf_regs.c | 2 +- + 4 files changed, 4 insertions(+), 4 deletions(-) + +diff --git a/arch/x86/events/core.c b/arch/x86/events/core.c +index b79b9f21cbb3b..1cef0ceb6acb3 100644 +--- a/arch/x86/events/core.c ++++ b/arch/x86/events/core.c +@@ -2615,7 +2615,7 @@ perf_callchain_user32(struct pt_regs *regs, struct perf_callchain_entry_ctx *ent + struct stack_frame_ia32 frame; + const struct stack_frame_ia32 __user *fp; + +- if (!test_thread_flag(TIF_IA32)) ++ if (user_64bit_mode(regs)) + return 0; + + cs_base = get_segment_base(regs->cs); +diff --git a/arch/x86/events/intel/ds.c b/arch/x86/events/intel/ds.c +index 48f30ffef1f4b..64a847eead484 100644 +--- a/arch/x86/events/intel/ds.c ++++ b/arch/x86/events/intel/ds.c +@@ -1266,7 +1266,7 @@ static int intel_pmu_pebs_fixup_ip(struct pt_regs *regs) + old_to = to; + + #ifdef CONFIG_X86_64 +- is_64bit = kernel_ip(to) || !test_thread_flag(TIF_IA32); ++ is_64bit = kernel_ip(to) || any_64bit_mode(regs); + #endif + insn_init(&insn, kaddr, size, is_64bit); + insn_get_length(&insn); +diff --git a/arch/x86/events/intel/lbr.c b/arch/x86/events/intel/lbr.c +index 4b6c39c5facba..d93076c18c6ca 100644 +--- a/arch/x86/events/intel/lbr.c ++++ b/arch/x86/events/intel/lbr.c +@@ -1245,7 +1245,7 @@ static int branch_type(unsigned long from, unsigned long to, int abort) + * on 64-bit systems running 32-bit apps + */ + #ifdef CONFIG_X86_64 +- is64 = kernel_ip((unsigned long)addr) || !test_thread_flag(TIF_IA32); ++ is64 = kernel_ip((unsigned long)addr) || any_64bit_mode(current_pt_regs()); + #endif + insn_init(&insn, addr, bytes_read, is64); + insn_get_opcode(&insn); +diff --git a/arch/x86/kernel/perf_regs.c b/arch/x86/kernel/perf_regs.c +index f9e5352b3bef9..624703af80a19 100644 +--- a/arch/x86/kernel/perf_regs.c ++++ b/arch/x86/kernel/perf_regs.c +@@ -122,7 +122,7 @@ int perf_reg_validate(u64 mask) + + u64 perf_reg_abi(struct task_struct *task) + { +- if (test_tsk_thread_flag(task, TIF_IA32)) ++ if (!user_64bit_mode(task_pt_regs(task))) + return PERF_SAMPLE_REGS_ABI_32; + else + return PERF_SAMPLE_REGS_ABI_64; +-- +2.43.0 + diff --git a/queue-5.10/series b/queue-5.10/series index d8d1da69402..fc12ea72dde 100644 --- a/queue-5.10/series +++ b/queue-5.10/series @@ -121,3 +121,11 @@ mptcp-pm-inc-rmaddr-mib-counter-once-per-rm_addr-id.patch mptcp-pm-update-add_addr-counters-after-connect.patch remoteproc-k3-r5-jump-to-error-handling-labels-in-start-stop-errors.patch greybus-fix-use-after-free-bug-in-gb_interface_release-due-to-race-condition.patch +usb-storage-alauda-check-whether-the-media-is-initia.patch +i2c-at91-fix-the-functionality-flags-of-the-slave-on.patch +i2c-designware-fix-the-functionality-flags-of-the-sl.patch +perf-x86-avoid-tif_ia32-when-checking-64bit-mode.patch +x86-compat-simplify-compat-syscall-userspace-allocat.patch +x86-elf-use-e_machine-to-select-start_thread-for-x32.patch +x86-mm-convert-mmu-context-ia32_compat-into-a-proper.patch +zap_pid_ns_processes-clear-tif_notify_signal-along-w.patch diff --git a/queue-5.10/usb-storage-alauda-check-whether-the-media-is-initia.patch b/queue-5.10/usb-storage-alauda-check-whether-the-media-is-initia.patch new file mode 100644 index 00000000000..efe44fe8775 --- /dev/null +++ b/queue-5.10/usb-storage-alauda-check-whether-the-media-is-initia.patch @@ -0,0 +1,61 @@ +From a62bad31a11723fa84b40c67f31e9a73ef3b2dd5 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Sun, 26 May 2024 09:27:45 +0800 +Subject: usb-storage: alauda: Check whether the media is initialized + +From: Shichao Lai + +[ Upstream commit 16637fea001ab3c8df528a8995b3211906165a30 ] + +The member "uzonesize" of struct alauda_info will remain 0 +if alauda_init_media() fails, potentially causing divide errors +in alauda_read_data() and alauda_write_lba(). +- Add a member "media_initialized" to struct alauda_info. +- Change a condition in alauda_check_media() to ensure the + first initialization. +- Add an error check for the return value of alauda_init_media(). + +Fixes: e80b0fade09e ("[PATCH] USB Storage: add alauda support") +Reported-by: xingwei lee +Reported-by: yue sun +Reviewed-by: Alan Stern +Signed-off-by: Shichao Lai +Link: https://lore.kernel.org/r/20240526012745.2852061-1-shichaorai@gmail.com +Signed-off-by: Greg Kroah-Hartman +Signed-off-by: Sasha Levin +--- + drivers/usb/storage/alauda.c | 9 ++++++--- + 1 file changed, 6 insertions(+), 3 deletions(-) + +diff --git a/drivers/usb/storage/alauda.c b/drivers/usb/storage/alauda.c +index dcc4778d1ae99..17fe35083f048 100644 +--- a/drivers/usb/storage/alauda.c ++++ b/drivers/usb/storage/alauda.c +@@ -105,6 +105,8 @@ struct alauda_info { + unsigned char sense_key; + unsigned long sense_asc; /* additional sense code */ + unsigned long sense_ascq; /* additional sense code qualifier */ ++ ++ bool media_initialized; + }; + + #define short_pack(lsb,msb) ( ((u16)(lsb)) | ( ((u16)(msb))<<8 ) ) +@@ -476,11 +478,12 @@ static int alauda_check_media(struct us_data *us) + } + + /* Check for media change */ +- if (status[0] & 0x08) { ++ if (status[0] & 0x08 || !info->media_initialized) { + usb_stor_dbg(us, "Media change detected\n"); + alauda_free_maps(&MEDIA_INFO(us)); +- alauda_init_media(us); +- ++ rc = alauda_init_media(us); ++ if (rc == USB_STOR_TRANSPORT_GOOD) ++ info->media_initialized = true; + info->sense_key = UNIT_ATTENTION; + info->sense_asc = 0x28; + info->sense_ascq = 0x00; +-- +2.43.0 + diff --git a/queue-5.10/x86-compat-simplify-compat-syscall-userspace-allocat.patch b/queue-5.10/x86-compat-simplify-compat-syscall-userspace-allocat.patch new file mode 100644 index 00000000000..b42d2aa28df --- /dev/null +++ b/queue-5.10/x86-compat-simplify-compat-syscall-userspace-allocat.patch @@ -0,0 +1,53 @@ +From 48a9fc8b13722c354335c399cd8de298acb5b0df Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Sat, 3 Oct 2020 23:25:28 -0400 +Subject: x86/compat: Simplify compat syscall userspace allocation + +From: Gabriel Krisman Bertazi + +[ Upstream commit 214f0e804358cdd13b5cbe4445189f23e30618b4 ] + +When allocating user memory space for a compat system call, don't consider +whether the originating code is IA32 or X32, just allocate from a safe +region for both, beyond the redzone. This should be safe for IA32, and has +the benefit of avoiding TIF_IA32, which is about to be removed. + +Suggested-by: Andy Lutomirski +Signed-off-by: Gabriel Krisman Bertazi +Signed-off-by: Thomas Gleixner +Link: https://lore.kernel.org/r/20201004032536.1229030-3-krisman@collabora.com +Stable-dep-of: 7fea700e04bd ("zap_pid_ns_processes: clear TIF_NOTIFY_SIGNAL along with TIF_SIGPENDING") +Signed-off-by: Sasha Levin +--- + arch/x86/include/asm/compat.h | 15 +++++++-------- + 1 file changed, 7 insertions(+), 8 deletions(-) + +diff --git a/arch/x86/include/asm/compat.h b/arch/x86/include/asm/compat.h +index 46a067bd7e0ba..8f7af1f890406 100644 +--- a/arch/x86/include/asm/compat.h ++++ b/arch/x86/include/asm/compat.h +@@ -175,14 +175,13 @@ typedef struct user_regs_struct compat_elf_gregset_t; + + static inline void __user *arch_compat_alloc_user_space(long len) + { +- compat_uptr_t sp; +- +- if (test_thread_flag(TIF_IA32)) { +- sp = task_pt_regs(current)->sp; +- } else { +- /* -128 for the x32 ABI redzone */ +- sp = task_pt_regs(current)->sp - 128; +- } ++ compat_uptr_t sp = task_pt_regs(current)->sp; ++ ++ /* ++ * -128 for the x32 ABI redzone. For IA32, it is not strictly ++ * necessary, but not harmful. ++ */ ++ sp -= 128; + + return (void __user *)round_down(sp - len, 16); + } +-- +2.43.0 + diff --git a/queue-5.10/x86-elf-use-e_machine-to-select-start_thread-for-x32.patch b/queue-5.10/x86-elf-use-e_machine-to-select-start_thread-for-x32.patch new file mode 100644 index 00000000000..e7ac44e7860 --- /dev/null +++ b/queue-5.10/x86-elf-use-e_machine-to-select-start_thread-for-x32.patch @@ -0,0 +1,65 @@ +From b3fe0ecd86fb80ade5819a9271716fe1e04e9b1c Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Sat, 3 Oct 2020 23:25:32 -0400 +Subject: x86/elf: Use e_machine to select start_thread for x32 + +From: Gabriel Krisman Bertazi + +[ Upstream commit 2424b14605c71a7187c14edd525044eb36bdea47 ] + +Since TIF_X32 is going away, avoid using it to find the ELF type in +compat_start_thread. + +According to SysV AMD64 ABI Draft, an AMD64 ELF object using ILP32 must +have ELFCLASS32 with (E_MACHINE == EM_X86_64), so use that ELF field to +differentiate a x32 object from a IA32 object when executing start_thread() +in compat mode. + +Signed-off-by: Gabriel Krisman Bertazi +Signed-off-by: Thomas Gleixner +Reviewed-by: Andy Lutomirski +Link: https://lore.kernel.org/r/20201004032536.1229030-7-krisman@collabora.com +Stable-dep-of: 7fea700e04bd ("zap_pid_ns_processes: clear TIF_NOTIFY_SIGNAL along with TIF_SIGPENDING") +Signed-off-by: Sasha Levin +--- + arch/x86/include/asm/elf.h | 5 +++-- + arch/x86/kernel/process_64.c | 5 ++--- + 2 files changed, 5 insertions(+), 5 deletions(-) + +diff --git a/arch/x86/include/asm/elf.h b/arch/x86/include/asm/elf.h +index b9a5d488f1a5e..b7e3fa0dcd970 100644 +--- a/arch/x86/include/asm/elf.h ++++ b/arch/x86/include/asm/elf.h +@@ -186,8 +186,9 @@ static inline void elf_common_init(struct thread_struct *t, + #define COMPAT_ELF_PLAT_INIT(regs, load_addr) \ + elf_common_init(¤t->thread, regs, __USER_DS) + +-void compat_start_thread(struct pt_regs *regs, u32 new_ip, u32 new_sp); +-#define compat_start_thread compat_start_thread ++void compat_start_thread(struct pt_regs *regs, u32 new_ip, u32 new_sp, bool x32); ++#define COMPAT_START_THREAD(ex, regs, new_ip, new_sp) \ ++ compat_start_thread(regs, new_ip, new_sp, ex->e_machine == EM_X86_64) + + void set_personality_ia32(bool); + #define COMPAT_SET_PERSONALITY(ex) \ +diff --git a/arch/x86/kernel/process_64.c b/arch/x86/kernel/process_64.c +index 1d8bc4736fb79..997d6556f4be8 100644 +--- a/arch/x86/kernel/process_64.c ++++ b/arch/x86/kernel/process_64.c +@@ -511,11 +511,10 @@ start_thread(struct pt_regs *regs, unsigned long new_ip, unsigned long new_sp) + EXPORT_SYMBOL_GPL(start_thread); + + #ifdef CONFIG_COMPAT +-void compat_start_thread(struct pt_regs *regs, u32 new_ip, u32 new_sp) ++void compat_start_thread(struct pt_regs *regs, u32 new_ip, u32 new_sp, bool x32) + { + start_thread_common(regs, new_ip, new_sp, +- test_thread_flag(TIF_X32) +- ? __USER_CS : __USER32_CS, ++ x32 ? __USER_CS : __USER32_CS, + __USER_DS, __USER_DS); + } + #endif +-- +2.43.0 + diff --git a/queue-5.10/x86-mm-convert-mmu-context-ia32_compat-into-a-proper.patch b/queue-5.10/x86-mm-convert-mmu-context-ia32_compat-into-a-proper.patch new file mode 100644 index 00000000000..646d0ffa24f --- /dev/null +++ b/queue-5.10/x86-mm-convert-mmu-context-ia32_compat-into-a-proper.patch @@ -0,0 +1,137 @@ +From 1e6677766e249d2c21c8a5afde8e7dbb7da4cf70 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Sat, 3 Oct 2020 23:25:35 -0400 +Subject: x86/mm: Convert mmu context ia32_compat into a proper flags field + +From: Gabriel Krisman Bertazi + +[ Upstream commit ff170cd0595398a7b66cb40f249eb2f10c29b66d ] + +The ia32_compat attribute is a weird thing. It mirrors TIF_IA32 and +TIF_X32 and is used only in two very unrelated places: (1) to decide if +the vsyscall page is accessible (2) for uprobes to find whether the +patched instruction is 32 or 64 bit. + +In preparation to remove the TIF flags, a new mechanism is required for +ia32_compat, but given its odd semantics, adding a real flags field which +configures these specific behaviours is the best option. + +So, set_personality_x64() can ask for the vsyscall page, which is not +available in x32/ia32 and set_personality_ia32() can configure the uprobe +code as needed. + +uprobe cannot rely on other methods like user_64bit_mode() to decide how +to patch, so it needs some specific flag like this. + +Signed-off-by: Gabriel Krisman Bertazi +Signed-off-by: Thomas Gleixner +Acked-by: Andy Lutomirski +Link: https://lore.kernel.org/r/20201004032536.1229030-10-krisman@collabora.com +Stable-dep-of: 7fea700e04bd ("zap_pid_ns_processes: clear TIF_NOTIFY_SIGNAL along with TIF_SIGPENDING") +Signed-off-by: Sasha Levin +--- + arch/x86/entry/vsyscall/vsyscall_64.c | 2 +- + arch/x86/include/asm/mmu.h | 9 +++++++-- + arch/x86/include/asm/mmu_context.h | 2 +- + arch/x86/kernel/process_64.c | 17 +++++++++++------ + 4 files changed, 20 insertions(+), 10 deletions(-) + +diff --git a/arch/x86/entry/vsyscall/vsyscall_64.c b/arch/x86/entry/vsyscall/vsyscall_64.c +index f0b817eb6e8ba..c5d074f5627a4 100644 +--- a/arch/x86/entry/vsyscall/vsyscall_64.c ++++ b/arch/x86/entry/vsyscall/vsyscall_64.c +@@ -292,7 +292,7 @@ static struct vm_area_struct gate_vma __ro_after_init = { + struct vm_area_struct *get_gate_vma(struct mm_struct *mm) + { + #ifdef CONFIG_COMPAT +- if (!mm || mm->context.ia32_compat) ++ if (!mm || !(mm->context.flags & MM_CONTEXT_HAS_VSYSCALL)) + return NULL; + #endif + if (vsyscall_mode == NONE) +diff --git a/arch/x86/include/asm/mmu.h b/arch/x86/include/asm/mmu.h +index 9257667d13c5e..5d7494631ea95 100644 +--- a/arch/x86/include/asm/mmu.h ++++ b/arch/x86/include/asm/mmu.h +@@ -6,6 +6,12 @@ + #include + #include + #include ++#include ++ ++/* Uprobes on this MM assume 32-bit code */ ++#define MM_CONTEXT_UPROBE_IA32 BIT(0) ++/* vsyscall page is accessible on this MM */ ++#define MM_CONTEXT_HAS_VSYSCALL BIT(1) + + /* + * x86 has arch-specific MMU state beyond what lives in mm_struct. +@@ -33,8 +39,7 @@ typedef struct { + #endif + + #ifdef CONFIG_X86_64 +- /* True if mm supports a task running in 32 bit compatibility mode. */ +- unsigned short ia32_compat; ++ unsigned short flags; + #endif + + struct mutex lock; +diff --git a/arch/x86/include/asm/mmu_context.h b/arch/x86/include/asm/mmu_context.h +index d98016b837559..054a791573231 100644 +--- a/arch/x86/include/asm/mmu_context.h ++++ b/arch/x86/include/asm/mmu_context.h +@@ -177,7 +177,7 @@ static inline void arch_exit_mmap(struct mm_struct *mm) + static inline bool is_64bit_mm(struct mm_struct *mm) + { + return !IS_ENABLED(CONFIG_IA32_EMULATION) || +- !(mm->context.ia32_compat == TIF_IA32); ++ !(mm->context.flags & MM_CONTEXT_UPROBE_IA32); + } + #else + static inline bool is_64bit_mm(struct mm_struct *mm) +diff --git a/arch/x86/kernel/process_64.c b/arch/x86/kernel/process_64.c +index 997d6556f4be8..8546dfd8683fc 100644 +--- a/arch/x86/kernel/process_64.c ++++ b/arch/x86/kernel/process_64.c +@@ -644,10 +644,8 @@ void set_personality_64bit(void) + /* Pretend that this comes from a 64bit execve */ + task_pt_regs(current)->orig_ax = __NR_execve; + current_thread_info()->status &= ~TS_COMPAT; +- +- /* Ensure the corresponding mm is not marked. */ + if (current->mm) +- current->mm->context.ia32_compat = 0; ++ current->mm->context.flags = MM_CONTEXT_HAS_VSYSCALL; + + /* TBD: overwrites user setup. Should have two bits. + But 64bit processes have always behaved this way, +@@ -662,7 +660,8 @@ static void __set_personality_x32(void) + clear_thread_flag(TIF_IA32); + set_thread_flag(TIF_X32); + if (current->mm) +- current->mm->context.ia32_compat = TIF_X32; ++ current->mm->context.flags = 0; ++ + current->personality &= ~READ_IMPLIES_EXEC; + /* + * in_32bit_syscall() uses the presence of the x32 syscall bit +@@ -682,8 +681,14 @@ static void __set_personality_ia32(void) + #ifdef CONFIG_IA32_EMULATION + set_thread_flag(TIF_IA32); + clear_thread_flag(TIF_X32); +- if (current->mm) +- current->mm->context.ia32_compat = TIF_IA32; ++ if (current->mm) { ++ /* ++ * uprobes applied to this MM need to know this and ++ * cannot use user_64bit_mode() at that time. ++ */ ++ current->mm->context.flags = MM_CONTEXT_UPROBE_IA32; ++ } ++ + current->personality |= force_personality32; + /* Prepare the first "return" to user space */ + task_pt_regs(current)->orig_ax = __NR_ia32_execve; +-- +2.43.0 + diff --git a/queue-5.10/zap_pid_ns_processes-clear-tif_notify_signal-along-w.patch b/queue-5.10/zap_pid_ns_processes-clear-tif_notify_signal-along-w.patch new file mode 100644 index 00000000000..fe874d95384 --- /dev/null +++ b/queue-5.10/zap_pid_ns_processes-clear-tif_notify_signal-along-w.patch @@ -0,0 +1,61 @@ +From 7652995519e4b2c57053cd299d2e638ddb084172 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Sat, 8 Jun 2024 14:06:16 +0200 +Subject: zap_pid_ns_processes: clear TIF_NOTIFY_SIGNAL along with + TIF_SIGPENDING + +From: Oleg Nesterov + +[ Upstream commit 7fea700e04bd3f424c2d836e98425782f97b494e ] + +kernel_wait4() doesn't sleep and returns -EINTR if there is no +eligible child and signal_pending() is true. + +That is why zap_pid_ns_processes() clears TIF_SIGPENDING but this is not +enough, it should also clear TIF_NOTIFY_SIGNAL to make signal_pending() +return false and avoid a busy-wait loop. + +Link: https://lkml.kernel.org/r/20240608120616.GB7947@redhat.com +Fixes: 12db8b690010 ("entry: Add support for TIF_NOTIFY_SIGNAL") +Signed-off-by: Oleg Nesterov +Reported-by: Rachel Menge +Closes: https://lore.kernel.org/all/1386cd49-36d0-4a5c-85e9-bc42056a5a38@linux.microsoft.com/ +Reviewed-by: Boqun Feng +Tested-by: Wei Fu +Reviewed-by: Jens Axboe +Cc: Allen Pais +Cc: Christian Brauner +Cc: Frederic Weisbecker +Cc: Joel Fernandes (Google) +Cc: Joel Granados +Cc: Josh Triplett +Cc: Lai Jiangshan +Cc: Mateusz Guzik +Cc: Mathieu Desnoyers +Cc: Mike Christie +Cc: Neeraj Upadhyay +Cc: Paul E. McKenney +Cc: Steven Rostedt (Google) +Cc: Zqiang +Cc: Thomas Gleixner +Signed-off-by: Andrew Morton +Signed-off-by: Sasha Levin +--- + kernel/pid_namespace.c | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/kernel/pid_namespace.c b/kernel/pid_namespace.c +index 20243682e6056..e032b1ce79649 100644 +--- a/kernel/pid_namespace.c ++++ b/kernel/pid_namespace.c +@@ -221,6 +221,7 @@ void zap_pid_ns_processes(struct pid_namespace *pid_ns) + */ + do { + clear_thread_flag(TIF_SIGPENDING); ++ clear_thread_flag(TIF_NOTIFY_SIGNAL); + rc = kernel_wait4(-1, NULL, __WALL, NULL); + } while (rc != -ECHILD); + +-- +2.43.0 + -- 2.47.3