diff options
author | Will Deacon <will@kernel.org> | 2020-03-25 11:13:46 +0000 |
---|---|---|
committer | Catalin Marinas <catalin.marinas@arm.com> | 2020-03-26 11:28:57 +0000 |
commit | b2a84de2a2deb76a6a51609845341f508c518c03 (patch) | |
tree | 4a15584ff90c52f6b69f1b930f9dcbf90fa4cc75 /mm/mremap.c | |
parent | 44ca0e00b6a05ea9cf89d8a5290a225de19f4a2a (diff) | |
download | linux-stable-b2a84de2a2deb76a6a51609845341f508c518c03.tar.gz linux-stable-b2a84de2a2deb76a6a51609845341f508c518c03.tar.bz2 linux-stable-b2a84de2a2deb76a6a51609845341f508c518c03.zip |
mm/mremap: Add comment explaining the untagging behaviour of mremap()
Commit dcde237319e6 ("mm: Avoid creating virtual address aliases in
brk()/mmap()/mremap()") changed mremap() so that only the 'old' address
is untagged, leaving the 'new' address in the form it was passed from
userspace. This prevents the unexpected creation of aliasing virtual
mappings in userspace, but looks a bit odd when you read the code.
Add a comment justifying the untagging behaviour in mremap().
Reported-by: Linus Torvalds <torvalds@linux-foundation.org>
Acked-by: Linus Torvalds <torvalds@linux-foundation.org>
Reviewed-by: Catalin Marinas <catalin.marinas@arm.com>
Signed-off-by: Will Deacon <will@kernel.org>
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
Diffstat (limited to 'mm/mremap.c')
-rw-r--r-- | mm/mremap.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/mm/mremap.c b/mm/mremap.c index af363063ea23..d28f08a36b96 100644 --- a/mm/mremap.c +++ b/mm/mremap.c @@ -606,6 +606,16 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len, LIST_HEAD(uf_unmap_early); LIST_HEAD(uf_unmap); + /* + * There is a deliberate asymmetry here: we strip the pointer tag + * from the old address but leave the new address alone. This is + * for consistency with mmap(), where we prevent the creation of + * aliasing mappings in userspace by leaving the tag bits of the + * mapping address intact. A non-zero tag will cause the subsequent + * range checks to reject the address as invalid. + * + * See Documentation/arm64/tagged-address-abi.rst for more information. + */ addr = untagged_addr(addr); if (flags & ~(MREMAP_FIXED | MREMAP_MAYMOVE)) |