Skip to content

Commit f04fd85

Browse files
lorenzo-stoakesakpm00
authored andcommitted
mm: correct type for vmalloc vm_flags fields
Several functions refer to the unfortunately named 'vm_flags' field when referencing vmalloc flags, which happens to be the precise same name used for VMA flags. As a result these were erroneously changed to use the vm_flags_t type (which currently is a typedef equivalent to unsigned long). Currently this has no impact, but in future when vm_flags_t changes this will result in issues, so change the type to unsigned long to account for this. [[email protected]: fixup very disguised vmalloc flags parameter] Link: https://lkml.kernel.org/r/[email protected] Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: Lorenzo Stoakes <[email protected]> Reported-by: Harry Yoo <[email protected]> Closes: https://lore.kernel.org/all/aIgSpAnU8EaIcqd9@hyeyoo/ Reviewed-by: Pedro Falcato <[email protected]> Acked-by: David Hildenbrand <[email protected]> Reviewed-by: Harry Yoo <[email protected]> Acked-by: Vlastimil Babka <[email protected]> Cc: Jann Horn <[email protected]> Cc: Liam Howlett <[email protected]> Cc: Michal Hocko <[email protected]> Cc: Mike Rapoport <[email protected]> Cc: Suren Baghdasaryan <[email protected]> Cc: "Uladzislau Rezki (Sony)" <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent de55be4 commit f04fd85

File tree

4 files changed

+7
-7
lines changed

4 files changed

+7
-7
lines changed

arch/arm64/mm/mmu.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -721,7 +721,7 @@ void mark_rodata_ro(void)
721721

722722
static void __init declare_vma(struct vm_struct *vma,
723723
void *va_start, void *va_end,
724-
vm_flags_t vm_flags)
724+
unsigned long vm_flags)
725725
{
726726
phys_addr_t pa_start = __pa_symbol(va_start);
727727
unsigned long size = va_end - va_start;

mm/execmem.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ static struct execmem_info default_execmem_info __ro_after_init;
2626

2727
#ifdef CONFIG_MMU
2828
static void *execmem_vmalloc(struct execmem_range *range, size_t size,
29-
pgprot_t pgprot, vm_flags_t vm_flags)
29+
pgprot_t pgprot, unsigned long vm_flags)
3030
{
3131
bool kasan = range->flags & EXECMEM_KASAN_SHADOW;
3232
gfp_t gfp_flags = GFP_KERNEL | __GFP_NOWARN;
@@ -82,7 +82,7 @@ struct vm_struct *execmem_vmap(size_t size)
8282
}
8383
#else
8484
static void *execmem_vmalloc(struct execmem_range *range, size_t size,
85-
pgprot_t pgprot, vm_flags_t vm_flags)
85+
pgprot_t pgprot, unsigned long vm_flags)
8686
{
8787
return vmalloc(size);
8888
}
@@ -283,7 +283,7 @@ static void *__execmem_cache_alloc(struct execmem_range *range, size_t size)
283283

284284
static int execmem_cache_populate(struct execmem_range *range, size_t size)
285285
{
286-
vm_flags_t vm_flags = VM_ALLOW_HUGE_VMAP;
286+
unsigned long vm_flags = VM_ALLOW_HUGE_VMAP;
287287
struct vm_struct *vm;
288288
size_t alloc_size;
289289
int err = -ENOMEM;
@@ -465,7 +465,7 @@ void *execmem_alloc(enum execmem_type type, size_t size)
465465
{
466466
struct execmem_range *range = &execmem_info->ranges[type];
467467
bool use_cache = range->flags & EXECMEM_ROX_CACHE;
468-
vm_flags_t vm_flags = VM_FLUSH_RESET_PERMS;
468+
unsigned long vm_flags = VM_FLUSH_RESET_PERMS;
469469
pgprot_t pgprot = range->pgprot;
470470
void *p = NULL;
471471

mm/internal.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1391,7 +1391,7 @@ int migrate_device_coherent_folio(struct folio *folio);
13911391

13921392
struct vm_struct *__get_vm_area_node(unsigned long size,
13931393
unsigned long align, unsigned long shift,
1394-
vm_flags_t vm_flags, unsigned long start,
1394+
unsigned long vm_flags, unsigned long start,
13951395
unsigned long end, int node, gfp_t gfp_mask,
13961396
const void *caller);
13971397

mm/nommu.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ void *vrealloc_noprof(const void *p, size_t size, gfp_t flags)
126126

127127
void *__vmalloc_node_range_noprof(unsigned long size, unsigned long align,
128128
unsigned long start, unsigned long end, gfp_t gfp_mask,
129-
pgprot_t prot, vm_flags_t vm_flags, int node,
129+
pgprot_t prot, unsigned long vm_flags, int node,
130130
const void *caller)
131131
{
132132
return __vmalloc_noprof(size, gfp_mask);

0 commit comments

Comments
 (0)