Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp3056375rwe; Mon, 29 Aug 2022 05:14:41 -0700 (PDT) X-Google-Smtp-Source: AA6agR4Z0cfepG1QCfS3wXAOLwKjbWPo3/fUdukL65gRBXkSnt0TRqRog0RMpD6AsNqRhzWWyVGy X-Received: by 2002:a17:90b:1c8e:b0:1f7:5250:7b44 with SMTP id oo14-20020a17090b1c8e00b001f752507b44mr18210633pjb.212.1661775280941; Mon, 29 Aug 2022 05:14:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661775280; cv=none; d=google.com; s=arc-20160816; b=DIBBusI6HlcwID+lCSiDjN+mrFejiAz0BiL+fODGaxgV4LGYWCBSeVFRkoHFE42c9d EwSXUjzsSyCb7ICoMWAphNYu0DT1WkXsFJU55VzlL6mI/iDhKEBWg9F8q1nDRsetH4Et VnVcb7MO9AwypVXv1hIzxzTrHIuPXFS9bFDjZbLKhHmmuZEwhgrEKUM/1hacYsgPaiLt cRUU0a3z0nYNBtwSbWk7W9HIE22UdTdZjLWoje6bHH6IWyLggdNOOgIQS/j4O4L+FOX7 VPAy6HrG89Hmr1jESvEKSHcdaQwzmrtLGm7rgCAgpPIMSnbci68QIlq6KYAOPLDX/TKW 6nCw== 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=ppJJkHoHnl0AiexoWndITtUEYZmZZznwrFXpyjJCIdM=; b=vmf+ZaY4n2t/nrAGTvlZT3o+UVWn9ZJhLwsIYl2amxQ0wbKmdyo0poIOH79sjsVEcs 1BV3Uxl2KYyT6QAJhsENP+JRNsXkGuKeGjQPldWyK3caTkU0t80PyCu0Z41xPE7NIuxg 6TjDOgygg+4beKs6DvHe0kWvbyJ+kNA1/zOa/HqZsQIvhQurEXmw9h9C3lVz3ZEWTezE jMAkvDPkg4903ZCeL3SDvZtSDjvEJ+HCYpyMaOByJiSM9OrGxPcpXumgS/Y8SozRjlfI HLqdHXJz8Od+tzjYrAIgohvXKv/PpCu9/OnnEwsJcrONWVTSb8eSq62PiFftxMyBmOl8 mAfQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=DKQyOA3v; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j14-20020a63550e000000b0041e2cc84562si8988809pgb.577.2022.08.29.05.14.28; Mon, 29 Aug 2022 05:14:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=DKQyOA3v; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232627AbiH2LnU (ORCPT + 99 others); Mon, 29 Aug 2022 07:43:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37676 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231438AbiH2Lmy (ORCPT ); Mon, 29 Aug 2022 07:42:54 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7386A857CB; Mon, 29 Aug 2022 04:26:55 -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 18F4761128; Mon, 29 Aug 2022 11:18:51 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2031BC433D6; Mon, 29 Aug 2022 11:18:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1661771930; bh=kqkVxhuCaRG2+GSbJDbaLUZwPMnCwLQMfdS0t1ErPWQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DKQyOA3v/warpGV3X7Y4d/ht/r/3QA/9r+s8JOpo67s28lX1lNKCCVSHUievqg5P4 QM68ZtGzZMdkA42NGVhfMqNhmdM02g7MYzxGahBIilQ47xcq2LAjjloayLH+o4T7n4 QluEFZw4oon+wFHYzPrql6A0HCPwWky27xYbjBvU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Miaohe Lin , Mike Kravetz , Axel Rasmussen , Peter Xu , Andrew Morton Subject: [PATCH 5.19 117/158] mm/hugetlb: avoid corrupting page->mapping in hugetlb_mcopy_atomic_pte Date: Mon, 29 Aug 2022 12:59:27 +0200 Message-Id: <20220829105814.014988421@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220829105808.828227973@linuxfoundation.org> References: <20220829105808.828227973@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham 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: Miaohe Lin commit ab74ef708dc51df7cf2b8a890b9c6990fac5c0c6 upstream. In MCOPY_ATOMIC_CONTINUE case with a non-shared VMA, pages in the page cache are installed in the ptes. But hugepage_add_new_anon_rmap is called for them mistakenly because they're not vm_shared. This will corrupt the page->mapping used by page cache code. Link: https://lkml.kernel.org/r/20220712130542.18836-1-linmiaohe@huawei.com Fixes: f619147104c8 ("userfaultfd: add UFFDIO_CONTINUE ioctl") Signed-off-by: Miaohe Lin Reviewed-by: Mike Kravetz Cc: Axel Rasmussen Cc: Peter Xu Cc: Signed-off-by: Andrew Morton Signed-off-by: Greg Kroah-Hartman --- mm/hugetlb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -6026,7 +6026,7 @@ int hugetlb_mcopy_atomic_pte(struct mm_s if (!huge_pte_none_mostly(huge_ptep_get(dst_pte))) goto out_release_unlock; - if (vm_shared) { + if (page_in_pagecache) { page_dup_file_rmap(page, true); } else { ClearHPageRestoreReserve(page);