mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/chenhuacai/linux-loongson
synced 2025-08-27 06:50:37 +00:00

The core kernel code is currently very inconsistent in its use of vm_flags_t vs. unsigned long. This prevents us from changing the type of vm_flags_t in the future and is simply not correct, so correct this. While this results in rather a lot of churn, it is a critical pre-requisite for a future planned change to VMA flag type. Additionally, update VMA userland tests to account for the changes. To make review easier and to break things into smaller parts, driver and architecture-specific changes is left for a subsequent commit. The code has been adjusted to cascade the changes across all calling code as far as is needed. We will adjust architecture-specific and driver code in a subsequent patch. Overall, this patch does not introduce any functional change. Link: https://lkml.kernel.org/r/d1588e7bb96d1ea3fe7b9df2c699d5b4592d901d.1750274467.git.lorenzo.stoakes@oracle.com Signed-off-by: Lorenzo Stoakes <lorenzo.stoakes@oracle.com> Acked-by: Kees Cook <kees@kernel.org> Acked-by: Mike Rapoport (Microsoft) <rppt@kernel.org> Acked-by: Jan Kara <jack@suse.cz> Acked-by: Christian Brauner <brauner@kernel.org> Reviewed-by: Vlastimil Babka <vbabka@suse.cz> Acked-by: Oscar Salvador <osalvador@suse.de> Reviewed-by: Pedro Falcato <pfalcato@suse.de> Acked-by: Zi Yan <ziy@nvidia.com> Acked-by: David Hildenbrand <david@redhat.com> Reviewed-by: Anshuman Khandual <anshuman.khandual@arm.com> Cc: Jann Horn <jannh@google.com> Cc: Liam R. Howlett <Liam.Howlett@oracle.com> Cc: Catalin Marinas <catalin.marinas@arm.com> Cc: Jarkko Sakkinen <jarkko@kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
35 lines
944 B
C
35 lines
944 B
C
/* SPDX-License-Identifier: GPL-2.0 */
|
|
#ifndef __LINUX_MEMFD_H
|
|
#define __LINUX_MEMFD_H
|
|
|
|
#include <linux/file.h>
|
|
|
|
#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 vm_flags_ptr.
|
|
*/
|
|
int memfd_check_seals_mmap(struct file *file, vm_flags_t *vm_flags_ptr);
|
|
#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,
|
|
vm_flags_t *vm_flags_ptr)
|
|
{
|
|
return 0;
|
|
}
|
|
#endif
|
|
|
|
#endif /* __LINUX_MEMFD_H */
|