From patchwork Tue Feb 8 07:36:15 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Muchun Song X-Patchwork-Id: 12738258 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 CFC04C433F5 for ; Tue, 8 Feb 2022 07:36:48 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6C9CC6B007B; Tue, 8 Feb 2022 02:36:48 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 679D76B007D; Tue, 8 Feb 2022 02:36:48 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 543DD6B007E; Tue, 8 Feb 2022 02:36:48 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (relay.a.hostedemail.com [64.99.140.24]) by kanga.kvack.org (Postfix) with ESMTP id 4583D6B007B for ; Tue, 8 Feb 2022 02:36:48 -0500 (EST) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 0A69E20F87 for ; Tue, 8 Feb 2022 07:36:48 +0000 (UTC) X-FDA: 79118805696.01.E685BCB Received: from mail-pj1-f47.google.com (mail-pj1-f47.google.com [209.85.216.47]) by imf31.hostedemail.com (Postfix) with ESMTP id B880920002 for ; Tue, 8 Feb 2022 07:36:47 +0000 (UTC) Received: by mail-pj1-f47.google.com with SMTP id p22-20020a17090adf9600b001b8783b2647so1325194pjv.5 for ; Mon, 07 Feb 2022 23:36:47 -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=y0jpOk6gAkKem1qpuxCydTJQeI0RYuJhd3oYTOoGI39XA5VyoB+ep0jJ6o+P/dV+6o mlwuzoo+SR5YLg3y2a/BC+MJRoaSWHaJ+qAJZb5Y5tHw3Dvyj2R7bsDTORVKf+0aoy9q Jn9P8oSuy9WMEeo5jqDcltiB2MAuJdmewps+UxFLCGBfsHbB4Nz8BgoO7bfS4ookfhRt fJVNLLDP8w7JHk+3AsBSjsnnR7LoF4EmZz1NN9NARpNJUzV4ELzDvSQGQOwb5dl3rKMT pSdNUaU72b0vAJoGUIJ5R22jT7AVOdSonWMx6C0mW3i1zT2otqX9O90SuABNbMer7Tl8 XOnQ== 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=FjXoyhnSjo99+J1PNVj6cn8cQqg7mewvWj7+e6Y5w1kCEep9X40ggF9BHbdkKymV1T MBLAlhClFxytXt1YBFDpj+97Z7PUgdQy/6alEMsnObfcAw3sqpkeXlrDyVU4quIuoEdx CyA+2lg5+MteuhzQqY56yQd+WMcZhnDX36u4xyJypvUZP4tRBHlxM7EUVdugMvHMTRZg 2HyHmjpvFRsYbG/gwO6pBhiu57g8tvnGyWSdN1buUTsZjnKqcYoACGTz+z/Ug4ubYCQ0 5BRx5eNRQp8I/n5ZjZbXuDd6JfnGQScE6M98j8cbBTa3jC0eteqFa8h18fjuPxc+AjEy 9aqg== X-Gm-Message-State: AOAM532MAKT2GNSQziaz5SyFahXxlkleicre3SiHO0W3YkYvCPXjFyHp JeioRJWG6ILFtJpDhG1pQE6iwQ== X-Google-Smtp-Source: ABdhPJzvsh4kBT5/wdRGyGAAQcGNW7TSFAisLlWR6Pe1OtowTbWhv0vQtaLjIv9HxR4IbxCYWBl48w== X-Received: by 2002:a17:902:b90a:: with SMTP id bf10mr3230897plb.36.1644305806765; Mon, 07 Feb 2022 23:36:46 -0800 (PST) Received: from FVFYT0MHHV2J.tiktokcdn.com ([139.177.225.225]) by smtp.gmail.com with ESMTPSA id gx10sm1621017pjb.7.2022.02.07.23.36.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Feb 2022 23:36:46 -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 v4 3/5] mm: hugetlb: fix missing cache flush in copy_huge_page_from_user() Date: Tue, 8 Feb 2022 15:36:15 +0800 Message-Id: <20220208073617.70342-4-songmuchun@bytedance.com> X-Mailer: git-send-email 2.32.0 (Apple Git-132) In-Reply-To: <20220208073617.70342-1-songmuchun@bytedance.com> References: <20220208073617.70342-1-songmuchun@bytedance.com> MIME-Version: 1.0 X-Rspam-User: Authentication-Results: imf31.hostedemail.com; dkim=pass header.d=bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b=y0jpOk6g; dmarc=pass (policy=none) header.from=bytedance.com; spf=pass (imf31.hostedemail.com: domain of songmuchun@bytedance.com designates 209.85.216.47 as permitted sender) smtp.mailfrom=songmuchun@bytedance.com X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: B880920002 X-Stat-Signature: ppc7acp47cgxsaz9x3pbce66uoas8oi1 X-HE-Tag: 1644305807-784313 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000002, 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;