Commit f087df84 authored by ZhangPeng's avatar ZhangPeng Committed by Ma Wupeng
Browse files

userswap: mark swap-out buffer PTE as writable

hulk inclusion
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I6CAIM



--------------------------------

Add a VM_WRITE check for the swap-out buffer. If the swap-out buffer VMA
contains VM_WRITE, the PTE should be marked as writable.

Signed-off-by: default avatarZhangPeng <zhangpeng362@huawei.com>
parent a81fb608
Loading
Loading
Loading
Loading
+5 −2
Original line number Diff line number Diff line
@@ -215,7 +215,7 @@ static unsigned long vm_insert_anon_page(struct vm_area_struct *vma,
{
	struct mm_struct *mm = vma->vm_mm;
	int ret = 0;
	pte_t *pte;
	pte_t *pte, dst_pte;
	spinlock_t *ptl;

	if (unlikely(anon_vma_prepare(vma)))
@@ -233,7 +233,10 @@ static unsigned long vm_insert_anon_page(struct vm_area_struct *vma,
	inc_mm_counter(mm, MM_ANONPAGES);
	reliable_page_counter(page, mm, 1);
	page_add_new_anon_rmap(page, vma, addr, false);
	set_pte_at(mm, addr, pte, mk_pte(page, vma->vm_page_prot));
	dst_pte = mk_pte(page, vma->vm_page_prot);
	if (vma->vm_flags & VM_WRITE)
		dst_pte = pte_mkwrite(pte_mkdirty(dst_pte));
	set_pte_at(mm, addr, pte, dst_pte);

out_unlock:
	pte_unmap_unlock(pte, ptl);