···8686extern int cap_inode_removexattr(struct dentry *dentry, const char *name);8787extern int cap_inode_need_killpriv(struct dentry *dentry);8888extern int cap_inode_killpriv(struct dentry *dentry);8989+extern int cap_mmap_addr(unsigned long addr);8990extern int cap_file_mmap(struct file *file, unsigned long reqprot,9091 unsigned long prot, unsigned long flags,9192 unsigned long addr, unsigned long addr_only);···21882187 unsigned long addr,21892188 unsigned long addr_only)21902189{21912191- return cap_file_mmap(file, reqprot, prot, flags, addr, addr_only);21902190+ return cap_mmap_addr(addr);21922191}2193219221942193static inline int security_file_mprotect(struct vm_area_struct *vma,
+1-1
security/apparmor/lsm.c
···497497 int rc = 0;498498499499 /* do DAC check */500500- rc = cap_file_mmap(file, reqprot, prot, flags, addr, addr_only);500500+ rc = cap_mmap_addr(addr);501501 if (rc || addr_only)502502 return rc;503503
+24-10
security/commoncap.c
···958958}959959960960/*961961+ * cap_mmap_addr - check if able to map given addr962962+ * @addr: address attempting to be mapped963963+ *964964+ * If the process is attempting to map memory below dac_mmap_min_addr they need965965+ * CAP_SYS_RAWIO. The other parameters to this function are unused by the966966+ * capability security module. Returns 0 if this mapping should be allowed967967+ * -EPERM if not.968968+ */969969+int cap_mmap_addr(unsigned long addr)970970+{971971+ int ret = 0;972972+973973+ if (addr < dac_mmap_min_addr) {974974+ ret = cap_capable(current_cred(), &init_user_ns, CAP_SYS_RAWIO,975975+ SECURITY_CAP_AUDIT);976976+ /* set PF_SUPERPRIV if it turns out we allow the low mmap */977977+ if (ret == 0)978978+ current->flags |= PF_SUPERPRIV;979979+ }980980+ return ret;981981+}982982+983983+/*961984 * cap_file_mmap - check if able to map given addr962985 * @file: unused963986 * @reqprot: unused···998975 unsigned long prot, unsigned long flags,999976 unsigned long addr, unsigned long addr_only)1000977{10011001- int ret = 0;10021002-10031003- if (addr < dac_mmap_min_addr) {10041004- ret = cap_capable(current_cred(), &init_user_ns, CAP_SYS_RAWIO,10051005- SECURITY_CAP_AUDIT);10061006- /* set PF_SUPERPRIV if it turns out we allow the low mmap */10071007- if (ret == 0)10081008- current->flags |= PF_SUPERPRIV;10091009- }10101010- return ret;978978+ return cap_mmap_addr(addr);1011979}
+1-1
security/selinux/hooks.c
···31043104 }3105310531063106 /* do DAC check on address space usage */31073107- rc = cap_file_mmap(file, reqprot, prot, flags, addr, addr_only);31073107+ rc = cap_mmap_addr(addr);31083108 if (rc || addr_only)31093109 return rc;31103110
+1-1
security/smack/smack_lsm.c
···11991199 int rc;1200120012011201 /* do DAC check on address space usage */12021202- rc = cap_file_mmap(file, reqprot, prot, flags, addr, addr_only);12021202+ rc = cap_mmap_addr(addr);12031203 if (rc || addr_only)12041204 return rc;12051205