Skip to content

Commit ce18d17

Browse files
ctmarinastorvalds
authored andcommitted
mm: untag user pointers in mmap/munmap/mremap/brk
There isn't a good reason to differentiate between the user address space layout modification syscalls and the other memory permission/attributes ones (e.g. mprotect, madvise) w.r.t. the tagged address ABI. Untag the user addresses on entry to these functions. Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Catalin Marinas <[email protected]> Acked-by: Will Deacon <[email protected]> Acked-by: Andrey Konovalov <[email protected]> Cc: Vincenzo Frascino <[email protected]> Cc: Szabolcs Nagy <[email protected]> Cc: Kevin Brodsky <[email protected]> Cc: Dave P Martin <[email protected]> Cc: Dave Hansen <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent 6cf5354 commit ce18d17

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

mm/mmap.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,8 @@ SYSCALL_DEFINE1(brk, unsigned long, brk)
201201
bool downgraded = false;
202202
LIST_HEAD(uf);
203203

204+
brk = untagged_addr(brk);
205+
204206
if (down_write_killable(&mm->mmap_sem))
205207
return -EINTR;
206208

@@ -1587,6 +1589,8 @@ unsigned long ksys_mmap_pgoff(unsigned long addr, unsigned long len,
15871589
struct file *file = NULL;
15881590
unsigned long retval;
15891591

1592+
addr = untagged_addr(addr);
1593+
15901594
if (!(flags & MAP_ANONYMOUS)) {
15911595
audit_mmap_fd(fd, flags);
15921596
file = fget(fd);
@@ -2885,6 +2889,7 @@ EXPORT_SYMBOL(vm_munmap);
28852889

28862890
SYSCALL_DEFINE2(munmap, unsigned long, addr, size_t, len)
28872891
{
2892+
addr = untagged_addr(addr);
28882893
profile_munmap(addr);
28892894
return __vm_munmap(addr, len, true);
28902895
}

mm/mremap.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -606,12 +606,8 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,
606606
LIST_HEAD(uf_unmap_early);
607607
LIST_HEAD(uf_unmap);
608608

609-
/*
610-
* Architectures may interpret the tag passed to mmap as a background
611-
* colour for the corresponding vma. For mremap we don't allow tagged
612-
* new_addr to preserve similar behaviour to mmap.
613-
*/
614609
addr = untagged_addr(addr);
610+
new_addr = untagged_addr(new_addr);
615611

616612
if (flags & ~(MREMAP_FIXED | MREMAP_MAYMOVE))
617613
return ret;

0 commit comments

Comments
 (0)