Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp1045362iob; Fri, 13 May 2022 20:55:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyy91ncYlnGImG4h/0eCbMZJyDJOJEj6o35yj65ok78VzFKPcEbuCIVLV2GLjpRXP1+B0qD X-Received: by 2002:a5d:5987:0:b0:20c:5d7c:b4e3 with SMTP id n7-20020a5d5987000000b0020c5d7cb4e3mr6333120wri.133.1652500518464; Fri, 13 May 2022 20:55:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652500518; cv=none; d=google.com; s=arc-20160816; b=Gw3C7WuS3NILJoqw0hATSv+KDHeFIHMjN9N790SE0LeT4qdYPEB0CNvO2u7X5K1gTb Q3tWlPUQunRApvOhoP+5dfO7krlpMSiHWCMcX8xX9q2HkGFRVV6xh1tV5NYkvwe+AdGU 516TYI+YUGARvo8GsEN8Q3ESBE688w56wn2qo6SWfF6GB//pfmVjHVL0u0oSufJFQu/l uh6u8h904g9MmiNEONrI708hdlZf22AU39csW8C/YF+XUCT/CW7epZpXueMEFlr8gsBQ iJfUKk8xjHItezllhaQxC7yFkx5IMaoUArzuIXC/GFoB4GlEpJQxPSKE9bD2du2iTRGH DEhQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=YY06Wq9XtVqBbrR7E7LdV+aEZv+xpDXvrFmdDwuW+Hw=; b=wMc/DlV7ZFIAIap1Ks9aBGPEyUnCCu+zIyr1KimR8Zg4T2TSVDGMBPJ4fWIhP6PP0v MVWjZXc6CpOenypymi6SIsKA9IkHb3D3Dovp5/G/1+uB8RAqhRyc0z/ZOc3nUUZWzgoq FXdReAG9IP95rc30YqXnmlK/sJvqOEQ3S2y5OmtJdzu0EHRfxWCQuiFGSWv7XzHKW9Dd JK02ihKD7bmSoEq31dlZ3zLIcaf6xcj2c4ImEIraOkdq7SdmDb34y2O/EUyXIVVxUUwS xYF7qXdVw8tLTL0vGRD7gh7eGKHaPJME+Ah5OFQsSJGXdz2J/UjUEnjhbuwElMBPShQL a1GA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Rr3hmb0G; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id o6-20020a05600c510600b003943fe43a0asi4592889wms.204.2022.05.13.20.55.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 May 2022 20:55:18 -0700 (PDT) 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=@linuxfoundation.org header.s=korg header.b=Rr3hmb0G; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id E7D3748CCDF; Fri, 13 May 2022 17:27:35 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1381065AbiEMOaj (ORCPT + 99 others); Fri, 13 May 2022 10:30:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40532 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1380735AbiEMOZ6 (ORCPT ); Fri, 13 May 2022 10:25:58 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 75AEA6B67A; Fri, 13 May 2022 07:25:22 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id E0E6662198; Fri, 13 May 2022 14:25:21 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id BFAC7C36AF6; Fri, 13 May 2022 14:25:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1652451921; bh=5bib3ZlM1WmxHuZRocWWOlskoPQq6BEw+c52UWjFo70=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Rr3hmb0G4sAt63ozbC/GrwwKcvK5WnhBcxE//DpR229O4ZigS2dpkiYMQbN/iEh4W jlga90oTVKWx5rjZTYdGoxRgqJOMxWWMTz7SpjRQlsAuYN/R227kcegB5Zf4xH30z6 ZdywT8YsRYjHscej2V+es0gXSp4iEyBTseQgzEHs= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Muchun Song , Mike Kravetz , Axel Rasmussen , David Rientjes , Fam Zheng , "Kirill A. Shutemov" , Lars Persson , Peter Xu , Xiongchun Duan , Zi Yan , Andrew Morton , Linus Torvalds Subject: [PATCH 4.14 07/14] mm: hugetlb: fix missing cache flush in copy_huge_page_from_user() Date: Fri, 13 May 2022 16:23:23 +0200 Message-Id: <20220513142227.599609402@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220513142227.381154244@linuxfoundation.org> References: <20220513142227.381154244@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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 From: Muchun Song commit e763243cc6cb1fcc720ec58cfd6e7c35ae90a479 upstream. 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 Signed-off-by: Linus Torvalds Signed-off-by: Greg Kroah-Hartman --- mm/memory.c | 2 ++ 1 file changed, 2 insertions(+) --- a/mm/memory.c +++ b/mm/memory.c @@ -4836,6 +4836,8 @@ long copy_huge_page_from_user(struct pag if (rc) break; + flush_dcache_page(subpage); + cond_resched(); } return ret_val;