Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 211685
b: refs/heads/master
c: 845ca30
h: refs/heads/master
i:
  211683: b328356
v: v3
  • Loading branch information
Eric Paris authored and James Morris committed Oct 20, 2010
1 parent 4d1a597 commit 74d85db
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 2 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: cee74f47a6baba0ac457e87687fdcf0abd599f0a
refs/heads/master: 845ca30fe9691f1bab7cfbf30b6d11c944eb4abd
44 changes: 44 additions & 0 deletions trunk/security/selinux/selinuxfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -439,9 +439,53 @@ static ssize_t sel_read_policy(struct file *filp, char __user *buf,
return ret;
}

static int sel_mmap_policy_fault(struct vm_area_struct *vma,
struct vm_fault *vmf)
{
struct policy_load_memory *plm = vma->vm_file->private_data;
unsigned long offset;
struct page *page;

if (vmf->flags & (FAULT_FLAG_MKWRITE | FAULT_FLAG_WRITE))
return VM_FAULT_SIGBUS;

offset = vmf->pgoff << PAGE_SHIFT;
if (offset >= roundup(plm->len, PAGE_SIZE))
return VM_FAULT_SIGBUS;

page = vmalloc_to_page(plm->data + offset);
get_page(page);

vmf->page = page;

return 0;
}

static struct vm_operations_struct sel_mmap_policy_ops = {
.fault = sel_mmap_policy_fault,
.page_mkwrite = sel_mmap_policy_fault,
};

int sel_mmap_policy(struct file *filp, struct vm_area_struct *vma)
{
if (vma->vm_flags & VM_SHARED) {
/* do not allow mprotect to make mapping writable */
vma->vm_flags &= ~VM_MAYWRITE;

if (vma->vm_flags & VM_WRITE)
return -EACCES;
}

vma->vm_flags |= VM_RESERVED;
vma->vm_ops = &sel_mmap_policy_ops;

return 0;
}

static const struct file_operations sel_policy_ops = {
.open = sel_open_policy,
.read = sel_read_policy,
.mmap = sel_mmap_policy,
.release = sel_release_policy,
};

Expand Down
2 changes: 1 addition & 1 deletion trunk/security/selinux/ss/services.c
Original file line number Diff line number Diff line change
Expand Up @@ -3169,7 +3169,7 @@ int security_read_policy(void **data, ssize_t *len)

*len = security_policydb_len();

*data = vmalloc(*len);
*data = vmalloc_user(*len);
if (!*data)
return -ENOMEM;

Expand Down

0 comments on commit 74d85db

Please sign in to comment.