From patchwork Thu Feb 10 12:30:54 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Muchun Song X-Patchwork-Id: 12741874 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 82CF2C433EF for ; Thu, 10 Feb 2022 12:37:36 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id F11FF6B007B; Thu, 10 Feb 2022 07:37:35 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id EC1796B007D; Thu, 10 Feb 2022 07:37:35 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D8B746B007E; Thu, 10 Feb 2022 07:37:35 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0144.hostedemail.com [216.40.44.144]) by kanga.kvack.org (Postfix) with ESMTP id C985E6B007B for ; Thu, 10 Feb 2022 07:37:35 -0500 (EST) Received: from smtpin24.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 872ED1BFF42 for ; Thu, 10 Feb 2022 12:37:35 +0000 (UTC) X-FDA: 79126821270.24.5443057 Received: from mail-pj1-f48.google.com (mail-pj1-f48.google.com [209.85.216.48]) by imf28.hostedemail.com (Postfix) with ESMTP id 27CCAC0003 for ; Thu, 10 Feb 2022 12:37:35 +0000 (UTC) Received: by mail-pj1-f48.google.com with SMTP id c5-20020a17090a1d0500b001b904a7046dso6824770pjd.1 for ; Thu, 10 Feb 2022 04:37:34 -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=kCvGgcRI4BCb4bo+PLBmo+rPOq2UtF9zlalPG6igjOk=; b=nk3w1/O8ruce/KxIcFhyUO1pVaNj82bb2o0RtC+Eqn+gFpTDRTDEEO+SUjkKii+bMA 6/XUIHV6zMhbdvk0KD8AaMfYxOjdrDE/7BPf2Z1eS3SWvotZrlr+0FHt9//kPbH5xExr QBMsk7iVC+lbtURShOMph5ee0edzKKy8tr0ltF1A0FHWFQrbjSd6iU3q6WGP9e8BVY17 9SsD6HPxj3Z6fmn3OcjrV8uLz3kbddDZFxPxIcLS9FKpC8iZfZiXhVY5IdjLNbA2qjSP kyJe8qybWut+rnxiXLz/UUmADHvH367cikWiEbu+7LMtZO3nb/X5hv0TeKzr6J8tdMIc UEdA== 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=kCvGgcRI4BCb4bo+PLBmo+rPOq2UtF9zlalPG6igjOk=; b=QwrO2+1rgU+j9rOHjfzkS9OZOp7hVXFMh9zDpyzb0wEnaOKfKTQtXO09+LR5oedFE1 Dy2XxILhF++ZuEbZ/B/37ubNZJ0s7kcZVp0xsnd7hR4H5Ov2HBm0rQJidJo5uC2DssAi 0a7NVlsM+qMxyxhcW37Iu7oKudAopGx0ZU4hkEtkN0aFtZq139sNHbfZH6PJlzIcP+HM MpkSRkoqXmlnWo+ck5y6kX9XQS65ZUkcWBuqgIesYQF4BeV4SgTxqbILuuo8wUEcZpT1 /LLbRSJPZt5C/TAXUj6hz9eNGXnAWQ82VlFefzrX6Fga4UfJJrsjN5lbgJnJ5XUdYTnO 4u/g== X-Gm-Message-State: AOAM531BJxP8QU+7zCeMTDMtWajG95GTdClyAeCxo6oJavFkGhHU5xRC uzOrIaRfC2LfSCDXmR/Rt8HRsA== X-Google-Smtp-Source: ABdhPJydgYDL68pV4tg6C9n6s9P9xqUtx6BfUfSjlx18xcMF5d9QufoEkJRRr1Q5wwnwW+Wqm5H7Zw== X-Received: by 2002:a17:902:e743:: with SMTP id p3mr1888043plf.152.1644496654350; Thu, 10 Feb 2022 04:37:34 -0800 (PST) Received: from FVFYT0MHHV2J.tiktokcdn.com ([139.177.225.237]) by smtp.gmail.com with ESMTPSA id i8sm11767812pgf.94.2022.02.10.04.37.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Feb 2022 04:37:34 -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, ziy@nvidia.com Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, duanxiongchun@bytedance.com, fam.zheng@bytedance.com, Muchun Song Subject: [PATCH v5 3/7] mm: hugetlb: fix missing cache flush in copy_huge_page_from_user() Date: Thu, 10 Feb 2022 20:30:54 +0800 Message-Id: <20220210123058.79206-4-songmuchun@bytedance.com> X-Mailer: git-send-email 2.32.0 (Apple Git-132) In-Reply-To: <20220210123058.79206-1-songmuchun@bytedance.com> References: <20220210123058.79206-1-songmuchun@bytedance.com> MIME-Version: 1.0 Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b="nk3w1/O8"; spf=pass (imf28.hostedemail.com: domain of songmuchun@bytedance.com designates 209.85.216.48 as permitted sender) smtp.mailfrom=songmuchun@bytedance.com; dmarc=pass (policy=none) header.from=bytedance.com X-Stat-Signature: i88m8aibxfnof8aqaxzh885un6upqur8 X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 27CCAC0003 X-Rspam-User: X-HE-Tag: 1644496655-967714 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 Reviewed-by: Mike Kravetz --- 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;