Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp4660644rwd; Tue, 23 May 2023 10:32:37 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7I56McQEtMJn2szQAMSqvcvZM1QphMTfw/SH5AVoqZgfTLzOLwLulGL0/0skL2PIKaDTWB X-Received: by 2002:a05:6a21:78a7:b0:10a:dafc:aef5 with SMTP id bf39-20020a056a2178a700b0010adafcaef5mr14088454pzc.34.1684863156815; Tue, 23 May 2023 10:32:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684863156; cv=none; d=google.com; s=arc-20160816; b=ZrVSgsOtMpS2Peh3C+XvyAJ2CoDi2CvE0Tpw8SnNqZ8wnbcwPoArdGg/dz2MlnTkfV UxVLigOVA/ESHbItzp9xFJ4TS6pTQ+Eis3908zUbDfoaVuR3HwvNd/+mXBksbyI2Vh4c wZ7BUXia8hD8ArWTAY1RFaCSDE+fo0tFspBLYOdWc4KeObOZuhlqG+whZVrSKjkzI7Ak XEEcUpNJX/yVjEr1hAcXjfwVUCzibhj5D1ApbIAizbtLi5169FauTxqbcMW2m3MpIdY+ 8WGLwoiIA9DLk5LSKVMl22/E3A9D5FMD/NIcXx0Jig88CclMj8WsmZSjpVHQAzgLm7FL ibfA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=cImDjprrbyCagqgL7hx5cC+l1diu0Ysptat3mQQx7iI=; b=V7KlioGEn245z5aIf+5U3JVJNVzHy0lDb07uYNKrkJHUyUK/NkNTTb75HZFvc3JwAT tY0E0hZX2hiOXrjnTXmSs3lVBnXIfsd4U47m5a2yHMlE3zrGwC/2WPpM71UpXrnWFpYc nUfj3X7EI5B7MnP49xiKwM3hHUazDXX+pFp4YxJKWA82d37Sg9IckrEEdxjh0t1rxQuJ 5iKB8f9SpKGXRVfTheHmlGyfc28pVPN2iCtXda2beCcgdEqhwCfhH+EmtpgGxV18/fjP zOCF5lsbJHpcpAvoH3A4GR9WexV5mE6gCInv47CgihBqUPiP+yuh9izd0YtiUh0AmFbw Gklg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=ALUHuU4t; 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 z21-20020a63ac55000000b0051b578dfc51si6592678pgn.744.2023.05.23.10.32.21; Tue, 23 May 2023 10:32:36 -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=ALUHuU4t; 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 S237826AbjEWR2R (ORCPT + 99 others); Tue, 23 May 2023 13:28:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58044 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237722AbjEWR2M (ORCPT ); Tue, 23 May 2023 13:28:12 -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 4CE9D1BC for ; Tue, 23 May 2023 10:27:10 -0700 (PDT) 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-f198.google.com (mail-qk1-f198.google.com [209.85.222.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-587-v4yX7AzqPh2JidcisWhTvQ-1; Tue, 23 May 2023 13:27:07 -0400 X-MC-Unique: v4yX7AzqPh2JidcisWhTvQ-1 Received: by mail-qk1-f198.google.com with SMTP id af79cd13be357-75b147a2548so1631985a.1 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=ZK/je9BRrIV++n7NpzIsa1x066335bZzE+C2Y7tz5b4KSElHrO6yuYYOll8E1DtddW namnyVS8sa9DbzsU3GQPaUBpHxXszDQhErMNN0MJRQAJamA28dKrgVhb15l+1jUIUI/Y XkGvunWZeikNBsNG+hwDcQJafErDLFaqK/UJ+oIGsVXAT6CVrwF121V/o/IdDP3p3/3B PV5tYNdrd0UXGSnUDyyld3Wgz/BwFE2E4kd14zAlJgSl+YqhKcVe8fbJfYyA+EJqI+xm uSh9o5LUWqkAaufaMkUNnh6ugbUIsREs4/TzB/VJQyAEGaIeEdbh3aN7ULhBuK5dsEWF TQiA== X-Gm-Message-State: AC+VfDxTbe1z1cNSbh3hOXq7b8xw0IryJkMqFSTWLVdoFXX2uhqu2FVs byZMiGiP0uC50KpaIWqoRWIBa+w8D0LCzrb1UnFvWjx1WilNtmkB63LN/MHCLeICmvD4+54+VAC xspGZ2eSKydceB6tp/aZxp2El X-Received: by 2002:a05:620a:2b0a:b0:75b:23a1:69ec with SMTP id do10-20020a05620a2b0a00b0075b23a169ecmr5378378qkb.3.1684862826879; Tue, 23 May 2023 10:27:06 -0700 (PDT) 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 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE 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 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