From 3e0d87ec728774c6975cf801e8d884f2c6a6a110 Mon Sep 17 00:00:00 2001 From: c30043414 Date: Tue, 15 Aug 2023 16:15:28 +0800 Subject: [PATCH] fix maps Signed-off-by: c30043414 Change-Id: I75c1bc83ebe3862d52fd7e42fa398e3902c5511c --- fs/proc/task_mmu.c | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c index 5b486198a968..4fcfde39b7fb 100644 --- a/fs/proc/task_mmu.c +++ b/fs/proc/task_mmu.c @@ -24,6 +24,9 @@ #include #endif +#include +#include + #include #include #include @@ -292,6 +295,28 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma) dev_t dev = 0; const char *name = NULL; + + struct inode *inode = file_inode(m->file); + char *selinux_label = NULL; + int rc; + u32 secid; + u32 secctx_sz = 0; + bool result = false; + bool ret = false; + struct task_struct *task = get_proc_task(inode); + + security_cred_getsecid(task->cred, &secid); + rc = security_secid_to_secctx(secid, &selinux_label, &secctx_sz); + if (!rc) { + if ( selinux_label == "u:r:isolated_render:s0"){ + result = true; + } + } + if (flags & VM_READ & VM_EXEC) { + ret = true; + } + + if (file) { struct inode *inode = file_inode(vma->vm_file); dev = inode->i_sb->s_dev; @@ -301,7 +326,15 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma) start = vma->vm_start; end = vma->vm_end; +#ifdef DEBUG show_vma_header_prefix(m, start, end, flags, pgoff, dev, ino); +#else + if(result && ret) { + seq_putc(m, ' '); + }else{ + show_vma_header_prefix(m, start, end, flags, pgoff, dev, ino); + } +#endif /* * Print the dentry name for named mappings, and a @@ -341,8 +374,17 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma) anon_name = anon_vma_name(vma); if (anon_name) { +#ifdef DEBUG seq_pad(m, ' '); seq_printf(m, "[anon:%s]", anon_name->name); +#else + if (ret && result){ + seq_pad(m, ' '); + }else{ + seq_pad(m, ' '); + seq_printf(m, "[anon:%s]", anon_name->name); + } +#endif } } -- Gitee