From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5CFBC6453 for ; Tue, 22 Mar 2022 21:42:00 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 28467C36AE3; Tue, 22 Mar 2022 21:42:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1647985320; bh=pvulDPwyizhgGDxa4jhwBc0U3Z5T0u8pV4nxemqXHIo=; h=Date:To:From:In-Reply-To:Subject:From; b=PvCTD+JzzxO/UlwcN4mHCJbJ4+rUhaARV7ubSxnLxFkENXo2LFcyV+P1fVYvg9FHz 3IUvp9keQEPtHk5ZVtX6QiCOw0hG9NhRLCUGY2eYZnogQtdX5iNrOwQu04Qnr1jkoV M3etRAbIjHBkdEThQDt2D1YCf3hT5qOaKrocjV2Q= Date: Tue, 22 Mar 2022 14:41:59 -0700 To: ziy@nvidia.com,rientjes@google.com,peterx@redhat.com,mike.kravetz@oracle.com,lars.persson@axis.com,kirill.shutemov@linux.intel.com,fam.zheng@bytedance.com,duanxiongchun@bytedance.com,axelrasmussen@google.com,songmuchun@bytedance.com,akpm@linux-foundation.org,patches@lists.linux.dev,linux-mm@kvack.org,mm-commits@vger.kernel.org,torvalds@linux-foundation.org,akpm@linux-foundation.org From: Andrew Morton In-Reply-To: <20220322143803.04a5e59a07e48284f196a2f9@linux-foundation.org> Subject: [patch 068/227] mm: hugetlb: fix missing cache flush in copy_huge_page_from_user() Message-Id: <20220322214200.28467C36AE3@smtp.kernel.org> Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: From: Muchun Song Subject: mm: hugetlb: fix missing cache flush in copy_huge_page_from_user() userfaultfd calls copy_huge_page_from_user() which does not do any cache flushing for the target page. Then the target page will be mapped to the user space with a different address (user address), which might have an alias issue with the kernel address used to copy the data from the user to. Fix this issue by flushing dcache in copy_huge_page_from_user(). Link: https://lkml.kernel.org/r/20220210123058.79206-4-songmuchun@bytedance.com Fixes: fa4d75c1de13 ("userfaultfd: hugetlbfs: add copy_huge_page_from_user for hugetlb userfaultfd support") Signed-off-by: Muchun Song Reviewed-by: Mike Kravetz Cc: Axel Rasmussen Cc: David Rientjes Cc: Fam Zheng Cc: Kirill A. Shutemov Cc: Lars Persson Cc: Peter Xu Cc: Xiongchun Duan Cc: Zi Yan Signed-off-by: Andrew Morton --- mm/memory.c | 2 ++ 1 file changed, 2 insertions(+) --- a/mm/memory.c~mm-hugetlb-fix-missing-cache-flush-in-copy_huge_page_from_user +++ a/mm/memory.c @@ -5444,6 +5444,8 @@ long copy_huge_page_from_user(struct pag if (rc) break; + flush_dcache_page(subpage); + cond_resched(); } return ret_val; _