Skip to content

Commit d007794

Browse files
author
Al Viro
committed
split cap_mmap_addr() out of cap_file_mmap()
... switch callers. Signed-off-by: Al Viro <[email protected]>
1 parent cf74d14 commit d007794

File tree

5 files changed

+28
-13
lines changed

5 files changed

+28
-13
lines changed

include/linux/security.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ extern int cap_inode_setxattr(struct dentry *dentry, const char *name,
8686
extern int cap_inode_removexattr(struct dentry *dentry, const char *name);
8787
extern int cap_inode_need_killpriv(struct dentry *dentry);
8888
extern int cap_inode_killpriv(struct dentry *dentry);
89+
extern int cap_mmap_addr(unsigned long addr);
8990
extern 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);
@@ -2187,7 +2188,7 @@ static inline int security_file_mmap(struct file *file, unsigned long reqprot,
21872188
unsigned long addr,
21882189
unsigned long addr_only)
21892190
{
2190-
return cap_file_mmap(file, reqprot, prot, flags, addr, addr_only);
2191+
return cap_mmap_addr(addr);
21912192
}
21922193

21932194
static inline int security_file_mprotect(struct vm_area_struct *vma,

security/apparmor/lsm.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -497,7 +497,7 @@ static int apparmor_file_mmap(struct file *file, unsigned long reqprot,
497497
int rc = 0;
498498

499499
/* do DAC check */
500-
rc = cap_file_mmap(file, reqprot, prot, flags, addr, addr_only);
500+
rc = cap_mmap_addr(addr);
501501
if (rc || addr_only)
502502
return rc;
503503

security/commoncap.c

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -958,22 +958,15 @@ int cap_vm_enough_memory(struct mm_struct *mm, long pages)
958958
}
959959

960960
/*
961-
* cap_file_mmap - check if able to map given addr
962-
* @file: unused
963-
* @reqprot: unused
964-
* @prot: unused
965-
* @flags: unused
961+
* cap_mmap_addr - check if able to map given addr
966962
* @addr: address attempting to be mapped
967-
* @addr_only: unused
968963
*
969964
* If the process is attempting to map memory below dac_mmap_min_addr they need
970965
* CAP_SYS_RAWIO. The other parameters to this function are unused by the
971966
* capability security module. Returns 0 if this mapping should be allowed
972967
* -EPERM if not.
973968
*/
974-
int cap_file_mmap(struct file *file, unsigned long reqprot,
975-
unsigned long prot, unsigned long flags,
976-
unsigned long addr, unsigned long addr_only)
969+
int cap_mmap_addr(unsigned long addr)
977970
{
978971
int ret = 0;
979972

@@ -986,3 +979,24 @@ int cap_file_mmap(struct file *file, unsigned long reqprot,
986979
}
987980
return ret;
988981
}
982+
983+
/*
984+
* cap_file_mmap - check if able to map given addr
985+
* @file: unused
986+
* @reqprot: unused
987+
* @prot: unused
988+
* @flags: unused
989+
* @addr: address attempting to be mapped
990+
* @addr_only: unused
991+
*
992+
* If the process is attempting to map memory below dac_mmap_min_addr they need
993+
* CAP_SYS_RAWIO. The other parameters to this function are unused by the
994+
* capability security module. Returns 0 if this mapping should be allowed
995+
* -EPERM if not.
996+
*/
997+
int cap_file_mmap(struct file *file, unsigned long reqprot,
998+
unsigned long prot, unsigned long flags,
999+
unsigned long addr, unsigned long addr_only)
1000+
{
1001+
return cap_mmap_addr(addr);
1002+
}

security/selinux/hooks.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3104,7 +3104,7 @@ static int selinux_file_mmap(struct file *file, unsigned long reqprot,
31043104
}
31053105

31063106
/* do DAC check on address space usage */
3107-
rc = cap_file_mmap(file, reqprot, prot, flags, addr, addr_only);
3107+
rc = cap_mmap_addr(addr);
31083108
if (rc || addr_only)
31093109
return rc;
31103110

security/smack/smack_lsm.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1199,7 +1199,7 @@ static int smack_file_mmap(struct file *file,
11991199
int rc;
12001200

12011201
/* do DAC check on address space usage */
1202-
rc = cap_file_mmap(file, reqprot, prot, flags, addr, addr_only);
1202+
rc = cap_mmap_addr(addr);
12031203
if (rc || addr_only)
12041204
return rc;
12051205

0 commit comments

Comments
 (0)