hfi1_file_mmap() rejects a writable mapping of the device status page, but leaves VM_MAYWRITE set in the VMA flags. Userspace can map the page read-only and then upgrade it to writable with mprotect(), bypassing the check and writing to a device-owned status page. Clear VM_MAYWRITE on this path, as the RTAIL and SUBCTXT_EGRBUF cases in the same function already do. Cc: stable@vger.kernel.org Signed-off-by: Abdifatah Suruur --- diff --git a/drivers/infiniband/hw/hfi1/file_ops.c b/drivers/infiniband/hw/hfi1/file_ops.c index 680364fda856f..779dbe32c69da 100644 --- a/drivers/infiniband/hw/hfi1/file_ops.c +++ b/drivers/infiniband/hw/hfi1/file_ops.c @@ -492,6 +492,7 @@ static int hfi1_file_mmap(struct file *fp, struct vm_area_struct *vma) ret = -EPERM; goto done; } + flags &= ~VM_MAYWRITE; memaddr = kvirt_to_phys((void *)dd->status); memlen = PAGE_SIZE; break;