mirror of
https://github.com/linux-msm/laptops-kernel.git
synced 2026-08-13 14:19:53 -07:00
The core do_mmap() function accepts a vm_flags_t parameter which it then manipulates before passing to mmap_region() to do the heavy lifting of the memory mapping. Update do_mmap() to instead accept a vma_flags_t parameter, and adjust all the logic within do_mmap() to manipulate this instead. This is as part of the ongoing effort to convert VMA flags from a system word size to a bitmap type which allows us to unrestrict the number of VMA flags, as well as gain control over how VMA flag manipulation occurs. We do not cascade these changes to all functions which accept vm_flags_t, but rather use vma_flags_to_legacy() where necessary, specifically deferring converting calc_vm_prot_bits(), calc_vm_flag_bits() and __get_unmapped_area() to vma_flags_t. Also utilise the new vma_flags_can_grow() predicate which correctly handles the case of architectures without upward growing stacks. As part of this change, introduce VMA_SHADOW_STACK so we can correctly handle the case of the shadow stack not being defined. No functional change intended. Link: https://lore.kernel.org/20260711-b4-vma-flags-mm-v2-2-0fa2357d5431@kernel.org Signed-off-by: Lorenzo Stoakes <ljs@kernel.org> Reviewed-by: Lance Yang <lance.yang@linux.dev> Reviewed-by: Zi Yan <ziy@nvidia.com> Reviewed-by: Vlastimil Babka (SUSE) <vbabka@kernel.org> Cc: Baolin Wang <baolin.wang@linux.alibaba.com> Cc: Barry Song <baohua@kernel.org> Cc: Christian Brauner <brauner@kernel.org> Cc: Dave Airlie <airlied@gmail.com> Cc: David Hildenbrand <david@kernel.org> Cc: Dev Jain <dev.jain@arm.com> Cc: Jani Nikula <jani.nikula@intel.com> Cc: Jan Kara <jack@suse.cz> Cc: Jann Horn <jannh@google.com> Cc: Mike Rapoport <rppt@kernel.org> Cc: Muchun Song <muchun.song@linux.dev> Cc: Nico Pache <npache@redhat.com> Cc: Oscar Salvador <osalvador@suse.de> Cc: Pedro Falcato <pfalcato@suse.de> Cc: Suren Baghdasaryan <surenb@google.com> Cc: Thomas Zimmermann <tzimmermann@suse.de> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
55 lines
1.4 KiB
C
55 lines
1.4 KiB
C
/* SPDX-License-Identifier: GPL-2.0 */
|
|
#ifndef __LINUX_MEMFD_H
|
|
#define __LINUX_MEMFD_H
|
|
|
|
#include <linux/file.h>
|
|
|
|
#define MEMFD_ANON_NAME "[memfd]"
|
|
|
|
#ifdef CONFIG_MEMFD_CREATE
|
|
extern long memfd_fcntl(struct file *file, unsigned int cmd, unsigned int arg);
|
|
struct folio *memfd_alloc_folio(struct file *memfd, pgoff_t idx);
|
|
/*
|
|
* Check for any existing seals on mmap, return an error if access is denied due
|
|
* to sealing, or 0 otherwise.
|
|
*
|
|
* We also update VMA flags if appropriate by manipulating the VMA flags pointed
|
|
* to by vma_flags_ptr.
|
|
*/
|
|
int memfd_check_seals_mmap(struct file *file, vma_flags_t *vma_flags_ptr);
|
|
struct file *memfd_alloc_file(const char *name, unsigned int flags);
|
|
int memfd_get_seals(struct file *file);
|
|
int memfd_add_seals(struct file *file, unsigned int seals);
|
|
#else
|
|
static inline long memfd_fcntl(struct file *f, unsigned int c, unsigned int a)
|
|
{
|
|
return -EINVAL;
|
|
}
|
|
static inline struct folio *memfd_alloc_folio(struct file *memfd, pgoff_t idx)
|
|
{
|
|
return ERR_PTR(-EINVAL);
|
|
}
|
|
static inline int memfd_check_seals_mmap(struct file *file,
|
|
vma_flags_t *vma_flags_ptr)
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
static inline struct file *memfd_alloc_file(const char *name, unsigned int flags)
|
|
{
|
|
return ERR_PTR(-EINVAL);
|
|
}
|
|
|
|
static inline int memfd_get_seals(struct file *file)
|
|
{
|
|
return -EINVAL;
|
|
}
|
|
|
|
static inline int memfd_add_seals(struct file *file, unsigned int seals)
|
|
{
|
|
return -EINVAL;
|
|
}
|
|
#endif
|
|
|
|
#endif /* __LINUX_MEMFD_H */
|