2020#include <linux/uaccess.h>
2121#include <linux/mm_inline.h>
2222#include <linux/ctype.h>
23- #ifdef CONFIG_KSU_SUSFS_SUS_KSTAT
23+ #if defined( CONFIG_KSU_SUSFS_SUS_KSTAT ) || defined( CONFIG_KSU_SUSFS_SUS_MAP )
2424#include <linux/susfs_def.h>
2525#endif
2626
2929#include <asm/tlbflush.h>
3030#include "internal.h"
3131
32+ #ifdef CONFIG_KSU_SUSFS_SUS_KSTAT
33+ extern void susfs_sus_ino_for_show_map_vma (unsigned long ino , dev_t * out_dev , unsigned long * out_ino );
34+ #endif
35+
3236void task_mem (struct seq_file * m , struct mm_struct * mm )
3337{
3438 unsigned long text , lib , swap , anon , file , shmem ;
@@ -514,10 +518,6 @@ static void show_vma_header_prefix_fake(struct seq_file *m,
514518 seq_putc (m , ' ' );
515519}
516520
517- #ifdef CONFIG_KSU_SUSFS_SUS_KSTAT
518- extern void susfs_sus_ino_for_show_map_vma (unsigned long ino , dev_t * out_dev , unsigned long * out_ino );
519- #endif
520-
521521static void
522522show_map_vma (struct seq_file * m , struct vm_area_struct * vma , int is_pid )
523523{
@@ -532,6 +532,24 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
532532
533533 if (file ) {
534534 struct inode * inode = file_inode (vma -> vm_file );
535+ #ifdef CONFIG_KSU_SUSFS_SUS_MAP
536+ if (unlikely (inode -> i_mapping -> flags & BIT_SUS_MAPS ) && susfs_is_current_non_root_user_app_proc ()) {
537+ seq_setwidth (m , 25 + sizeof (void * ) * 6 - 1 );
538+ seq_put_hex_ll (m , NULL , vma -> vm_start , 8 );
539+ seq_put_hex_ll (m , "-" , vma -> vm_end , 8 );
540+ seq_putc (m , ' ' );
541+ seq_putc (m , '-' );
542+ seq_putc (m , '-' );
543+ seq_putc (m , '-' );
544+ seq_putc (m , 'p' );
545+ seq_put_hex_ll (m , " " , pgoff , 8 );
546+ seq_put_hex_ll (m , " " , MAJOR (dev ), 2 );
547+ seq_put_hex_ll (m , ":" , MINOR (dev ), 2 );
548+ seq_put_decimal_ull (m , " " , ino );
549+ seq_putc (m , ' ' );
550+ goto done ;
551+ }
552+ #endif
535553#ifdef CONFIG_KSU_SUSFS_SUS_KSTAT
536554 if (unlikely (inode -> i_mapping -> flags & BIT_SUS_KSTAT )) {
537555 susfs_sus_ino_for_show_map_vma (inode -> i_ino , & dev , & ino );
@@ -1090,15 +1108,30 @@ static int show_smap(struct seq_file *m, void *v, int is_pid)
10901108 }
10911109
10921110 if (!rollup_mode )
1111+ #ifdef CONFIG_KSU_SUSFS_SUS_MAP
1112+ if (vma -> vm_file &&
1113+ unlikely (file_inode (vma -> vm_file )-> i_mapping -> flags & BIT_SUS_MAPS ) &&
1114+ susfs_is_current_non_root_user_app_proc ())
1115+ {
1116+ seq_printf (m ,
1117+ "Size: %8lu kB\n"
1118+ "KernelPageSize: %8lu kB\n"
1119+ "MMUPageSize: %8lu kB\n" ,
1120+ (vma -> vm_end - vma -> vm_start ) >> 10 ,
1121+ 4 , 4 );
1122+ goto bypass_orig_flow ;
1123+ }
1124+ #endif
10931125 seq_printf (m ,
10941126 "Size: %8lu kB\n"
10951127 "KernelPageSize: %8lu kB\n"
10961128 "MMUPageSize: %8lu kB\n" ,
10971129 (vma -> vm_end - vma -> vm_start ) >> 10 ,
10981130 vma_kernel_pagesize (vma ) >> 10 ,
10991131 vma_mmu_pagesize (vma ) >> 10 );
1100-
1101-
1132+ #ifdef CONFIG_KSU_SUSFS_SUS_MAP
1133+ bypass_orig_flow :
1134+ #endif
11021135 if (!rollup_mode || last_vma )
11031136 seq_printf (m ,
11041137 "Rss: %8lu kB\n"
@@ -1135,9 +1168,22 @@ static int show_smap(struct seq_file *m, void *v, int is_pid)
11351168 (unsigned long )(mss -> pss_locked >> (10 + PSS_SHIFT )));
11361169
11371170 if (!rollup_mode ) {
1171+ #ifdef CONFIG_KSU_SUSFS_SUS_MAP
1172+ if (vma -> vm_file &&
1173+ unlikely (file_inode (vma -> vm_file )-> i_mapping -> flags & BIT_SUS_MAPS ) &&
1174+ susfs_is_current_non_root_user_app_proc ())
1175+ {
1176+ seq_puts (m , "VmFlags: mr mw me" );
1177+ seq_putc (m , '\n' );
1178+ goto bypass_orig_flow2 ;
1179+ }
1180+ #endif
11381181 arch_show_smap (m , vma );
11391182 show_smap_vma_flags (m , vma );
11401183 }
1184+ #ifdef CONFIG_KSU_SUSFS_SUS_MAP
1185+ bypass_orig_flow2 :
1186+ #endif
11411187 m_cache_vma (m , vma );
11421188 return ret ;
11431189}
@@ -1772,6 +1818,9 @@ static ssize_t pagemap_read(struct file *file, char __user *buf,
17721818 unsigned long start_vaddr ;
17731819 unsigned long end_vaddr ;
17741820 int ret = 0 , copied = 0 ;
1821+ #ifdef CONFIG_KSU_SUSFS_SUS_MAP
1822+ struct vm_area_struct * vma ;
1823+ #endif
17751824
17761825 if (!mm || !mmget_not_zero (mm ))
17771826 goto out ;
@@ -1830,6 +1879,16 @@ static ssize_t pagemap_read(struct file *file, char __user *buf,
18301879 down_read (& mm -> mmap_sem );
18311880 ret = walk_page_range (start_vaddr , end , & pagemap_walk );
18321881 up_read (& mm -> mmap_sem );
1882+ #ifdef CONFIG_KSU_SUSFS_SUS_MAP
1883+ vma = find_vma (mm , start_vaddr );
1884+ if (vma && vma -> vm_file ) {
1885+ struct inode * inode = file_inode (vma -> vm_file );
1886+ if (unlikely (inode -> i_mapping -> flags & BIT_SUS_MAPS ) && susfs_is_current_non_root_user_app_proc ()) {
1887+ pm .show_pfn = false;
1888+ pm .buffer -> pme = 0 ;
1889+ }
1890+ }
1891+ #endif
18331892 start_vaddr = end ;
18341893
18351894 len = min (count , PM_ENTRY_BYTES * pm .pos );
0 commit comments