From f1cda067ee0006a2e599cdf2112ded2056f4b858 Mon Sep 17 00:00:00 2001 From: zhangzhengming Date: Thu, 8 May 2025 21:52:04 +0800 Subject: [PATCH] mm:fix return handling of cow_user_page h3c inclusion category: bugfix bugzilla: https://gitee.com/openeuler/kernel/issues/IC6J33 -------------------------------- The default return value of the current cow_user_page function is 0. In this case, the wp_page_copy function returns without modifying the page table entry attributes. This leads to repeated retries in page fault scenarios, resulting in an infinite loop. Modify the handling of the return value in the cow_user_page function to ensure logical consistency. Fixes: 8658b10d4cda ("make copy_[user]_highpage_mc have return value") Signed-off-by: zhangzhengming --- mm/memory.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mm/memory.c b/mm/memory.c index f580b9c54247..6013eb177a29 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -2692,7 +2692,7 @@ static inline int cow_user_page(struct page *dst, struct page *src, if (likely(src)) { if (copy_user_highpage_mc(dst, src, addr, vma)) return -EHWPOISON; - return true; + return 0; } /* @@ -2947,7 +2947,7 @@ static vm_fault_t wp_page_copy(struct vm_fault *vmf) goto oom; err = cow_user_page(new_page, old_page, vmf); - if (!err || err == -EHWPOISON) { + if (err) { /* * COW failed, if the fault was solved by other, * it's fine. If not, userspace would re-fault on -- Gitee