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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id B88CAC7EE26 for ; Tue, 23 May 2023 17:27:13 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4F5B06B0074; Tue, 23 May 2023 13:27:13 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 4A6A2900003; Tue, 23 May 2023 13:27:13 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 34751900002; Tue, 23 May 2023 13:27:13 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 21BFE6B0074 for ; Tue, 23 May 2023 13:27:13 -0400 (EDT) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id ED3B08071D for ; Tue, 23 May 2023 17:27:12 +0000 (UTC) X-FDA: 80822200704.02.D447A0D Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf22.hostedemail.com (Postfix) with ESMTP id B1776C0009 for ; Tue, 23 May 2023 17:27:10 +0000 (UTC) Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=ALUHuU4t; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf22.hostedemail.com: domain of peterx@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=peterx@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1684862830; a=rsa-sha256; cv=none; b=ZkYjNkAJqXF0wzClYhAhr0nMGT+vvf3DFQdrH0Ar4CGcS5dVPUNl4ZfD/yCp8yAws1l2z3 PXSbGIi4xqIRv/0I+/ILv1tB/kijI8995QwCUQ7wofW300ploDpFDs7kVP+5wo9tGXYlzy fU1aRr819OEbX0mnpTdkhNePY6Gq6W0= ARC-Authentication-Results: i=1; imf22.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=ALUHuU4t; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf22.hostedemail.com: domain of peterx@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=peterx@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1684862830; h=from:from:sender: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:dkim-signature; bh=cImDjprrbyCagqgL7hx5cC+l1diu0Ysptat3mQQx7iI=; b=A8bCzMDPpMf0EhqFYURaB9cC7SyNU2ayhw6MQ5tpnGRKrjCHYNPOcLvE85HTieyKkBqZgA UBP14TEJNysMDSbqtzpgJqsHQmVuFCtsGkr74zDAyJjwHZkRPJGl3+EOnfqkBFJmTcFI6D p1SetIdJs9nOS9VjrnFTbEHUJyucLf8= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1684862829; 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=cImDjprrbyCagqgL7hx5cC+l1diu0Ysptat3mQQx7iI=; b=ALUHuU4tuOxCJfIJdheYXu73BxOkjGikFjHKh8HQYMwDCS9B0WiOLosdGPz8WwJQP+WqJO 6s/y1NCqZxO/9pXISsIXBGHp/EGiGP63Cdl72nqn1hCkBoFsaTPAU58tmEcOMMIPpPvibg MNVzc6MKbtFcX+KjIQaQIuvZi52lQhg= Received: from mail-qk1-f197.google.com (mail-qk1-f197.google.com [209.85.222.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-206-kyoFKuENM_OMHxL4eJt5dQ-1; Tue, 23 May 2023 13:27:07 -0400 X-MC-Unique: kyoFKuENM_OMHxL4eJt5dQ-1 Received: by mail-qk1-f197.google.com with SMTP id af79cd13be357-75b175cf0d1so2013185a.0 for ; Tue, 23 May 2023 10:27:07 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684862827; x=1687454827; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=cImDjprrbyCagqgL7hx5cC+l1diu0Ysptat3mQQx7iI=; b=L97eEAnwG9Frx8Qn4NWNLB3Wlo30WaSrgI92JzvGK4jElhHQCQ5sIY1N5FGBtT+kmh DO+yICh5GLke+nYLuLpe8EBGTQKXN07R24tslRGWr08KvAGbQRtghVF1i8no5UL72g6M SAuqqy8usd41CNVBfCbE3T5igPouEERRyKzyjKHYUVE2sSVMSxzGQ4K6WirQz/CkuWfK 5t8jq17VRC6dFYKqJEufqcqZQjXXj3DSsgjv7EZoC1Vo65fvcoSP+PUSXMcwdh/ihqVF cXyBL41Y3vitTqpmWnlCzBv7qxXjJ75+0XPapCCZ6nbdKtacLhwwtoeqW3UKfvcVvH07 5UqA== X-Gm-Message-State: AC+VfDzrEbkfIJmPSooorsYy6tcExSg+nnWarXSARpQmUs0SCPBmVJTG krPVfiFZV0es+nYYtYkvs/YiAKX3GqovbVxcOrD9jTf8oykA31fKmto3UotstUPe9VRWwsPQiYU OsGfN+tr1OnY= X-Received: by 2002:a05:620a:2b0a:b0:75b:23a1:69ec with SMTP id do10-20020a05620a2b0a00b0075b23a169ecmr5378377qkb.3.1684862826879; Tue, 23 May 2023 10:27:06 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4M4RNfGC67mMFT70JEPLNT3I+5EAh4zo0m/jamb1QJmcX791dEziFSsudincKhZfjyQdFDIg== X-Received: by 2002:a05:620a:2b0a:b0:75b:23a1:69ec with SMTP id do10-20020a05620a2b0a00b0075b23a169ecmr5378348qkb.3.1684862826591; Tue, 23 May 2023 10:27:06 -0700 (PDT) Received: from x1n (bras-base-aurron9127w-grc-62-70-24-86-62.dsl.bell.ca. [70.24.86.62]) by smtp.gmail.com with ESMTPSA id fc10-20020ad44f2a000000b0062439f05b87sm2869456qvb.45.2023.05.23.10.27.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 May 2023 10:27:05 -0700 (PDT) Date: Tue, 23 May 2023 13:27:04 -0400 From: Peter Xu To: Axel Rasmussen Cc: Jiaqi Yan , David Hildenbrand , James Houghton , Alexander Viro , Andrew Morton , Christian Brauner , Hongchen Zhang , Huang Ying , "Liam R. Howlett" , Miaohe Lin , "Mike Rapoport (IBM)" , Nadav Amit , Naoya Horiguchi , Shuah Khan , ZhangPeng , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-kselftest@vger.kernel.org, Anish Moorthy Subject: Re: [PATCH 1/3] mm: userfaultfd: add new UFFDIO_SIGBUS ioctl Message-ID: References: <32fdc2c8-b86b-92f3-1d5e-64db6be29126@redhat.com> MIME-Version: 1.0 In-Reply-To: X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit X-Rspam-User: X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: B1776C0009 X-Stat-Signature: ujo6c1jxry4ieauig4fq3mw1k6aiijc4 X-HE-Tag: 1684862830-107639 X-HE-Meta: U2FsdGVkX1+kA8mXz92nm1pgBg/E4n68OjLgOSENBJFN22Rq8k1CY0Hpz7JeIo4AmwOyfGaQuo9MBNP0uuW/zgx6AFekAwJ+Tq/COtvBe6KkwFh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sVrmETwXlWhdMZfPqluPg/wC8sEDEjKOkCMwFHEBYoILbEqgPHZ7Z0pNbASdn+HIQd1mTqaxw6BmbCYNoQyFr1wIvFmgQgZZcFKEZ5oVDWeRWjsej8aRCeS6IsSN6LfWcz2YYkRg2d5aQlq1aKlDLBm7DZLxf6wSzsHnE7yuOIhfugBIZ2m5M6nBifjSjV86SvlOGxuQFdYiwtmz9Fc4P1vvicTG9jekQJ7nzjwJ/VCyKI0AoPBqiZvCaDMhFT/m23x7SJ3gCTJVgk65M3tV9fpqewDai1u1E/3Ocf0VWd6ZrjDH7yOPa5oxlV8hAY49BUJcihm4esKrEj8= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000041, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Fri, May 19, 2023 at 10:32:13AM -0700, Axel Rasmussen wrote: > On Fri, May 19, 2023 at 9:20 AM Peter Xu wrote: > > > > Hi, Jiaqi, > > > > On Fri, May 19, 2023 at 08:04:09AM -0700, Jiaqi Yan wrote: > > > I don't think CAP_ADMIN is something we can work around: a VMM must be > > > a good citizen to avoid introducing any vulnerability to the host or > > > guest. > > > > > > On the other hand, "Userfaults allow the implementation of on-demand > > > paging from userland and more generally they allow userland to take > > > control of various memory page faults, something otherwise only the > > > kernel code could do." [3]. I am not familiar with the UFFD internals, > > > but our use case seems to match what UFFD wants to provide: without > > > affecting the whole world, give a specific userspace (without > > > CAP_ADMIN) the ability to handle page faults (indirectly emulate a > > > HWPOISON page (in my mind I treat it as SetHWPOISON(page) + > > > TestHWPOISON(page) operation in kernel's PF code)). So is it fair to > > > say what Axel provided here is "provide !ADMIN somehow"? > > > > > > [3]https://docs.kernel.org/admin-guide/mm/userfaultfd.html > > > > Userfault keywords on "user", IMHO. We don't strictly need userfault to > > resolve anything regarding CAP_ADMIN problems. MADV_DONTNEED also dosn't > > need CAP_ADMIN, same to any new madvise() if we want to make it useful for > > injecting poisoned ptes with !ADMIN and limit it within current->mm. > > > > But I think you're right that userfaultfd always tried to avoid having > > ADMIN and keep everything within its own scope of permissions. > > > > So again, totally no objection on make it uffd specific for now if you guys > > are all happy with it, but just to be clear that it's (to me) mostly for > > avoiding another WAKE, and afaics that's not really for solving the ADMIN > > issue here. > > How about this plan: > > Since the concrete use case we have (postcopy live migration) is > UFFD-specific, let's leave it as a UFFDIO_* operation for now. > > If in the future we come up with a non-UFFD use case, we can add a new > MADV_* which does this operation at that point. From my perspective > they could even share most of the same implementation code. > > I don't think it's a big problem keeping the UFFDIO_* version too at > that point, because it still provides some (perhaps small) value: > > - Combines the operation + waking into one syscall > - It allows us to support additional UFFD flags which modify / extend > the operation in UFFD-specific ways, if we want to add those in the > future > > Seem reasonable? Ok here. > > If so, I'll send a v2 with documentation updates. I've reviewed v1 in this case, please have a look, thanks. -- Peter Xu