Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 12220267 authored by Ira Weiny's avatar Ira Weiny Committed by Doug Ledford
Browse files

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: default avatarDennis Dalessandro <dennis.dalessandro@intel.com>
Signed-off-by: default avatarIra Weiny <ira.weiny@intel.com>
Signed-off-by: default avatarDennis Dalessandro <dennis.dalessandro@intel.com>
Signed-off-by: default avatarDoug Ledford <dledford@redhat.com>
parent ee495ada
Loading
Loading
Loading
Loading
+4 −0
Original line number Original line Diff line number Diff line
@@ -597,6 +597,10 @@ static int hfi1_file_mmap(struct file *fp, struct vm_area_struct *vma)
		vmf = 1;
		vmf = 1;
		break;
		break;
	case STATUS:
	case STATUS:
		if (flags & (unsigned long)(VM_WRITE | VM_EXEC)) {
			ret = -EPERM;
			goto done;
		}
		memaddr = kvirt_to_phys((void *)dd->status);
		memaddr = kvirt_to_phys((void *)dd->status);
		memlen = PAGE_SIZE;
		memlen = PAGE_SIZE;
		flags |= VM_IO | VM_DONTEXPAND;
		flags |= VM_IO | VM_DONTEXPAND;