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

userswap: check read and write permissions for swap-out pages

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



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

Check the VM_READ and VM_WRITE flags of vma->vm_flags to determine
whether the read and write permissions of the swap-out page VA are
consistent with those of the swap-out buffer VA. If they are
inconsistent, the swap operation will fail.

Signed-off-by: default avatarZhangPeng <zhangpeng362@huawei.com>
parent 62d6e76a
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -311,8 +311,8 @@ static unsigned long do_user_swap(struct mm_struct *mm,
			goto out_recover;

		ret = -EACCES;
		if (pgprot_val(old_vma->vm_page_prot) !=
		    pgprot_val(new_vma->vm_page_prot))
		if (!(old_vma->vm_flags & VM_WRITE) &&
		    (new_vma->vm_flags & VM_WRITE))
			goto out_recover;

		ret = -ENXIO;