From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A7A7EEEAA7B for ; Thu, 14 Sep 2023 21:57:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229723AbjINV5Y (ORCPT ); Thu, 14 Sep 2023 17:57:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39220 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229447AbjINV5W (ORCPT ); Thu, 14 Sep 2023 17:57:22 -0400 Received: from mail-pl1-x636.google.com (mail-pl1-x636.google.com [IPv6:2607:f8b0:4864:20::636]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B7C321BFA; Thu, 14 Sep 2023 14:57:18 -0700 (PDT) Received: by mail-pl1-x636.google.com with SMTP id d9443c01a7336-1c0d5b16aacso12418325ad.1; Thu, 14 Sep 2023 14:57:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1694728638; x=1695333438; darn=vger.kernel.org; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=X34N50NaiDX+PBJtKJBqu0HsGsPzsSqdEPNcf7aeIrs=; b=PX2VQQqAiWTaBfzhNszo/To7XsEfIzIpKOBNFVhclk15Ev+P8MYg3cD5ngxpZKFNKH /9V3JJDtBfQwkwOzxW3WplbkYp55+pEXM55fEOCM1ZuDQPUEFrsYgYe+mQ8ae+1wLF/5 IIHi2f1Rcg03TIrsFfpkyjRO/uHjz4aFzhCZSxzd/qNksGpV0zsv8uVr5MR83oTrvyeL p+ovLEkuckafvMBWiCH4+p5XDkOZMmRUGtuz44/m+qS7AHoDqKOGtEut6cQoldMyNVAG TacqQZzSCt5KOvoIJbouYvc4YaSbt+mK6OMstpVI4PBYxwtg8m1fFVXIUOF7B4Cu6cTM h5Ng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694728638; x=1695333438; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=X34N50NaiDX+PBJtKJBqu0HsGsPzsSqdEPNcf7aeIrs=; b=SvVWCdufCR/8/7KP1NlAUj7oLfRWaq1cq4JBaFIGkwO6meKGrlkRoJ85HSjHquwPVM 8olVUlPFt04sAc9CiKCjtH9LQ86FoYzLSjsqJgfY7xZ01A6GN2f7+SV02gQPw5BiA4kK fmhzL03469LO35MN9T7hciN15806X9jEZuo6sbIaVbdlWeE4pcslmoAUO6usITqoyUs9 zYLQ57fISy1lVc7iqXbk9qjYt/1/094ahRCfplBiLpWveKZ9pJWpsQvlCiOUGAz5bEc2 w0PB8zAKuDXoY+Luan9SjKAkzK4P9vDZTq3+rJEZfRsd5oIS6n8d3KlI37hifA/OhofP E3ug== X-Gm-Message-State: AOJu0YxMDdjYddPkBe4dDchIu4LIr+sGqNlVllO7jUWArbbfK9KT+ig/ qYUbTL1ILaRQETn3nYCosb8= X-Google-Smtp-Source: AGHT+IGIaI/uWkQLliCTRlQFV1QfmbwrrxnMWQ0mT8W+Jdap0w9HAyjlgBEZRZvbgXVCbtXJ8c4H3g== X-Received: by 2002:a17:903:2284:b0:1bc:8fca:9d59 with SMTP id b4-20020a170903228400b001bc8fca9d59mr7882429plh.29.1694728638036; Thu, 14 Sep 2023 14:57:18 -0700 (PDT) Received: from smtpclient.apple (c-73-162-233-46.hsd1.ca.comcast.net. [73.162.233.46]) by smtp.gmail.com with ESMTPSA id bb6-20020a170902bc8600b001bba7aab822sm2049158plb.5.2023.09.14.14.57.15 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 14 Sep 2023 14:57:17 -0700 (PDT) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3731.700.6\)) Subject: Re: [PATCH 2/3] userfaultfd: UFFDIO_REMAP uABI From: Nadav Amit In-Reply-To: <20230914152620.2743033-3-surenb@google.com> Date: Thu, 14 Sep 2023 14:57:04 -0700 Cc: Andrew Morton , viro@zeniv.linux.org.uk, brauner@kernel.org, shuah@kernel.org, Andrea Arcangeli , lokeshgidra@google.com, Peter Xu , David Hildenbrand , Hugh Dickins , mhocko@suse.com, Axel Rasmussen , Mike Rapoport , Matthew Wilcox , Liam.Howlett@oracle.com, Jann Horn , zhangpeng362@huawei.com, bgeffon@google.com, kaleshsingh@google.com, ngeoffray@google.com, jdduke@google.com, linux-mm , linux-fsdevel@vger.kernel.org, Linux Kernel Mailing List , linux-kselftest@vger.kernel.org, kernel-team@android.com Content-Transfer-Encoding: 7bit Message-Id: <4F9BBE45-22D0-4F8D-BA56-CA3459998DC4@gmail.com> References: <20230914152620.2743033-1-surenb@google.com> <20230914152620.2743033-3-surenb@google.com> To: Suren Baghdasaryan X-Mailer: Apple Mail (2.3731.700.6) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > On Sep 14, 2023, at 8:26 AM, Suren Baghdasaryan wrote: > > + if (!pte_same(ptep_clear_flush(src_vma, src_addr, src_pte), > + orig_src_pte)) > + BUG_ON(1); Just a minor detail regarding these few lines: Besides the less-than-ideal use of BUG_ON() here, I think that this code assumes that the PTE cannot change at this point. However, as the PTE was still mapped at this point, I think the access and dirty bits can be set. tl;dr: this appears to be triggerable by userspace. [ as for the performance of this code, the lack of batching would mean that for multithreaded applications where more than a single page is remapped, performance would suffer ]