Received: by 2002:a05:6a10:7420:0:0:0:0 with SMTP id hk32csp609560pxb; Tue, 15 Feb 2022 23:41:13 -0800 (PST) X-Google-Smtp-Source: ABdhPJxmUmf8DYbTIYubfTu5150b6wuGvbJnqKQSd7HRbNVhMGZWR0RYVW5dy5hJIxb7mJobnt3h X-Received: by 2002:a17:903:2348:b0:14d:d2b6:b71 with SMTP id c8-20020a170903234800b0014dd2b60b71mr1347749plh.35.1644997273342; Tue, 15 Feb 2022 23:41:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644997273; cv=none; d=google.com; s=arc-20160816; b=PMR5b1o3IQCVXN/cG957YXknDsPSlTtEmn/7O77z+C6APeSVJy5wzwFQYDsLHUIqX8 RnmnoorCoB8FuYXraeSjs4pYyI+aMUEWFi2eaxvT/3Qgpwi4edJwo+oN8rnU5HOuqWPk n+8dFBfZUnKdSA3MtNtvm2IP2p4S3Vtak3x+zkrwc48Jho+l67Bs3nQoS0iryoScAOxD e6xA/acEdzcAemS/an7FZpB7A/PMTcB0iJAG4pTFVq61NZE0eaVv7uGJ67cVcDoUsIPB LDZ0IwzQ1DtYH4wV7iz6oTGGcOOS3llozDDGnl18qFIvXNVOcXjwM2olH5+pfOEH16Be 8NXA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=fj0gD7ulTBZq25O5ipO8sbzaZnByNFYzTOaIrem2GJI=; b=AUlHyUckoQRzkv++kmhqfDXIFiLmKwr/LsXbDjfpjhWofKyMVd2lm1fexpuaC8DQ3p sJQ68zSzymFB3gTJK6zcmux5BcAko2WzB0XTxdGCfAmMwebJBcfUQoV8wO6gCU/GuysR a+WVKbS7puQqyd5JSpODWARwNn9d5SuxN/L1plJ+avTyHdJioKGN/S5ozRwBljBJvWv4 zSlHDCXO0pP52e9Drw/6xFVNyl3/V+mYcoamVLtQko17nDTnwyX4dbsfwOyi6TV9UycI URF37vk//MQK9vQ4rXMwAAMm1E+yXTEx4Oxfi2iRinrS+v9ou1Y+18ST9Eat3pMKBTxX H7HQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b="v/JgsETL"; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=bytedance.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id v189si12121269pfb.7.2022.02.15.23.41.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Feb 2022 23:41:13 -0800 (PST) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b="v/JgsETL"; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=bytedance.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 55538251E60; Tue, 15 Feb 2022 23:05:41 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230016AbiBPGRG (ORCPT + 99 others); Wed, 16 Feb 2022 01:17:06 -0500 Received: from gmail-smtp-in.l.google.com ([23.128.96.19]:46318 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229487AbiBPGRE (ORCPT ); Wed, 16 Feb 2022 01:17:04 -0500 Received: from mail-yb1-xb34.google.com (mail-yb1-xb34.google.com [IPv6:2607:f8b0:4864:20::b34]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 38FD363C9 for ; Tue, 15 Feb 2022 22:16:51 -0800 (PST) Received: by mail-yb1-xb34.google.com with SMTP id 124so2912201ybn.11 for ; Tue, 15 Feb 2022 22:16:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance-com.20210112.gappssmtp.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=fj0gD7ulTBZq25O5ipO8sbzaZnByNFYzTOaIrem2GJI=; b=v/JgsETLxe0/hm/AA5GsACF8WbkW5lYlBICmSCPBJRwkdphqlFcGSU4zn7Uia3n8l8 ChzEAUcPZ8tPWX133x+zQZ8B+u5NtXXDbp7FYSXcEv7HM5SI2nn3hfgt3lVy6mXrYbwB 8RvU1KZw+re5hvp27VM8b4Sp8KuYugX2l3Eqg9B3Oc5fd8+SjF7zzRi51zscms/4Ap+O crduJSOlnNUMP1ARucXq1AXRo3bF1P4ntDGqJW6JqO11TK/+ldRM31w5a5NLQQDcVyTE LhLIHUUFBR/J/s7Uk7MF3Bf1nGumQ+tDNUD7qv/oMVJ/PP/uz0quLcmV9DRfKouQxVhq /XQg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=fj0gD7ulTBZq25O5ipO8sbzaZnByNFYzTOaIrem2GJI=; b=nQ32f3Trmd7wPPLJEvHVCt2rL9PDbOXrPapNI/lj9Qun7drJUbUUWyjBZGfUofrerR vJnl5l+M2AMDVQgBVYVxbT2p6MzRPp5a8ngDb/rDkEO2i64XPW/lDpIpE0PcPFpS+r6I pz1BL/x1jYxqFWyzB3hMVWSNmuiMYhzDDpRTrr1mFXuMT7tVKiNTUr36x3qi6Pt0wyDN HAyUjSDv1MSIkThFzkZvRD2OqnQFFlloKj0kkWfeyQVfZ5BZqyvB9nQ7y/s46al73nbI pIkzNvkD7KsqYnicrt4y2etKXYPaK55R2ZLHWl8y+j4SllTz2gwKkwoVBl0qvwpOgSd/ 5VCg== X-Gm-Message-State: AOAM530RVpYTVsKRxz8O+ISkWDOgr2PG7ACP2Hxamn6xi/1xt779OU9r Dmr5bZvFES/7u3Imp/2opp+HmQcr3wLQUeAWDa5Jpw== X-Received: by 2002:a25:d145:0:b0:611:c6ef:7c0d with SMTP id i66-20020a25d145000000b00611c6ef7c0dmr830341ybg.703.1644992210451; Tue, 15 Feb 2022 22:16:50 -0800 (PST) MIME-Version: 1.0 References: <20220210123058.79206-1-songmuchun@bytedance.com> <20220210123058.79206-6-songmuchun@bytedance.com> <39ab53c4-cb2f-82f4-1097-65d000284b23@oracle.com> In-Reply-To: <39ab53c4-cb2f-82f4-1097-65d000284b23@oracle.com> From: Muchun Song Date: Wed, 16 Feb 2022 14:16:13 +0800 Message-ID: Subject: Re: [PATCH v5 5/7] mm: shmem: fix missing cache flush in shmem_mfill_atomic_pte() To: Mike Kravetz Cc: Andrew Morton , zi.yan@cs.rutgers.edu, "Kirill A. Shutemov" , David Rientjes , Lars Persson , Zi Yan , Linux Memory Management List , LKML , Xiongchun duan , Fam Zheng Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Feb 16, 2022 at 3:12 AM Mike Kravetz wrote: > > On 2/10/22 04:30, Muchun Song wrote: > > The userfaultfd calls shmem_mfill_atomic_pte() 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. Insert flush_dcache_page() in non-zero-page case. And replace > > clear_highpage() with clear_user_highpage() which already considers > > the cache maintenance. > > > > Fixes: 8d1039634206 ("userfaultfd: shmem: add shmem_mfill_zeropage_pte for userfaultfd support") > > Fixes: 4c27fe4c4c84 ("userfaultfd: shmem: add shmem_mcopy_atomic_pte for userfaultfd support") > > Signed-off-by: Muchun Song > > --- > > mm/shmem.c | 4 +++- > > 1 file changed, 3 insertions(+), 1 deletion(-) > > Thanks, > > It might have been better to combine this and the next patch. When looking > at this, I noted the 'fallback to copy_from_user outside mmap_lock' case needs > to be addressed as well. It is in the next patch. No need to change. I separate those changes into 2 patches since the fixed patch is different. This patch is fixing linux 4.13 and later, while next patch is fixing linux 4.2 and later. Maybe it is hard to backport if combining those two patches. > > Reviewed-by: Mike Kravetz Thanks Mike.