[PATCH 13/13] security: convert VMA flag tests to use vma_flags_t
From: Lorenzo Stoakes (ARM)
Date: Thu Nov 05 2026 - 16:45:56 EST
Replace use of the legacy vm_flags_t flags with vma_flags_t values in the
mmap and mprotect LSM hooks of SELinux, AppArmor, IMA and IPE.
No functional change intended.
Signed-off-by: Lorenzo Stoakes (ARM) <ljs@xxxxxxxxxx>
---
security/apparmor/lsm.c | 2 +-
security/integrity/ima/ima_main.c | 2 +-
security/ipe/hooks.c | 2 +-
security/selinux/hooks.c | 14 +++++++-------
4 files changed, 10 insertions(+), 10 deletions(-)
diff --git a/security/apparmor/lsm.c b/security/apparmor/lsm.c
index c73681d820a0..00099a32b3f6 100644
--- a/security/apparmor/lsm.c
+++ b/security/apparmor/lsm.c
@@ -590,7 +590,7 @@ static int apparmor_file_mprotect(struct vm_area_struct *vma,
unsigned long reqprot, unsigned long prot)
{
return common_mmap(OP_FMPROT, vma->vm_file, prot,
- !(vma->vm_flags & VM_SHARED) ? MAP_PRIVATE : 0);
+ !vma_test(vma, VMA_SHARED_BIT) ? MAP_PRIVATE : 0);
}
#ifdef CONFIG_IO_URING
diff --git a/security/integrity/ima/ima_main.c b/security/integrity/ima/ima_main.c
index fed80da3ee09..92032afe4cd1 100644
--- a/security/integrity/ima/ima_main.c
+++ b/security/integrity/ima/ima_main.c
@@ -556,7 +556,7 @@ static int ima_file_mprotect(struct vm_area_struct *vma, unsigned long reqprot,
/* Is mprotect making an mmap'ed file executable? */
if (!(ima_policy_flag & IMA_APPRAISE) || !vma->vm_file ||
- !(prot & PROT_EXEC) || (vma->vm_flags & VM_EXEC))
+ !(prot & PROT_EXEC) || vma_test(vma, VMA_EXEC_BIT))
return 0;
security_current_getlsmprop_subj(&prop);
diff --git a/security/ipe/hooks.c b/security/ipe/hooks.c
index d878b52ceec8..247b07748b1d 100644
--- a/security/ipe/hooks.c
+++ b/security/ipe/hooks.c
@@ -112,7 +112,7 @@ int ipe_file_mprotect(struct vm_area_struct *vma,
struct ipe_eval_ctx ctx = IPE_EVAL_CTX_INIT;
/* Already Executable */
- if (vma->vm_flags & VM_EXEC)
+ if (vma_test(vma, VMA_EXEC_BIT))
return 0;
if (prot & PROT_EXEC) {
diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c
index 6168dd5f91c2..1bf78c2a6aba 100644
--- a/security/selinux/hooks.c
+++ b/security/selinux/hooks.c
@@ -4206,16 +4206,16 @@ static int selinux_mmap_backing_file(struct vm_area_struct *vma,
{
unsigned long prot = 0;
- /* translate vma->vm_flags perms into PROT perms */
- if (vma->vm_flags & VM_READ)
+ /* translate VMA flag perms into PROT perms */
+ if (vma_test(vma, VMA_READ_BIT))
prot |= PROT_READ;
- if (vma->vm_flags & VM_WRITE)
+ if (vma_test(vma, VMA_WRITE_BIT))
prot |= PROT_WRITE;
- if (vma->vm_flags & VM_EXEC)
+ if (vma_test(vma, VMA_EXEC_BIT))
prot |= PROT_EXEC;
return selinux_mmap_file_common(backing_file, prot,
- vma->vm_flags & VM_SHARED,
+ vma_test(vma, VMA_SHARED_BIT),
true);
}
@@ -4229,13 +4229,13 @@ static int selinux_file_mprotect(struct vm_area_struct *vma,
u32 av;
const struct file *file = vma->vm_file;
bool backing_file;
- bool shared = vma->vm_flags & VM_SHARED;
+ bool shared = vma_test(vma, VMA_SHARED_BIT);
/* check if we need to trigger the "backing files are awful" mode */
backing_file = file && (file->f_mode & FMODE_BACKING);
if (default_noexec &&
- (prot & PROT_EXEC) && !(vma->vm_flags & VM_EXEC)) {
+ (prot & PROT_EXEC) && !vma_test(vma, VMA_EXEC_BIT)) {
/*
* We don't use the vma_is_initial_heap() helper as it has
* a history of problems and is currently broken on systems
--
2.56.0