Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp4429949rwl; Mon, 3 Apr 2023 05:04:29 -0700 (PDT) X-Google-Smtp-Source: AKy350b5QzafIwgDQ55f1byurN8sCASlqX61dgaKOLUZn5MpEbv0vuxX1KBQZujyBhTDDko9IOjk X-Received: by 2002:a17:907:1c93:b0:93e:908d:cfe2 with SMTP id nb19-20020a1709071c9300b0093e908dcfe2mr41536506ejc.0.1680523468774; Mon, 03 Apr 2023 05:04:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680523468; cv=none; d=google.com; s=arc-20160816; b=yxaQv+Ig5ixJS3JnC7+JAn52kWlVxyDr+kCjyIG45BUdhh9Z73O2wPVNavV8CIkQYw 5TzZ2ULu88CMPZXv0Hdavf3jRe+3Jnr1tEEhImepUoZIGqMG9IEFc6wpBHGu9t2CXtVq t0+6Mz/DyJkEuy55HbeoPrrkdD392dPln/YLZ1nqcwtrYKYdQ/gBSFrRJFhZ3VnBe1RA PLoPtKXw+k3mj1rKe5lZrOrpycpH5q4UCmoa4ikmkMqfs6mFTeOmJTRx4UumA0rhWXOi V2re1IQdc93GO1g8ahD/PXyuiXXuzd0NqyUSKTiojwzxk/blqDInfF5riJjUUcSI586f aQVg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:subject :organization:from:references:cc:to:content-language:user-agent :mime-version:date:message-id:dkim-signature; bh=OVIwWquixww+JFF4EZop7Ld7XWMwZqHJw07biyoMhrs=; b=EegpAQE4tzW4QtjpQ8wsomYc1AnTWfSjlR1Lph2UeMzXtBPyMaOiVtXlDVmjlRDWlu dmg/DK54Du8L0ImPRoe6MMYPYSB8iDij0QCqbIqa4+NZHpJtTYtJl372AgdlZq4BIC71 nHJVDDDYS4nZUp+M1exlSEOHWIifTOo397Jx412ceiG7KqGRzF14UMvpu3vEuS/uEILP vcA2tWovcaCsmmZfSy1Mnx+DVmU1Yh5l2+Ke1JG5aRAHyiKMkLSkuJ4jKSJWRXtTa5P+ 4TzYdz7eXiKZutpUd5YO7v4iUSvySxwQR8yImC4+9rsZsUTqvsZ6b2nG70qW92eW8Rov rd8w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=D5fF3joT; 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=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t6-20020a1709066bc600b009477edafcb1si1013018ejs.882.2023.04.03.05.04.03; Mon, 03 Apr 2023 05:04:28 -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=@redhat.com header.s=mimecast20190719 header.b=D5fF3joT; 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=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231833AbjDCL65 (ORCPT + 99 others); Mon, 3 Apr 2023 07:58:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54904 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229446AbjDCL64 (ORCPT ); Mon, 3 Apr 2023 07:58:56 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E30154691 for ; Mon, 3 Apr 2023 04:58:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1680523089; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=OVIwWquixww+JFF4EZop7Ld7XWMwZqHJw07biyoMhrs=; b=D5fF3joTCY0fkbdaP27EX0/SkQL1BTwWcuz5aCesP0xdQERYv41LhhkrW2mHIVRTd3AxXz PybsCgkuCluNKcYAbwQp1xAr2ErDw8/P22ladIbwGG1BIWMJ2d7bVUZkDTTSdIv68WVMgs 4A+mWnFEFd6s4Wy6HX1tEh2AeEim+Lo= Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-365-3RS8N5dZNcqfRxHCExDAiQ-1; Mon, 03 Apr 2023 07:58:08 -0400 X-MC-Unique: 3RS8N5dZNcqfRxHCExDAiQ-1 Received: by mail-wm1-f70.google.com with SMTP id m27-20020a05600c3b1b00b003ee502f1b16so14420374wms.9 for ; Mon, 03 Apr 2023 04:58:07 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680523087; h=content-transfer-encoding:in-reply-to:subject:organization:from :references:cc:to:content-language:user-agent:mime-version:date :message-id:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=OVIwWquixww+JFF4EZop7Ld7XWMwZqHJw07biyoMhrs=; b=xpKO1KSwzBjdqWtJqxQPyrTAXbCYcUOetLk6XztSRS15y31nzjsLklOAXsfxSGpXUe lTyDdVF6tGyGlIMC5FvLANTI5igjCOcHdIMfBoWocRqwUx3l4jmeOxE//im58Ds/zCkQ Q/2SQO4Y7SIbBuYY6/QaU0vXYk1b0OfGWUJufq1Tba4rZZy1OF9rVM7wszoO4xPeDD5P 3yiXPQyK/xH57g5rIKTJ+IhBM3+EASdDMjlY8T48DSXmDTajyn7jHFPvM9G3pQ2CZMF/ OY9jFUijW/wvcxnMDMY97uqAnH1aj8WpLZE9yd88fcf5TgyzLxy4WAk+7zePsNBF///O nneA== X-Gm-Message-State: AAQBX9dvJ7P29QP4iWJJFX3sQ48GBfvd0QwpSPIcDUk9treC+MpiriOu vm8uQNEYXRpmEYLXK1sL+C+qFiYZffUYPivajgJS8mCVeS/KKOXlDgyJz8dntfAJgszF7TQSNnB NGIDJhFd2A9TuC3fJurLmPYWq X-Received: by 2002:a7b:c4c3:0:b0:3f0:3d47:2cbe with SMTP id g3-20020a7bc4c3000000b003f03d472cbemr9925361wmk.10.1680523086945; Mon, 03 Apr 2023 04:58:06 -0700 (PDT) X-Received: by 2002:a7b:c4c3:0:b0:3f0:3d47:2cbe with SMTP id g3-20020a7bc4c3000000b003f03d472cbemr9925348wmk.10.1680523086654; Mon, 03 Apr 2023 04:58:06 -0700 (PDT) Received: from ?IPV6:2003:cb:c702:5e00:8e78:71f3:6243:77f0? (p200300cbc7025e008e7871f3624377f0.dip0.t-ipconnect.de. [2003:cb:c702:5e00:8e78:71f3:6243:77f0]) by smtp.gmail.com with ESMTPSA id t14-20020a05600c198e00b003ee1e07a14asm19260533wmq.45.2023.04.03.04.58.05 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 03 Apr 2023 04:58:05 -0700 (PDT) Message-ID: Date: Mon, 3 Apr 2023 13:58:04 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.9.1 Content-Language: en-US To: stsp , Linux Kernel Mailing List Cc: linux-mm@kvack.org, =?UTF-8?Q?Jakub_Mat=c4=9bna?= , Hugh Dickins , Vlastimil Babka , "Peter Zijlstra (Intel)" References: <18c36a78-4082-fab6-c7c9-69a249516803@yandex.ru> From: David Hildenbrand Organization: Red Hat Subject: Re: MREMAP_FIXED unmaps dest on error In-Reply-To: <18c36a78-4082-fab6-c7c9-69a249516803@yandex.ru> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-1.5 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE 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 On 30.03.23 17:48, stsp wrote: > Hello. > > The attached test-case demonstrates a > bug in mremap(). If MREMAP_FIXED is used > over an existing mapping and mremap() fails, > destination area gets unmapped. > AFAIK the failed syscall should have no > observable effects. I remember that holds for various mapping-related syscalls: if something goes wrong, the end result is not guaranteed to be what we had before the syscall. For example, if you use mmap(MAP_FIXED) to replace part of an exiting mapping, we first munmap what's there and then try to mmap the new mapping. If something goes wrong while doing that, we cannot simple undo what we already did. Long story short: the semantics of these syscalls has never been to leave the system in the state as it was before in case anything goes wrong. As another example, if you do an mprotect() that covers multiple VMAS, and there is an issue with the last VMA, all but the last VMA will have their permissions changed. -- Thanks, David / dhildenb