Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp2063644rwl; Thu, 30 Mar 2023 05:40:13 -0700 (PDT) X-Google-Smtp-Source: AKy350ZHd6dtHgoZ9Nq4A16Red4e3ugNo9zatd5kD2I9dGKmY/5kCP/Onj6IMnKHPp5aK46l5pWQ X-Received: by 2002:a05:6a00:450e:b0:625:a08c:a8ba with SMTP id cw14-20020a056a00450e00b00625a08ca8bamr21205405pfb.1.1680180012909; Thu, 30 Mar 2023 05:40:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680180012; cv=none; d=google.com; s=arc-20160816; b=L4pEytmCiBoFgaAPgfL5XTxkAb2CuRj9+J3G47RGMrHO9JnlKxlQBm3UauR0is4EmO LG1rmfHTKYWrKUEeRzzlDzVfFPc+4lzpRJyS72g7n4RvM/4IG4asWT+3N1mLIpATH3fr MR+Kwkkd6jCjOg1dgh8IRYHDcgcwPyPhPNQpkhOuBqZoBmeA9OKucxTWUHESs9mGfJ5K CRd8MSOZuhZ/jhnJwxP0XTY0whJZHX8JBI3ucbKWf/QIq1nXNnPUHJUnA4/Dw04lVWQb HJc6Kn4lLM+HlqzsPkGDhM+JW5LxQkmXTBzzlut+BQ7ZVi16Xh3p93s/MRU9SnRMMZ9N r1fw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:subject:from:to:content-language:user-agent :mime-version:date:message-id:dkim-signature; bh=AUfUxWMmLzsWr9J8KyIIOEW5XdM2YJZTIzMN2LQK6rM=; b=cU0QD7iMGyITVd5sQFT8TCLqoRKjBRRyLEhQZqGAIxolw9NRpMWWeEInAE1+YwLc/v DU/OZ7YK1OBFZWnMEWZi9rpamjNa085yP6Xd3w7yXQRqpqFZb6ptrIkc3opbBCZiaO8O iqO8HOTE3JM768JgEXzhjQJvXtM3+k6HC3IumFe73hCrOBf//vjFVc3eo5+4urFemFrN 7EFoDgd/zRozlbPFtfD8uIeLpw18NGkTJdGIIlWc4ZtszlCVKio9OXtAeCMl7YL4xPKS KiBwQOFTFgMbZptUo8ILY8jxAFkRZPIo6Xt/8I0j0lR2eEHd+FwbE8xrcq6JelTySpy4 dDmg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@yandex.ru header.s=mail header.b="pti/RoUJ"; 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=yandex.ru Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d8-20020a056a0010c800b00627f37f3ca1si28344258pfu.246.2023.03.30.05.40.00; Thu, 30 Mar 2023 05:40:12 -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=@yandex.ru header.s=mail header.b="pti/RoUJ"; 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=yandex.ru Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230321AbjC3Miw (ORCPT + 99 others); Thu, 30 Mar 2023 08:38:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32828 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229923AbjC3MiW (ORCPT ); Thu, 30 Mar 2023 08:38:22 -0400 X-Greylist: delayed 68073 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Thu, 30 Mar 2023 05:38:21 PDT Received: from forward206c.mail.yandex.net (forward206c.mail.yandex.net [178.154.239.215]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9078672BA for ; Thu, 30 Mar 2023 05:38:21 -0700 (PDT) Received: from mail-nwsmtp-smtp-production-main-69.iva.yp-c.yandex.net (mail-nwsmtp-smtp-production-main-69.iva.yp-c.yandex.net [IPv6:2a02:6b8:c0c:610a:0:640:be20:0]) by forward206c.mail.yandex.net (Yandex) with ESMTP id 21AB3600FF; Thu, 30 Mar 2023 15:38:18 +0300 (MSK) Received: by mail-nwsmtp-smtp-production-main-69.iva.yp-c.yandex.net (smtp/Yandex) with ESMTPSA id GcI7wM1Dba60-KLRgsifT; Thu, 30 Mar 2023 15:38:17 +0300 X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex.ru; s=mail; t=1680179897; bh=AUfUxWMmLzsWr9J8KyIIOEW5XdM2YJZTIzMN2LQK6rM=; h=Cc:Subject:To:Message-ID:Date:From; b=pti/RoUJV3jh0s2ptDQf5/Lh3HH0bI+tBPsgcTB/fxAS2LpLSyFQ4PHDc0Mab0R5d hWbTYXJAuKgr+9p8vtW5uU1tDV1F+lPaa5YB3n5aw2uhtLSw84QUF+lcwvvoINQuEu SNxLpbVwJQi5NdQcVZdSS5KmiHk1BcP5bzRhdZpw= Authentication-Results: mail-nwsmtp-smtp-production-main-69.iva.yp-c.yandex.net; dkim=pass header.i=@yandex.ru Content-Type: multipart/mixed; boundary="------------J3j8IHe1JzGMO5Jt5X1dfnsH" Message-ID: Date: Thu, 30 Mar 2023 17:38:15 +0500 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.7.1 Content-Language: en-US To: Linux Kernel Mailing List From: stsp Subject: MREMAP_DONTUNMAP corrupts initial mapping Cc: linux-mm@kvack.org X-Spam-Status: No, score=0.1 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT,FREEMAIL_FROM, SPF_HELO_NONE,SPF_PASS 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 This is a multi-part message in MIME format. --------------J3j8IHe1JzGMO5Jt5X1dfnsH Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Hello. Attached is a small test-case that demonstrates the problem. The problem happens if you change some data in a file-backed private mapping and then use mremap on it with MREMAP_DONTUNMAP flag. The result is: - destination copy is valid - source copy restored from the original file So the 2 copies do not match. --------------J3j8IHe1JzGMO5Jt5X1dfnsH Content-Type: text/x-csrc; charset=UTF-8; name="mretst.c" Content-Disposition: attachment; filename="mretst.c" Content-Transfer-Encoding: base64 I2RlZmluZSBfR05VX1NPVVJDRQojaW5jbHVkZSA8c3lzL21tYW4uaD4KI2luY2x1ZGUgPGFz c2VydC5oPgojaW5jbHVkZSA8c3RkbGliLmg+CiNpbmNsdWRlIDxmY250bC5oPgojaW5jbHVk ZSA8c3RkaW8uaD4KI2luY2x1ZGUgPHVuaXN0ZC5oPgoKI2lmbmRlZiBQQUdFX1NJWkUKI2Rl ZmluZSBQQUdFX1NJWkUgNDA5NgojZW5kaWYKCmludCBtYWluKHZvaWQpCnsKICAgIGNvbnN0 IGNoYXIgKmZpbGUgPSAibXJldHN0LmMiOwogICAgY2hhciAqYWRkciwgKmFkZHIyOwogICAg aW50IGZkOwogICAgY2hhciBjOwoKICAgIGZkID0gb3BlbiAoZmlsZSwgT19SRE9OTFkpOwog ICAgaWYgKGZkID09IC0xKQogICAgICAgIHJldHVybiBFWElUX0ZBSUxVUkU7CiAgICBhZGRy ID0gbW1hcCAoTlVMTCwgUEFHRV9TSVpFLCBQUk9UX1JFQUQgfCBQUk9UX1dSSVRFLCBNQVBf UFJJVkFURSwgZmQsIDApOwogICAgY2xvc2UoZmQpOwogICAgaWYgKGFkZHIgPT0gTUFQX0ZB SUxFRCkKICAgICAgICByZXR1cm4gRVhJVF9GQUlMVVJFOwogICAgYyA9IGFkZHJbMF07CiAg ICBhc3NlcnQoYWRkclswXSk7CiAgICBhZGRyWzBdID0gMDsKICAgIGFzc2VydCghYWRkclsw XSk7CiAgICBhZGRyMiA9IG1yZW1hcCAoYWRkciwgUEFHRV9TSVpFLCBQQUdFX1NJWkUsCiAg ICAgICAgICAgICAgICAgICAgTVJFTUFQX01BWU1PVkUgfCBNUkVNQVBfRE9OVFVOTUFQKTsK ICAgIGFzc2VydCghYWRkcjJbMF0pOwogICAgaWYgKGFkZHJbMF0gPT0gYykKICAgICAgICBw cmludGYoIlRlc3QgRkFJTEVEXG4iKTsKICAgIGVsc2UKICAgICAgICBwcmludGYoIlRlc3Qg UEFTU0VEXG4iKTsKICAgIHJldHVybiAwOwp9Cg== --------------J3j8IHe1JzGMO5Jt5X1dfnsH--