aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/infiniband
diff options
context:
space:
mode:
authorIra Weiny <ira.weiny@intel.com>2017-04-09 10:17:24 -0700
committerDoug Ledford <dledford@redhat.com>2017-04-28 13:56:23 -0400
commit12220267645cb7d1f3f699218e0098629e932e1f (patch)
tree2b3bd6922c50637dd5e0d62248fae4b4f795f152 /drivers/infiniband
parentIB/hfi1: Fix unbalanced braces around else (diff)
downloadlinux-dev-12220267645cb7d1f3f699218e0098629e932e1f.tar.xz
linux-dev-12220267645cb7d1f3f699218e0098629e932e1f.zip
IB/hfi: Protect against writable mmap
The device/port status is not intended to be changed from user space. Prevent a user from mapping them as write or execute. Reviewed-by: Dennis Dalessandro <dennis.dalessandro@intel.com> Signed-off-by: Ira Weiny <ira.weiny@intel.com> Signed-off-by: Dennis Dalessandro <dennis.dalessandro@intel.com> Signed-off-by: Doug Ledford <dledford@redhat.com>
Diffstat (limited to 'drivers/infiniband')
-rw-r--r--drivers/infiniband/hw/hfi1/file_ops.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/drivers/infiniband/hw/hfi1/file_ops.c b/drivers/infiniband/hw/hfi1/file_ops.c
index 60598867f948..3d9bce4bfcc7 100644
--- a/drivers/infiniband/hw/hfi1/file_ops.c
+++ b/drivers/infiniband/hw/hfi1/file_ops.c
@@ -597,6 +597,10 @@ static int hfi1_file_mmap(struct file *fp, struct vm_area_struct *vma)
vmf = 1;
break;
case STATUS:
+ if (flags & (unsigned long)(VM_WRITE | VM_EXEC)) {
+ ret = -EPERM;
+ goto done;
+ }
memaddr = kvirt_to_phys((void *)dd->status);
memlen = PAGE_SIZE;
flags |= VM_IO | VM_DONTEXPAND;