Skip to content

Commit 0298c5a

Browse files
robertosassupcmoore
authored andcommitted
ima: Align ima_file_mprotect() definition with LSM infrastructure
Change ima_file_mprotect() definition, so that it can be registered as implementation of the file_mprotect hook. Signed-off-by: Roberto Sassu <roberto.sassu@huawei.com> Reviewed-by: Stefan Berger <stefanb@linux.ibm.com> Reviewed-by: Casey Schaufler <casey@schaufler-ca.com> Reviewed-by: Mimi Zohar <zohar@linux.ibm.com> Acked-by: Mimi Zohar <zohar@linux.ibm.com> Signed-off-by: Paul Moore <paul@paul-moore.com>
1 parent bad5247 commit 0298c5a

3 files changed

Lines changed: 8 additions & 5 deletions

File tree

include/linux/ima.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ extern void ima_post_create_tmpfile(struct mnt_idmap *idmap,
2323
extern void ima_file_free(struct file *file);
2424
extern int ima_file_mmap(struct file *file, unsigned long reqprot,
2525
unsigned long prot, unsigned long flags);
26-
extern int ima_file_mprotect(struct vm_area_struct *vma, unsigned long prot);
26+
extern int ima_file_mprotect(struct vm_area_struct *vma, unsigned long reqprot,
27+
unsigned long prot);
2728
extern int ima_load_data(enum kernel_load_data_id id, bool contents);
2829
extern int ima_post_load_data(char *buf, loff_t size,
2930
enum kernel_load_data_id id, char *description);
@@ -84,7 +85,7 @@ static inline int ima_file_mmap(struct file *file, unsigned long reqprot,
8485
}
8586

8687
static inline int ima_file_mprotect(struct vm_area_struct *vma,
87-
unsigned long prot)
88+
unsigned long reqprot, unsigned long prot)
8889
{
8990
return 0;
9091
}

security/integrity/ima/ima_main.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -455,7 +455,8 @@ int ima_file_mmap(struct file *file, unsigned long reqprot,
455455
/**
456456
* ima_file_mprotect - based on policy, limit mprotect change
457457
* @vma: vm_area_struct protection is set to
458-
* @prot: contains the protection that will be applied by the kernel.
458+
* @reqprot: protection requested by the application
459+
* @prot: protection that will be applied by the kernel
459460
*
460461
* Files can be mmap'ed read/write and later changed to execute to circumvent
461462
* IMA's mmap appraisal policy rules. Due to locking issues (mmap semaphore
@@ -465,7 +466,8 @@ int ima_file_mmap(struct file *file, unsigned long reqprot,
465466
*
466467
* On mprotect change success, return 0. On failure, return -EACESS.
467468
*/
468-
int ima_file_mprotect(struct vm_area_struct *vma, unsigned long prot)
469+
int ima_file_mprotect(struct vm_area_struct *vma, unsigned long reqprot,
470+
unsigned long prot)
469471
{
470472
struct ima_template_desc *template = NULL;
471473
struct file *file;

security/security.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2831,7 +2831,7 @@ int security_file_mprotect(struct vm_area_struct *vma, unsigned long reqprot,
28312831
ret = call_int_hook(file_mprotect, 0, vma, reqprot, prot);
28322832
if (ret)
28332833
return ret;
2834-
return ima_file_mprotect(vma, prot);
2834+
return ima_file_mprotect(vma, reqprot, prot);
28352835
}
28362836

28372837
/**

0 commit comments

Comments
 (0)