Skip to content

Commit 0731824

Browse files
author
Alex Shi
committed
Merge branch 'v4.4/topic/mm-kaslr' into v4.4/topic/mm-kaslr-pax_usercopy
2 parents 1b4b2f1 + 5a54b72 commit 0731824

4 files changed

Lines changed: 19 additions & 23 deletions

File tree

arch/arm64/include/asm/module.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#define __ASM_MODULE_H
1818

1919
#include <asm-generic/module.h>
20+
#include <asm/memory.h>
2021

2122
#define MODULE_ARCH_VERMAGIC "aarch64"
2223

@@ -32,6 +33,10 @@ u64 module_emit_plt_entry(struct module *mod, const Elf64_Rela *rela,
3233
Elf64_Sym *sym);
3334

3435
#ifdef CONFIG_RANDOMIZE_BASE
36+
#ifdef CONFIG_MODVERSIONS
37+
#define ARCH_RELOCATES_KCRCTAB
38+
#define reloc_start (kimage_vaddr - KIMAGE_VADDR)
39+
#endif
3540
extern u64 module_alloc_base;
3641
#else
3742
#define module_alloc_base ((u64)_etext - MODULES_VSIZE)

arch/arm64/kernel/stacktrace.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ int notrace unwind_frame(struct task_struct *tsk, struct stackframe *frame)
4343
unsigned long fp = frame->fp;
4444
unsigned long irq_stack_ptr;
4545

46+
if (!tsk)
47+
tsk = current;
48+
4649
/*
4750
* Switching between stacks is valid when tracing current and in
4851
* non-preemptible context.
@@ -67,7 +70,7 @@ int notrace unwind_frame(struct task_struct *tsk, struct stackframe *frame)
6770
frame->pc = *(unsigned long *)(fp + 8);
6871

6972
#ifdef CONFIG_FUNCTION_GRAPH_TRACER
70-
if (tsk && tsk->ret_stack &&
73+
if (tsk->ret_stack &&
7174
(frame->pc == (unsigned long)return_to_handler)) {
7275
/*
7376
* This is a case where function graph tracer has

arch/arm64/kernel/traps.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,11 @@ static void dump_backtrace(struct pt_regs *regs, struct task_struct *tsk)
149149
unsigned long irq_stack_ptr;
150150
int skip;
151151

152+
pr_debug("%s(regs = %p tsk = %p)\n", __func__, regs, tsk);
153+
154+
if (!tsk)
155+
tsk = current;
156+
152157
/*
153158
* Switching between stacks is valid when tracing current and in
154159
* non-preemptible context.
@@ -158,11 +163,6 @@ static void dump_backtrace(struct pt_regs *regs, struct task_struct *tsk)
158163
else
159164
irq_stack_ptr = 0;
160165

161-
pr_debug("%s(regs = %p tsk = %p)\n", __func__, regs, tsk);
162-
163-
if (!tsk)
164-
tsk = current;
165-
166166
if (tsk == current) {
167167
frame.fp = (unsigned long)__builtin_frame_address(0);
168168
frame.sp = current_stack_pointer;

arch/arm64/mm/hugetlbpage.c

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -51,20 +51,8 @@ static int find_num_contig(struct mm_struct *mm, unsigned long addr,
5151
*pgsize = PAGE_SIZE;
5252
if (!pte_cont(pte))
5353
return 1;
54-
if (!pgd_present(*pgd)) {
55-
VM_BUG_ON(!pgd_present(*pgd));
56-
return 1;
57-
}
5854
pud = pud_offset(pgd, addr);
59-
if (!pud_present(*pud)) {
60-
VM_BUG_ON(!pud_present(*pud));
61-
return 1;
62-
}
6355
pmd = pmd_offset(pud, addr);
64-
if (!pmd_present(*pmd)) {
65-
VM_BUG_ON(!pmd_present(*pmd));
66-
return 1;
67-
}
6856
if ((pte_t *)pmd == ptep) {
6957
*pgsize = PMD_SIZE;
7058
return CONT_PMDS;
@@ -212,7 +200,7 @@ pte_t huge_ptep_get_and_clear(struct mm_struct *mm,
212200
ncontig = find_num_contig(mm, addr, cpte, *cpte, &pgsize);
213201
/* save the 1st pte to return */
214202
pte = ptep_get_and_clear(mm, addr, cpte);
215-
for (i = 1; i < ncontig; ++i) {
203+
for (i = 1, addr += pgsize; i < ncontig; ++i, addr += pgsize) {
216204
/*
217205
* If HW_AFDBM is enabled, then the HW could
218206
* turn on the dirty bit for any of the page
@@ -250,8 +238,8 @@ int huge_ptep_set_access_flags(struct vm_area_struct *vma,
250238
pfn = pte_pfn(*cpte);
251239
ncontig = find_num_contig(vma->vm_mm, addr, cpte,
252240
*cpte, &pgsize);
253-
for (i = 0; i < ncontig; ++i, ++cpte) {
254-
changed = ptep_set_access_flags(vma, addr, cpte,
241+
for (i = 0; i < ncontig; ++i, ++cpte, addr += pgsize) {
242+
changed |= ptep_set_access_flags(vma, addr, cpte,
255243
pfn_pte(pfn,
256244
hugeprot),
257245
dirty);
@@ -273,7 +261,7 @@ void huge_ptep_set_wrprotect(struct mm_struct *mm,
273261

274262
cpte = huge_pte_offset(mm, addr);
275263
ncontig = find_num_contig(mm, addr, cpte, *cpte, &pgsize);
276-
for (i = 0; i < ncontig; ++i, ++cpte)
264+
for (i = 0; i < ncontig; ++i, ++cpte, addr += pgsize)
277265
ptep_set_wrprotect(mm, addr, cpte);
278266
} else {
279267
ptep_set_wrprotect(mm, addr, ptep);
@@ -291,7 +279,7 @@ void huge_ptep_clear_flush(struct vm_area_struct *vma,
291279
cpte = huge_pte_offset(vma->vm_mm, addr);
292280
ncontig = find_num_contig(vma->vm_mm, addr, cpte,
293281
*cpte, &pgsize);
294-
for (i = 0; i < ncontig; ++i, ++cpte)
282+
for (i = 0; i < ncontig; ++i, ++cpte, addr += pgsize)
295283
ptep_clear_flush(vma, addr, cpte);
296284
} else {
297285
ptep_clear_flush(vma, addr, ptep);

0 commit comments

Comments
 (0)