hc
2024-05-10 37f49e37ab4cb5d0bc4c60eb5c6d4dd57db767bb
kernel/arch/arm/kernel/process.c
....@@ -1,12 +1,9 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * linux/arch/arm/kernel/process.c
34 *
45 * Copyright (C) 1996-2000 Russell King - Converted to ARM.
56 * Original Copyright (C) 1995 Linus Torvalds
6
- *
7
- * This program is free software; you can redistribute it and/or modify
8
- * it under the terms of the GNU General Public License version 2 as
9
- * published by the Free Software Foundation.
107 */
118 #include <stdarg.h>
129
....@@ -39,7 +36,9 @@
3936 #include <asm/tls.h>
4037 #include <asm/vdso.h>
4138
42
-#ifdef CONFIG_STACKPROTECTOR
39
+#include "signal.h"
40
+
41
+#if defined(CONFIG_STACKPROTECTOR) && !defined(CONFIG_STACKPROTECTOR_PER_TASK)
4342 #include <linux/stackprotector.h>
4443 unsigned long __stack_chk_guard __read_mostly;
4544 EXPORT_SYMBOL(__stack_chk_guard);
....@@ -72,7 +71,7 @@
7271 arm_pm_idle();
7372 else
7473 cpu_do_idle();
75
- local_irq_enable();
74
+ raw_local_irq_enable();
7675 }
7776
7877 void arch_cpu_idle_prepare(void)
....@@ -93,77 +92,6 @@
9392 {
9493 ledtrig_cpu(CPU_LED_IDLE_END);
9594 idle_notifier_call_chain(IDLE_END);
96
-}
97
-
98
-/*
99
- * dump a block of kernel memory from around the given address
100
- */
101
-static void show_data(unsigned long addr, int nbytes, const char *name)
102
-{
103
- int i, j;
104
- int nlines;
105
- u32 *p;
106
-
107
- /*
108
- * don't attempt to dump non-kernel addresses or
109
- * values that are probably just small negative numbers
110
- */
111
- if (addr < PAGE_OFFSET || addr > -256UL)
112
- return;
113
-
114
- printk("\n%s: %#lx:\n", name, addr);
115
-
116
- /*
117
- * round address down to a 32 bit boundary
118
- * and always dump a multiple of 32 bytes
119
- */
120
- p = (u32 *)(addr & ~(sizeof(u32) - 1));
121
- nbytes += (addr & (sizeof(u32) - 1));
122
- nlines = (nbytes + 31) / 32;
123
-
124
-
125
- for (i = 0; i < nlines; i++) {
126
- /*
127
- * just display low 16 bits of address to keep
128
- * each line of the dump < 80 characters
129
- */
130
- printk("%04lx ", (unsigned long)p & 0xffff);
131
- for (j = 0; j < 8; j++) {
132
- u32 data;
133
- if (probe_kernel_address(p, data)) {
134
- pr_cont(" ********");
135
- } else {
136
- pr_cont(" %08x", data);
137
- }
138
- ++p;
139
- }
140
- pr_cont("\n");
141
- }
142
-}
143
-
144
-static void show_extra_register_data(struct pt_regs *regs, int nbytes)
145
-{
146
- mm_segment_t fs;
147
-
148
- fs = get_fs();
149
- set_fs(KERNEL_DS);
150
- show_data(regs->ARM_pc - nbytes, nbytes * 2, "PC");
151
- show_data(regs->ARM_lr - nbytes, nbytes * 2, "LR");
152
- show_data(regs->ARM_sp - nbytes, nbytes * 2, "SP");
153
- show_data(regs->ARM_ip - nbytes, nbytes * 2, "IP");
154
- show_data(regs->ARM_fp - nbytes, nbytes * 2, "FP");
155
- show_data(regs->ARM_r0 - nbytes, nbytes * 2, "R0");
156
- show_data(regs->ARM_r1 - nbytes, nbytes * 2, "R1");
157
- show_data(regs->ARM_r2 - nbytes, nbytes * 2, "R2");
158
- show_data(regs->ARM_r3 - nbytes, nbytes * 2, "R3");
159
- show_data(regs->ARM_r4 - nbytes, nbytes * 2, "R4");
160
- show_data(regs->ARM_r5 - nbytes, nbytes * 2, "R5");
161
- show_data(regs->ARM_r6 - nbytes, nbytes * 2, "R6");
162
- show_data(regs->ARM_r7 - nbytes, nbytes * 2, "R7");
163
- show_data(regs->ARM_r8 - nbytes, nbytes * 2, "R8");
164
- show_data(regs->ARM_r9 - nbytes, nbytes * 2, "R9");
165
- show_data(regs->ARM_r10 - nbytes, nbytes * 2, "R10");
166
- set_fs(fs);
16795 }
16896
16997 void __show_regs(struct pt_regs *regs)
....@@ -223,7 +151,7 @@
223151 if ((domain & domain_mask(DOMAIN_USER)) ==
224152 domain_val(DOMAIN_USER, DOMAIN_NOACCESS))
225153 segment = "none";
226
- else if (fs == get_ds())
154
+ else if (fs == KERNEL_DS)
227155 segment = "kernel";
228156 else
229157 segment = "user";
....@@ -257,8 +185,6 @@
257185 printk("Control: %08x%s\n", ctrl, buf);
258186 }
259187 #endif
260
-
261
- show_extra_register_data(regs, 128);
262188 }
263189
264190 void show_regs(struct pt_regs * regs)
....@@ -301,9 +227,8 @@
301227
302228 asmlinkage void ret_from_fork(void) __asm__("ret_from_fork");
303229
304
-int
305
-copy_thread(unsigned long clone_flags, unsigned long stack_start,
306
- unsigned long stk_sz, struct task_struct *p)
230
+int copy_thread(unsigned long clone_flags, unsigned long stack_start,
231
+ unsigned long stk_sz, struct task_struct *p, unsigned long tls)
307232 {
308233 struct thread_info *thread = task_thread_info(p);
309234 struct pt_regs *childregs = task_pt_regs(p);
....@@ -320,7 +245,7 @@
320245 thread->cpu_domain = get_domain();
321246 #endif
322247
323
- if (likely(!(p->flags & PF_KTHREAD))) {
248
+ if (likely(!(p->flags & (PF_KTHREAD | PF_IO_WORKER)))) {
324249 *childregs = *current_pt_regs();
325250 childregs->ARM_r0 = 0;
326251 if (stack_start)
....@@ -337,10 +262,14 @@
337262 clear_ptrace_hw_breakpoint(p);
338263
339264 if (clone_flags & CLONE_SETTLS)
340
- thread->tp_value[0] = childregs->ARM_r3;
265
+ thread->tp_value[0] = tls;
341266 thread->tp_value[1] = get_tpuser();
342267
343268 thread_notify(THREAD_NOTIFY_COPY, thread);
269
+
270
+#ifdef CONFIG_STACKPROTECTOR_PER_TASK
271
+ thread->stack_canary = p->stack_canary;
272
+#endif
344273
345274 return 0;
346275 }
....@@ -353,21 +282,6 @@
353282 elf_core_copy_regs(elfregs, task_pt_regs(t));
354283 return 1;
355284 }
356
-
357
-/*
358
- * fill in the fpe structure for a core dump...
359
- */
360
-int dump_fpu (struct pt_regs *regs, struct user_fp *fp)
361
-{
362
- struct thread_info *thread = current_thread_info();
363
- int used_math = thread->used_cp[1] | thread->used_cp[2];
364
-
365
- if (used_math)
366
- memcpy(fp, &thread->fpstate.soft, sizeof (*fp));
367
-
368
- return used_math != 0;
369
-}
370
-EXPORT_SYMBOL(dump_fpu);
371285
372286 unsigned long get_wchan(struct task_struct *p)
373287 {
....@@ -391,11 +305,6 @@
391305 return frame.pc;
392306 } while (count ++ < 16);
393307 return 0;
394
-}
395
-
396
-unsigned long arch_randomize_brk(struct mm_struct *mm)
397
-{
398
- return randomize_page(mm->brk, 0x02000000);
399308 }
400309
401310 #ifdef CONFIG_MMU
....@@ -508,7 +417,7 @@
508417 npages = 1; /* for sigpage */
509418 npages += vdso_total_pages;
510419
511
- if (down_write_killable(&mm->mmap_sem))
420
+ if (mmap_write_lock_killable(mm))
512421 return -EINTR;
513422 hint = sigpage_addr(mm, npages);
514423 addr = get_unmapped_area(NULL, hint, npages << PAGE_SHIFT, 0, 0);
....@@ -535,7 +444,7 @@
535444 arm_install_vdso(mm, addr + PAGE_SIZE);
536445
537446 up_fail:
538
- up_write(&mm->mmap_sem);
447
+ mmap_write_unlock(mm);
539448 return ret;
540449 }
541450 #endif