Skip to content

Commit 194d6ad

Browse files
committed
Merge tag 'arm64-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux
Pull arm64 fixes from Will Deacon: - fix HugeTLB leak due to CoW and PTE_RDONLY mismatch - avoid accessing unmapped FDT fields when checking validity - correctly account for vDSO AUX entry in ARCH_DLINFO - fix kallsyms with absolute expressions in linker script - kill unnecessary symbol-based relocs in vmlinux * tag 'arm64-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux: arm64: Fix copy-on-write referencing in HugeTLB arm64: mm: avoid fdt_check_header() before the FDT is fully mapped arm64: Define AT_VECTOR_SIZE_ARCH for ARCH_DLINFO arm64: relocatable: suppress R_AARCH64_ABS64 relocations in vmlinux arm64: vmlinux.lds: make __rela_offset and __dynsym_offset ABSOLUTE
2 parents a157b3a + 747a70e commit 194d6ad

File tree

7 files changed

+30
-34
lines changed

7 files changed

+30
-34
lines changed

arch/arm64/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ CPPFLAGS_vmlinux.lds = -DTEXT_OFFSET=$(TEXT_OFFSET)
1515
GZFLAGS :=-9
1616

1717
ifneq ($(CONFIG_RELOCATABLE),)
18-
LDFLAGS_vmlinux += -pie
18+
LDFLAGS_vmlinux += -pie -Bsymbolic
1919
endif
2020

2121
KBUILD_DEFCONFIG := defconfig

arch/arm64/include/asm/elf.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ typedef struct user_fpsimd_state elf_fpregset_t;
140140

141141
#define SET_PERSONALITY(ex) clear_thread_flag(TIF_32BIT);
142142

143+
/* update AT_VECTOR_SIZE_ARCH if the number of NEW_AUX_ENT entries changes */
143144
#define ARCH_DLINFO \
144145
do { \
145146
NEW_AUX_ENT(AT_SYSINFO_EHDR, \

arch/arm64/include/asm/pgtable.h

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,23 @@ static inline void set_pte_at(struct mm_struct *mm, unsigned long addr,
224224
set_pte(ptep, pte);
225225
}
226226

227+
#define __HAVE_ARCH_PTE_SAME
228+
static inline int pte_same(pte_t pte_a, pte_t pte_b)
229+
{
230+
pteval_t lhs, rhs;
231+
232+
lhs = pte_val(pte_a);
233+
rhs = pte_val(pte_b);
234+
235+
if (pte_present(pte_a))
236+
lhs &= ~PTE_RDONLY;
237+
238+
if (pte_present(pte_b))
239+
rhs &= ~PTE_RDONLY;
240+
241+
return (lhs == rhs);
242+
}
243+
227244
/*
228245
* Huge pte definitions.
229246
*/

arch/arm64/include/uapi/asm/auxvec.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,6 @@
1919
/* vDSO location */
2020
#define AT_SYSINFO_EHDR 33
2121

22+
#define AT_VECTOR_SIZE_ARCH 1 /* entries in ARCH_DLINFO */
23+
2224
#endif

arch/arm64/kernel/head.S

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -781,40 +781,25 @@ __primary_switch:
781781
* Iterate over each entry in the relocation table, and apply the
782782
* relocations in place.
783783
*/
784-
ldr w8, =__dynsym_offset // offset to symbol table
785784
ldr w9, =__rela_offset // offset to reloc table
786785
ldr w10, =__rela_size // size of reloc table
787786

788787
mov_q x11, KIMAGE_VADDR // default virtual offset
789788
add x11, x11, x23 // actual virtual offset
790-
add x8, x8, x11 // __va(.dynsym)
791789
add x9, x9, x11 // __va(.rela)
792790
add x10, x9, x10 // __va(.rela) + sizeof(.rela)
793791

794792
0: cmp x9, x10
795-
b.hs 2f
793+
b.hs 1f
796794
ldp x11, x12, [x9], #24
797795
ldr x13, [x9, #-8]
798796
cmp w12, #R_AARCH64_RELATIVE
799-
b.ne 1f
797+
b.ne 0b
800798
add x13, x13, x23 // relocate
801799
str x13, [x11, x23]
802800
b 0b
803801

804-
1: cmp w12, #R_AARCH64_ABS64
805-
b.ne 0b
806-
add x12, x12, x12, lsl #1 // symtab offset: 24x top word
807-
add x12, x8, x12, lsr #(32 - 3) // ... shifted into bottom word
808-
ldrsh w14, [x12, #6] // Elf64_Sym::st_shndx
809-
ldr x15, [x12, #8] // Elf64_Sym::st_value
810-
cmp w14, #-0xf // SHN_ABS (0xfff1) ?
811-
add x14, x15, x23 // relocate
812-
csel x15, x14, x15, ne
813-
add x15, x13, x15
814-
str x15, [x11, x23]
815-
b 0b
816-
817-
2:
802+
1:
818803
#endif
819804
ldr x8, =__primary_switched
820805
br x8

arch/arm64/kernel/vmlinux.lds.S

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ SECTIONS
103103
*(.discard)
104104
*(.discard.*)
105105
*(.interp .dynamic)
106+
*(.dynsym .dynstr .hash)
106107
}
107108

108109
. = KIMAGE_VADDR + TEXT_OFFSET;
@@ -174,19 +175,9 @@ SECTIONS
174175
.rela : ALIGN(8) {
175176
*(.rela .rela*)
176177
}
177-
.dynsym : ALIGN(8) {
178-
*(.dynsym)
179-
}
180-
.dynstr : {
181-
*(.dynstr)
182-
}
183-
.hash : {
184-
*(.hash)
185-
}
186178

187-
__rela_offset = ADDR(.rela) - KIMAGE_VADDR;
179+
__rela_offset = ABSOLUTE(ADDR(.rela) - KIMAGE_VADDR);
188180
__rela_size = SIZEOF(.rela);
189-
__dynsym_offset = ADDR(.dynsym) - KIMAGE_VADDR;
190181

191182
. = ALIGN(SEGMENT_ALIGN);
192183
__init_end = .;

arch/arm64/mm/mmu.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -686,9 +686,9 @@ void *__init __fixmap_remap_fdt(phys_addr_t dt_phys, int *size, pgprot_t prot)
686686
/*
687687
* Check whether the physical FDT address is set and meets the minimum
688688
* alignment requirement. Since we are relying on MIN_FDT_ALIGN to be
689-
* at least 8 bytes so that we can always access the size field of the
690-
* FDT header after mapping the first chunk, double check here if that
691-
* is indeed the case.
689+
* at least 8 bytes so that we can always access the magic and size
690+
* fields of the FDT header after mapping the first chunk, double check
691+
* here if that is indeed the case.
692692
*/
693693
BUILD_BUG_ON(MIN_FDT_ALIGN < 8);
694694
if (!dt_phys || dt_phys % MIN_FDT_ALIGN)
@@ -716,7 +716,7 @@ void *__init __fixmap_remap_fdt(phys_addr_t dt_phys, int *size, pgprot_t prot)
716716
create_mapping_noalloc(round_down(dt_phys, SWAPPER_BLOCK_SIZE),
717717
dt_virt_base, SWAPPER_BLOCK_SIZE, prot);
718718

719-
if (fdt_check_header(dt_virt) != 0)
719+
if (fdt_magic(dt_virt) != FDT_MAGIC)
720720
return NULL;
721721

722722
*size = fdt_totalsize(dt_virt);

0 commit comments

Comments
 (0)