History

Merge tag 'arm64-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux

Pull arm64 fixes from Will Deacon: "It's all straightforward apart from the changes to mmap()/mremap() in relation to their handling of address arguments from userspace with non-zero tag bits in the upper byte. The change to brk() is necessary to fix a nasty user-visible regression in malloc(), but we tightened up mmap() and mremap() at the same time because they also allow the user to create virtual aliases by accident. It's much less likely than brk() to matter in practice, but enforcing the principle of "don't permit the creation of mappings using tagged addresses" leads to a straightforward ABI without having to worry about the "but what if a crazy program did foo?" aspect of things. Summary: - Fix regression in malloc() caused by ignored address tags in brk() - Add missing brackets around argument to untagged_addr() macro - Fix clang build when using binutils assembler - Fix silly typo in virtual memory map documentation" * tag 'arm64-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux: mm: Avoid creating virtual address aliases in brk()/mmap()/mremap() docs: arm64: fix trivial spelling enought to enough in memory.rst arm64: memory: Add missing brackets to untagged_addr() macro arm64: lse: Fix LSE atomics with LLVM

Linus Torvalds committed 6 years ago

Commit 63f01d82 parents 2865936 dcde2376 files · +12 −10Browse files

Unified · Split

6 files
  1. Documentation/arm64/memory.rst +1 −1
  2. Documentation/arm64/tagged-address-abi.rst +9 −2
  3. arch/arm64/include/asm/lse.h +1 −1
  4. arch/arm64/include/asm/memory.h +1 −1
  5. mm/mmap.c +0 −4
  6. mm/mremap.c +0 −1
Documentation/arm64/memory.rst+1−1
@@ -129,7 +129,7 @@ this logic. · 128 unmodified lines
129 129
130As a single binary will need to support both 48-bit and 52-bit VA130As a single binary will need to support both 48-bit and 52-bit VA
131spaces, the VMEMMAP must be sized large enough for 52-bit VAs and131spaces, the VMEMMAP must be sized large enough for 52-bit VAs and
132also must be sized large enought to accommodate a fixed PAGE_OFFSET.132also must be sized large enough to accommodate a fixed PAGE_OFFSET.
133 133
134Most code in the kernel should not need to consider the VA_BITS, for134Most code in the kernel should not need to consider the VA_BITS, for
135code that does need to know the VA size the variables are135code that does need to know the VA size the variables are
Documentation/arm64/tagged-address-abi.rst+9−2
@@ -44,8 +44,15 @@ The AArch64 Tagged Address ABI has two stages of relaxation depending · 43 unmodified lines
44how the user addresses are used by the kernel:44how the user addresses are used by the kernel:
45 45
461. User addresses not accessed by the kernel but used for address space461. User addresses not accessed by the kernel but used for address space
47 management (e.g. ``mmap()``, ``mprotect()``, ``madvise()``). The use47 management (e.g. ``mprotect()``, ``madvise()``). The use of valid
48 of valid tagged pointers in this context is always allowed.48 tagged pointers in this context is allowed with the exception of
49 ``brk()``, ``mmap()`` and the ``new_address`` argument to
50 ``mremap()`` as these have the potential to alias with existing
51 user addresses.
52
53 NOTE: This behaviour changed in v5.6 and so some earlier kernels may
54 incorrectly accept valid tagged pointers for the ``brk()``,
55 ``mmap()`` and ``mremap()`` system calls.
49 56
502. User addresses accessed by the kernel (e.g. ``write()``). This ABI572. User addresses accessed by the kernel (e.g. ``write()``). This ABI
51 relaxation is disabled by default and the application thread needs to58 relaxation is disabled by default and the application thread needs to
arch/arm64/include/asm/lse.h+1−1
@@ -6,7 +6,7 @@ · 5 unmodified lines
6 6
7#ifdef CONFIG_ARM64_LSE_ATOMICS7#ifdef CONFIG_ARM64_LSE_ATOMICS
8 8
9#define __LSE_PREAMBLE ".arch armv8-a+lse\n"9#define __LSE_PREAMBLE ".arch_extension lse\n"
10 10
11#include <linux/compiler_types.h>11#include <linux/compiler_types.h>
12#include <linux/export.h>12#include <linux/export.h>
arch/arm64/include/asm/memory.h+1−1
@@ -213,7 +213,7 @@ static inline unsigned long kaslr_offset(void) · 212 unmodified lines
213 ((__force __typeof__(addr))sign_extend64((__force u64)(addr), 55))213 ((__force __typeof__(addr))sign_extend64((__force u64)(addr), 55))
214 214
215#define untagged_addr(addr) ({ \215#define untagged_addr(addr) ({ \
216 u64 __addr = (__force u64)addr; \216 u64 __addr = (__force u64)(addr); \
217 __addr &= __untagged_addr(__addr); \217 __addr &= __untagged_addr(__addr); \
218 (__force __typeof__(addr))__addr; \218 (__force __typeof__(addr))__addr; \
219})219})
mm/mmap.c+0−4
@@ -195,8 +195,6 @@ SYSCALL_DEFINE1(brk, unsigned long, brk) · 194 unmodified lines
195 bool downgraded = false;195 bool downgraded = false;
196 LIST_HEAD(uf);196 LIST_HEAD(uf);
197 197
198 brk = untagged_addr(brk);
199
200 if (down_write_killable(&mm->mmap_sem))198 if (down_write_killable(&mm->mmap_sem))
201 return -EINTR;199 return -EINTR;
202 200
@@ -1557,8 +1555,6 @@ unsigned long ksys_mmap_pgoff(unsigned long addr, unsigned long len, · 1354 unmodified lines
1557 struct file *file = NULL;1555 struct file *file = NULL;
1558 unsigned long retval;1556 unsigned long retval;
1559 1557
1560 addr = untagged_addr(addr);
1561
1562 if (!(flags & MAP_ANONYMOUS)) {1558 if (!(flags & MAP_ANONYMOUS)) {
1563 audit_mmap_fd(fd, flags);1559 audit_mmap_fd(fd, flags);
1564 file = fget(fd);1560 file = fget(fd);
mm/mremap.c+0−1
@@ -607,7 +607,6 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len, · 606 unmodified lines
607 LIST_HEAD(uf_unmap);607 LIST_HEAD(uf_unmap);
608 608
609 addr = untagged_addr(addr);609 addr = untagged_addr(addr);
610 new_addr = untagged_addr(new_addr);
611 610
612 if (flags & ~(MREMAP_FIXED | MREMAP_MAYMOVE))611 if (flags & ~(MREMAP_FIXED | MREMAP_MAYMOVE))
613 return ret;612 return ret;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t