Commit ab3f285f authored by Christian Borntraeger's avatar Christian Borntraeger

KVM: s390/mm: try a cow on read only pages for key ops

The PFMF instruction handler  blindly wrote the storage key even if
the page was mapped R/O in the host. Lets try a COW before continuing
and bail out in case of errors.
Signed-off-by: default avatarChristian Borntraeger <borntraeger@de.ibm.com>
Reviewed-by: default avatarDominik Dingel <dingel@linux.vnet.ibm.com>
Cc: stable@vger.kernel.org
parent 614a80e4
...@@ -986,11 +986,21 @@ int set_guest_storage_key(struct mm_struct *mm, unsigned long addr, ...@@ -986,11 +986,21 @@ int set_guest_storage_key(struct mm_struct *mm, unsigned long addr,
pte_t *ptep; pte_t *ptep;
down_read(&mm->mmap_sem); down_read(&mm->mmap_sem);
retry:
ptep = get_locked_pte(current->mm, addr, &ptl); ptep = get_locked_pte(current->mm, addr, &ptl);
if (unlikely(!ptep)) { if (unlikely(!ptep)) {
up_read(&mm->mmap_sem); up_read(&mm->mmap_sem);
return -EFAULT; return -EFAULT;
} }
if (!(pte_val(*ptep) & _PAGE_INVALID) &&
(pte_val(*ptep) & _PAGE_PROTECT)) {
pte_unmap_unlock(*ptep, ptl);
if (fixup_user_fault(current, mm, addr, FAULT_FLAG_WRITE)) {
up_read(&mm->mmap_sem);
return -EFAULT;
}
goto retry;
}
new = old = pgste_get_lock(ptep); new = old = pgste_get_lock(ptep);
pgste_val(new) &= ~(PGSTE_GR_BIT | PGSTE_GC_BIT | pgste_val(new) &= ~(PGSTE_GR_BIT | PGSTE_GC_BIT |
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment