From patchwork Mon Jan 31 16:02:52 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Muchun Song X-Patchwork-Id: 12730827 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6D6BBC433FE for ; Mon, 31 Jan 2022 16:04:23 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D8EF66B00C3; Mon, 31 Jan 2022 11:04:22 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id D37D36B00C5; Mon, 31 Jan 2022 11:04:22 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B37D88D0001; Mon, 31 Jan 2022 11:04:22 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0194.hostedemail.com [216.40.44.194]) by kanga.kvack.org (Postfix) with ESMTP id 903016B00C3 for ; Mon, 31 Jan 2022 11:04:22 -0500 (EST) Received: from smtpin10.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 4EAE792DEC for ; Mon, 31 Jan 2022 16:04:22 +0000 (UTC) X-FDA: 79091054364.10.AF29CC7 Received: from mail-pj1-f43.google.com (mail-pj1-f43.google.com [209.85.216.43]) by imf01.hostedemail.com (Postfix) with ESMTP id AA40F40026 for ; Mon, 31 Jan 2022 16:04:17 +0000 (UTC) Received: by mail-pj1-f43.google.com with SMTP id b1-20020a17090a990100b001b14bd47532so14329324pjp.0 for ; Mon, 31 Jan 2022 08:04:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=cll0HiNGaOM9yDWI60AkgZZ8Vcgf+tRA3oZc4UBL7nk=; b=kqcwDry5uO65hxuBb6yCzUOH/a1vV6vXhHnghWYmZE0wFwKVg4sDSVN/IFdkti1vxa gH7qY1qLoeC+cKiFHLrznIF/YZZj/5AhGagvceyAcyEcWWJMLsMqThARBDdu+bmGE+PX x6nXbH2i4BHnV1zU3rPxoNPPkey5wfOwbpO2l++PZiNesvMkQiFad2sph+apeltel7aQ Ls1SJTkFiJ4YqR9pdlN4r7l0tC31BgRrY8AyIlvoJPiUU/g7awJtPbivAom+ouD7h5rh 4fLe2DLqgbdp4M3crNsgRcakjECmczJ67k4TbCKpIhxWYZao52P3BXYCUZuUbN4s2YZS rVFQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=cll0HiNGaOM9yDWI60AkgZZ8Vcgf+tRA3oZc4UBL7nk=; b=2YX1nUu2ihRDqJclUY/jg9g8gr3dGDfgYORAgCFnNr9zT2tYKyzxMzcQ+76P4GD+Bx UrRAUVE9+1Y3G20/nlHM6z3994O5NurhvsZZB0sQXpeM8i0afPeGLE6VGsr2z++DUv3y JusRaXwxad7zBRv1S2lspgqR1SgA4vOLUD3zzbjplxRm3g+S5Gezn04THmDw693wRzZj BZgK5a/HFJhd04ake7liMtUV1e/JmCWbSmFwOjMDQKoi6ndrgii76+JTu0PMp+ZCtZPe Ptxsp+nYYv1ColLaoGyrhv94F8sFfMdufiYWUNz+FmiS0gbl4UtsoB22qpgI3PVb9dZf kQcQ== X-Gm-Message-State: AOAM532AXJ9qVzXi3S3QG+CygJoyQxt8fcoQioS1zPL89SiwyrQ/hBks +AU824zy8Jo8MrHZjWDEcuX5Cw== X-Google-Smtp-Source: ABdhPJxZJ+tEgViLwu3F1PuG3ikPoO/2NiO4jJZJUhCFbhH2t+GN/XLwxc/o0L5yrU9nizfHfRLOTw== X-Received: by 2002:a17:902:e788:: with SMTP id cp8mr21004336plb.172.1643645055966; Mon, 31 Jan 2022 08:04:15 -0800 (PST) Received: from FVFYT0MHHV2J.tiktokcdn.com ([139.177.225.244]) by smtp.gmail.com with ESMTPSA id n42sm17940716pfv.29.2022.01.31.08.04.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 31 Jan 2022 08:04:15 -0800 (PST) From: Muchun Song To: akpm@linux-foundation.org, zi.yan@cs.rutgers.edu, kirill.shutemov@linux.intel.com, rientjes@google.com, lars.persson@axis.com, mike.kravetz@oracle.com Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, duanxiongchun@bytedance.com, Muchun Song Subject: [PATCH v3 3/5] mm: hugetlb: fix missing cache flush in copy_huge_page_from_user() Date: Tue, 1 Feb 2022 00:02:52 +0800 Message-Id: <20220131160254.43211-4-songmuchun@bytedance.com> X-Mailer: git-send-email 2.32.0 (Apple Git-132) In-Reply-To: <20220131160254.43211-1-songmuchun@bytedance.com> References: <20220131160254.43211-1-songmuchun@bytedance.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: AA40F40026 X-Rspam-User: nil Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b=kqcwDry5; dmarc=pass (policy=none) header.from=bytedance.com; spf=pass (imf01.hostedemail.com: domain of songmuchun@bytedance.com designates 209.85.216.43 as permitted sender) smtp.mailfrom=songmuchun@bytedance.com X-Stat-Signature: xyjakwjipjixetqmnjm1xkh1jkyun5zo X-Rspamd-Server: rspam08 X-HE-Tag: 1643645057-473753 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: The 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(). Fixes: fa4d75c1de13 ("userfaultfd: hugetlbfs: add copy_huge_page_from_user for hugetlb userfaultfd support") Signed-off-by: Muchun Song --- mm/memory.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mm/memory.c b/mm/memory.c index e8ce066be5f2..eb027da68aa7 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -5405,6 +5405,8 @@ long copy_huge_page_from_user(struct page *dst_page, if (rc) break; + flush_dcache_page(subpage); + cond_resched(); } return ret_val;