diff options
author | Christoph Hellwig <hch@lst.de> | 2019-07-16 19:26:27 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2019-07-16 22:23:21 -0400 |
commit | 0bf5f9492389aa8df5c8e38fcb4488802d24504d (patch) | |
tree | 9c62b75ac595ca7dd1c0e25261c9a1ad08fb69f0 | |
parent | c633324e311243586675e732249339685e5d6faa (diff) |
mm: fix the MAP_UNINITIALIZED flag
We can't expose UAPI symbols differently based on CONFIG_ symbols, as
userspace won't have them available. Instead always define the flag,
but only respect it based on the config option.
Link: http://lkml.kernel.org/r/20190703122359.18200-2-hch@lst.de
Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Vladimir Murzin <vladimir.murzin@arm.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r-- | arch/xtensa/include/uapi/asm/mman.h | 6 | ||||
-rw-r--r-- | include/uapi/asm-generic/mman-common.h | 8 | ||||
-rw-r--r-- | mm/nommu.c | 4 |
3 files changed, 7 insertions, 11 deletions
diff --git a/arch/xtensa/include/uapi/asm/mman.h b/arch/xtensa/include/uapi/asm/mman.h index be726062412b..ebbb48842190 100644 --- a/arch/xtensa/include/uapi/asm/mman.h +++ b/arch/xtensa/include/uapi/asm/mman.h | |||
@@ -56,12 +56,8 @@ | |||
56 | #define MAP_STACK 0x40000 /* give out an address that is best suited for process/thread stacks */ | 56 | #define MAP_STACK 0x40000 /* give out an address that is best suited for process/thread stacks */ |
57 | #define MAP_HUGETLB 0x80000 /* create a huge page mapping */ | 57 | #define MAP_HUGETLB 0x80000 /* create a huge page mapping */ |
58 | #define MAP_FIXED_NOREPLACE 0x100000 /* MAP_FIXED which doesn't unmap underlying mapping */ | 58 | #define MAP_FIXED_NOREPLACE 0x100000 /* MAP_FIXED which doesn't unmap underlying mapping */ |
59 | #ifdef CONFIG_MMAP_ALLOW_UNINITIALIZED | 59 | #define MAP_UNINITIALIZED 0x4000000 /* For anonymous mmap, memory could be |
60 | # define MAP_UNINITIALIZED 0x4000000 /* For anonymous mmap, memory could be | ||
61 | * uninitialized */ | 60 | * uninitialized */ |
62 | #else | ||
63 | # define MAP_UNINITIALIZED 0x0 /* Don't support this flag */ | ||
64 | #endif | ||
65 | 61 | ||
66 | /* | 62 | /* |
67 | * Flags for msync | 63 | * Flags for msync |
diff --git a/include/uapi/asm-generic/mman-common.h b/include/uapi/asm-generic/mman-common.h index abd238d0f7a4..cb556b430e71 100644 --- a/include/uapi/asm-generic/mman-common.h +++ b/include/uapi/asm-generic/mman-common.h | |||
@@ -19,15 +19,13 @@ | |||
19 | #define MAP_TYPE 0x0f /* Mask for type of mapping */ | 19 | #define MAP_TYPE 0x0f /* Mask for type of mapping */ |
20 | #define MAP_FIXED 0x10 /* Interpret addr exactly */ | 20 | #define MAP_FIXED 0x10 /* Interpret addr exactly */ |
21 | #define MAP_ANONYMOUS 0x20 /* don't use a file */ | 21 | #define MAP_ANONYMOUS 0x20 /* don't use a file */ |
22 | #ifdef CONFIG_MMAP_ALLOW_UNINITIALIZED | ||
23 | # define MAP_UNINITIALIZED 0x4000000 /* For anonymous mmap, memory could be uninitialized */ | ||
24 | #else | ||
25 | # define MAP_UNINITIALIZED 0x0 /* Don't support this flag */ | ||
26 | #endif | ||
27 | 22 | ||
28 | /* 0x0100 - 0x80000 flags are defined in asm-generic/mman.h */ | 23 | /* 0x0100 - 0x80000 flags are defined in asm-generic/mman.h */ |
29 | #define MAP_FIXED_NOREPLACE 0x100000 /* MAP_FIXED which doesn't unmap underlying mapping */ | 24 | #define MAP_FIXED_NOREPLACE 0x100000 /* MAP_FIXED which doesn't unmap underlying mapping */ |
30 | 25 | ||
26 | #define MAP_UNINITIALIZED 0x4000000 /* For anonymous mmap, memory could be | ||
27 | * uninitialized */ | ||
28 | |||
31 | /* | 29 | /* |
32 | * Flags for mlock | 30 | * Flags for mlock |
33 | */ | 31 | */ |
diff --git a/mm/nommu.c b/mm/nommu.c index eb3e2e558da1..fed1b6e9c89b 100644 --- a/mm/nommu.c +++ b/mm/nommu.c | |||
@@ -1261,7 +1261,9 @@ unsigned long do_mmap(struct file *file, | |||
1261 | add_nommu_region(region); | 1261 | add_nommu_region(region); |
1262 | 1262 | ||
1263 | /* clear anonymous mappings that don't ask for uninitialized data */ | 1263 | /* clear anonymous mappings that don't ask for uninitialized data */ |
1264 | if (!vma->vm_file && !(flags & MAP_UNINITIALIZED)) | 1264 | if (!vma->vm_file && |
1265 | (!IS_ENABLED(CONFIG_MMAP_ALLOW_UNINITIALIZED) || | ||
1266 | !(flags & MAP_UNINITIALIZED))) | ||
1265 | memset((void *)region->vm_start, 0, | 1267 | memset((void *)region->vm_start, 0, |
1266 | region->vm_end - region->vm_start); | 1268 | region->vm_end - region->vm_start); |
1267 | 1269 | ||