···8787extern int cap_inode_need_killpriv(struct dentry *dentry);8888extern int cap_inode_killpriv(struct dentry *dentry);8989extern int cap_mmap_addr(unsigned long addr);9090-extern int cap_file_mmap(struct file *file, unsigned long reqprot,9191- unsigned long prot, unsigned long flags,9292- unsigned long addr, unsigned long addr_only);9090+extern int cap_mmap_file(struct file *file, unsigned long reqprot,9191+ unsigned long prot, unsigned long flags);9392extern int cap_task_fix_setuid(struct cred *new, const struct cred *old, int flags);9493extern int cap_task_prctl(int option, unsigned long arg2, unsigned long arg3,9594 unsigned long arg4, unsigned long arg5);···586587 * simple integer value. When @arg represents a user space pointer, it587588 * should never be used by the security module.588589 * Return 0 if permission is granted.589589- * @file_mmap :590590+ * @mmap_addr :591591+ * Check permissions for a mmap operation at @addr.592592+ * @addr contains virtual address that will be used for the operation.593593+ * Return 0 if permission is granted.594594+ * @mmap_file :590595 * Check permissions for a mmap operation. The @file may be NULL, e.g.591596 * if mapping anonymous memory.592597 * @file contains the file structure for file to map (may be NULL).593598 * @reqprot contains the protection requested by the application.594599 * @prot contains the protection that will be applied by the kernel.595600 * @flags contains the operational flags.596596- * @addr contains virtual address that will be used for the operation.597597- * @addr_only contains a boolean: 0 if file-backed VMA, otherwise 1.598601 * Return 0 if permission is granted.599602 * @file_mprotect:600603 * Check permissions before changing memory access permissions.···14831482 void (*file_free_security) (struct file *file);14841483 int (*file_ioctl) (struct file *file, unsigned int cmd,14851484 unsigned long arg);14861486- int (*file_mmap) (struct file *file,14851485+ int (*mmap_addr) (unsigned long addr);14861486+ int (*mmap_file) (struct file *file,14871487 unsigned long reqprot, unsigned long prot,14881488- unsigned long flags, unsigned long addr,14891489- unsigned long addr_only);14881488+ unsigned long flags);14901489 int (*file_mprotect) (struct vm_area_struct *vma,14911490 unsigned long reqprot,14921491 unsigned long prot);···17451744int security_file_alloc(struct file *file);17461745void security_file_free(struct file *file);17471746int security_file_ioctl(struct file *file, unsigned int cmd, unsigned long arg);17481748-int security_file_mmap(struct file *file, unsigned long reqprot,17491749- unsigned long prot, unsigned long flags,17501750- unsigned long addr, unsigned long addr_only);17471747+int security_mmap_file(struct file *file, unsigned long reqprot,17481748+ unsigned long prot, unsigned long flags);17491749+int security_mmap_addr(unsigned long addr);17511750int security_file_mprotect(struct vm_area_struct *vma, unsigned long reqprot,17521751 unsigned long prot);17531752int security_file_lock(struct file *file, unsigned int cmd);···21832182 return 0;21842183}2185218421862186-static inline int security_file_mmap(struct file *file, unsigned long reqprot,21852185+static inline int security_mmap_file(struct file *file, unsigned long reqprot,21872186 unsigned long prot,21882188- unsigned long flags,21892189- unsigned long addr,21902190- unsigned long addr_only)21872187+ unsigned long flags)21882188+{21892189+ return 0;21902190+}21912191+21922192+static inline int security_mmap_addr(unsigned long addr)21912193{21922194 return cap_mmap_addr(addr);21932195}
···371371 if ((addr <= new_addr) && (addr+old_len) > new_addr)372372 goto out;373373374374- ret = security_file_mmap(NULL, 0, 0, 0, new_addr, 1);374374+ ret = security_mmap_addr(new_addr);375375 if (ret)376376 goto out;377377···532532 goto out;533533 }534534535535- ret = security_file_mmap(NULL, 0, 0, 0, new_addr, 1);535535+ ret = security_mmap_addr(new_addr);536536 if (ret)537537 goto out;538538 ret = move_vma(vma, addr, old_len, new_len, new_addr);
+4-1
mm/nommu.c
···10471047 }1048104810491049 /* allow the security API to have its say */10501050- ret = security_file_mmap(file, reqprot, prot, flags, addr, 0);10501050+ ret = security_mmap_addr(addr);10511051+ if (ret < 0)10521052+ return ret;10531053+ ret = security_mmap_file(file, reqprot, prot, flags);10511054 if (ret < 0)10521055 return ret;10531056
+4-11
security/apparmor/lsm.c
···490490 return common_file_perm(op, file, mask);491491}492492493493-static int apparmor_file_mmap(struct file *file, unsigned long reqprot,494494- unsigned long prot, unsigned long flags,495495- unsigned long addr, unsigned long addr_only)493493+static int apparmor_mmap_file(struct file *file, unsigned long reqprot,494494+ unsigned long prot, unsigned long flags)496495{497497- int rc = 0;498498-499499- /* do DAC check */500500- rc = cap_mmap_addr(addr);501501- if (rc || addr_only)502502- return rc;503503-504496 return common_mmap(OP_FMMAP, file, prot, flags);505497}506498···638646 .file_permission = apparmor_file_permission,639647 .file_alloc_security = apparmor_file_alloc_security,640648 .file_free_security = apparmor_file_free_security,641641- .file_mmap = apparmor_file_mmap,649649+ .mmap_file = apparmor_mmap_file,650650+ .mmap_addr = cap_mmap_addr,642651 .file_mprotect = apparmor_file_mprotect,643652 .file_lock = apparmor_file_lock,644653
···980980 return ret;981981}982982983983-/*984984- * cap_file_mmap - check if able to map given addr985985- * @file: unused986986- * @reqprot: unused987987- * @prot: unused988988- * @flags: unused989989- * @addr: address attempting to be mapped990990- * @addr_only: unused991991- *992992- * If the process is attempting to map memory below dac_mmap_min_addr they need993993- * CAP_SYS_RAWIO. The other parameters to this function are unused by the994994- * capability security module. Returns 0 if this mapping should be allowed995995- * -EPERM if not.996996- */997997-int cap_file_mmap(struct file *file, unsigned long reqprot,998998- unsigned long prot, unsigned long flags,999999- unsigned long addr, unsigned long addr_only)983983+int cap_mmap_file(struct file *file, unsigned long reqprot,984984+ unsigned long prot, unsigned long flags)1000985{10011001- return cap_mmap_addr(addr);986986+ return 0;1002987}
+8-4
security/security.c
···657657 return security_ops->file_ioctl(file, cmd, arg);658658}659659660660-int security_file_mmap(struct file *file, unsigned long reqprot,661661- unsigned long prot, unsigned long flags,662662- unsigned long addr, unsigned long addr_only)660660+int security_mmap_file(struct file *file, unsigned long reqprot,661661+ unsigned long prot, unsigned long flags)663662{664663 int ret;665664666666- ret = security_ops->file_mmap(file, reqprot, prot, flags, addr, addr_only);665665+ ret = security_ops->mmap_file(file, reqprot, prot, flags);667666 if (ret)668667 return ret;669668 return ima_file_mmap(file, prot);669669+}670670+671671+int security_mmap_addr(unsigned long addr)672672+{673673+ return security_ops->mmap_addr(addr);670674}671675672676int security_file_mprotect(struct vm_area_struct *vma, unsigned long reqprot,
+8-7
security/selinux/hooks.c
···30833083 return rc;30843084}3085308530863086-static int selinux_file_mmap(struct file *file, unsigned long reqprot,30873087- unsigned long prot, unsigned long flags,30883088- unsigned long addr, unsigned long addr_only)30863086+static int selinux_mmap_addr(unsigned long addr)30893087{30903088 int rc = 0;30913089 u32 sid = current_sid();···31023104 }3103310531043106 /* do DAC check on address space usage */31053105- rc = cap_mmap_addr(addr);31063106- if (rc || addr_only)31073107- return rc;31073107+ return cap_mmap_addr(addr);31083108+}3108310931103110+static int selinux_mmap_file(struct file *file, unsigned long reqprot,31113111+ unsigned long prot, unsigned long flags)31123112+{31093113 if (selinux_checkreqprot)31103114 prot = reqprot;31113115···55705570 .file_alloc_security = selinux_file_alloc_security,55715571 .file_free_security = selinux_file_free_security,55725572 .file_ioctl = selinux_file_ioctl,55735573- .file_mmap = selinux_file_mmap,55735573+ .mmap_file = selinux_mmap_file,55745574+ .mmap_addr = selinux_mmap_addr,55745575 .file_mprotect = selinux_file_mprotect,55755576 .file_lock = selinux_file_lock,55765577 .file_fcntl = selinux_file_fcntl,
+5-10
security/smack/smack_lsm.c
···11711171}1172117211731173/**11741174- * smack_file_mmap :11741174+ * smack_mmap_file :11751175 * Check permissions for a mmap operation. The @file may be NULL, e.g.11761176 * if mapping anonymous memory.11771177 * @file contains the file structure for file to map (may be NULL).···11801180 * @flags contains the operational flags.11811181 * Return 0 if permission is granted.11821182 */11831183-static int smack_file_mmap(struct file *file,11831183+static int smack_mmap_file(struct file *file,11841184 unsigned long reqprot, unsigned long prot,11851185- unsigned long flags, unsigned long addr,11861186- unsigned long addr_only)11851185+ unsigned long flags)11871186{11881187 struct smack_known *skp;11891188 struct smack_rule *srp;···11961197 int mmay;11971198 int tmay;11981199 int rc;11991199-12001200- /* do DAC check on address space usage */12011201- rc = cap_mmap_addr(addr);12021202- if (rc || addr_only)12031203- return rc;1204120012051201 if (file == NULL || file->f_dentry == NULL)12061202 return 0;···34763482 .file_ioctl = smack_file_ioctl,34773483 .file_lock = smack_file_lock,34783484 .file_fcntl = smack_file_fcntl,34793479- .file_mmap = smack_file_mmap,34853485+ .mmap_file = smack_mmap_file,34863486+ .mmap_addr = cap_mmap_addr,34803487 .file_set_fowner = smack_file_set_fowner,34813488 .file_send_sigiotask = smack_file_send_sigiotask,34823489 .file_receive = smack_file_receive,