Skip to content

Commit 1222026

Browse files
weiny2dledford
authored andcommitted
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>
1 parent ee495ad commit 1222026

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

drivers/infiniband/hw/hfi1/file_ops.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -597,6 +597,10 @@ static int hfi1_file_mmap(struct file *fp, struct vm_area_struct *vma)
597597
vmf = 1;
598598
break;
599599
case STATUS:
600+
if (flags & (unsigned long)(VM_WRITE | VM_EXEC)) {
601+
ret = -EPERM;
602+
goto done;
603+
}
600604
memaddr = kvirt_to_phys((void *)dd->status);
601605
memlen = PAGE_SIZE;
602606
flags |= VM_IO | VM_DONTEXPAND;

0 commit comments

Comments
 (0)