Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp3659516pxu; Mon, 19 Oct 2020 18:49:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx//R0AIb69yOouv0ZiW8GBu8S3FacgHDAG9/rtzHUp9fqYGqhc1UJpshKBx/mnABYJkECq X-Received: by 2002:a50:8b62:: with SMTP id l89mr415553edl.132.1603158579011; Mon, 19 Oct 2020 18:49:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603158579; cv=none; d=google.com; s=arc-20160816; b=qv/s8q95Upu/gA7VSWprxBL/tuya3nAjGSwH6ZXtttUyrCqERn8VQ1cAMIVZggKTXR K3RQzwlHGN2Ckhd+HIXTLy20hOjDrfFw+iDSV5J/YsRybuVV/BJisDFiLfjgtzsB/mn1 bYm/0BQmHvxrKiLrSekAoWeBwXvSzeNS1XZ+dVLddRFtKkQKIA7paXwqYcsGjYR+6v/i u4F/g/bh6IW+W/CcJmaXdQX/DrbVOg7tyLmQkAPuyURLe6LwyC5hzG5SqCB2Ync5XKpp YVr0F3t2319TljuajZRz/pzrFx1Q7jd4fF4VjW54yhvOeno/81n81SyZyuOY/fNQzfbh poTQ== 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-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=eeEwkWd2inwelOxnZFWrV6qJ4loEm7oC47tsgU5zrNE=; b=SasP0lTJ7qa4ZT5GGmLtKp8wD8glNeEkzoX1LIXzxH12maLZWeF3/DrA0Rk22zI2Uc jCdhKQJja/chhDdJDnjCbLZFHOAeI6Y8gdk/yaZYa4ztGRzOT17e+wGISTUm2fwDSA8Z 3g2W4rBtCs0VVeSCWTnJweo6n0c3oDsSWRFVVyP9SnEFLX4hU9d0OS9TjfFNkhG7Nsho AZ+/dGBLloM/JTvJ9CvJJxo/19d2iVR6vTj4q26wZLs7UYZuPwtlAWAO3DMdD8OFgtjM d2FT4dq5i1ekpxw8ZOhs38i7GynnN48V/B43UuRZSk3pOzvHQdWODn2QzGhoYrHl9W0x VWVg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=KzK3Y4Pr; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id da5si183172edb.595.2020.10.19.18.49.16; Mon, 19 Oct 2020 18:49:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=KzK3Y4Pr; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S1729795AbgJSPA5 (ORCPT + 99 others); Mon, 19 Oct 2020 11:00:57 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:21330 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729715AbgJSPA4 (ORCPT ); Mon, 19 Oct 2020 11:00:56 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1603119654; 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: in-reply-to:in-reply-to:references:references; bh=eeEwkWd2inwelOxnZFWrV6qJ4loEm7oC47tsgU5zrNE=; b=KzK3Y4PrPBqzVLK5EXFDXijQAaMHftHhFoZ7WePp24M9Rxe1w4kRDnyEKxNUegT0Lp7rcq Jp56FcRiRyeTkmLW6zqdLlpwNm0BOi8aG2bPjPHI+87rKedwHw5KgHPjUfiywbG6vAz0v3 wajCgFHxNV774WTwCJdJd3FvAfDX/io= Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-343-MPWqHqjbOOW5I_js7_UaFA-1; Mon, 19 Oct 2020 11:00:53 -0400 X-MC-Unique: MPWqHqjbOOW5I_js7_UaFA-1 Received: by mail-wm1-f70.google.com with SMTP id z7so37442wme.8 for ; Mon, 19 Oct 2020 08:00:51 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=eeEwkWd2inwelOxnZFWrV6qJ4loEm7oC47tsgU5zrNE=; b=uJM07U02OtpBoWYaghPC951G7LQZMsdPi8O7pnjMYJ49PJN8X18LZmZVzv4XrFHZ5j z4GphffadU8zq304SYQUOaMt0BfXkr/FbD3ca85ZTBR8fuqmhU6LWsCtLeTuJxKY/vLY bhuOfF8RUHDWIgFwD6eUOjKKU06lyusPq9MtqSkAb2zTM+qlycBOjpmI6JSag0Ho6Hgl GtHso/fY0xNiI/YylzozLNhjDTirWloXQy1YtjZGQ69sU8+3U29w8DnT9DYNXyxe6nlv qccJt0GikKmR01bjGwxTQ/rdbFW5CfDIGrUB2RnzKoA+o45DSIrM+wH32Yz/PTaaN9Os HQDQ== X-Gm-Message-State: AOAM531rAk2rL9rKm1BriA8C8e1MYykDK8uMq9asbVvHmS+R6zsBie6u oe5jRVEHR05Ggl5/O0p3+fYLFjsJB/Rwt8rBM8EDVWNyHqhbZ1wqzfIqIqW4gpQxpGiIiJgiXyy t48ZCGAOlQJWN9c3TGb7LbMoQ X-Received: by 2002:a7b:c081:: with SMTP id r1mr17940597wmh.158.1603119650819; Mon, 19 Oct 2020 08:00:50 -0700 (PDT) X-Received: by 2002:a7b:c081:: with SMTP id r1mr17940572wmh.158.1603119650551; Mon, 19 Oct 2020 08:00:50 -0700 (PDT) Received: from redhat.com (bzq-79-176-118-93.red.bezeqint.net. [79.176.118.93]) by smtp.gmail.com with ESMTPSA id e15sm8898wro.13.2020.10.19.08.00.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Oct 2020 08:00:49 -0700 (PDT) Date: Mon, 19 Oct 2020 11:00:45 -0400 From: "Michael S. Tsirkin" To: Andy Lutomirski Cc: "Jason A. Donenfeld" , Jann Horn , Willy Tarreau , Colm MacCarthaigh , "Catangiu, Adrian Costin" , "Theodore Y. Ts'o" , Eric Biggers , "open list:DOCUMENTATION" , kernel list , "open list:VIRTIO GPU DRIVER" , "Graf (AWS), Alexander" , "Woodhouse, David" , bonzini@gnu.org, "Singh, Balbir" , "Weiss, Radu" , oridgar@gmail.com, ghammer@redhat.com, Jonathan Corbet , Greg Kroah-Hartman , Qemu Developers , KVM list , Michal Hocko , "Rafael J. Wysocki" , Pavel Machek , Linux API Subject: Re: [PATCH] drivers/virt: vmgenid: add vm generation id driver Message-ID: <20201019105118-mutt-send-email-mst@kernel.org> References: <20201017053712.GA14105@1wt.eu> <20201017064442.GA14117@1wt.eu> <20201018114625-mutt-send-email-mst@kernel.org> <20201018115524-mutt-send-email-mst@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, Oct 18, 2020 at 09:14:00AM -0700, Andy Lutomirski wrote: > On Sun, Oct 18, 2020 at 8:59 AM Michael S. Tsirkin wrote: > > > > On Sun, Oct 18, 2020 at 08:54:36AM -0700, Andy Lutomirski wrote: > > > On Sun, Oct 18, 2020 at 8:52 AM Michael S. Tsirkin wrote: > > > > > > > > On Sat, Oct 17, 2020 at 03:24:08PM +0200, Jason A. Donenfeld wrote: > > > > > 4c. The guest kernel maintains an array of physical addresses that are > > > > > MADV_WIPEONFORK. The hypervisor knows about this array and its > > > > > location through whatever protocol, and before resuming a > > > > > moved/snapshotted/duplicated VM, it takes the responsibility for > > > > > memzeroing this memory. The huge pro here would be that this > > > > > eliminates all races, and reduces complexity quite a bit, because the > > > > > hypervisor can perfectly synchronize its bringup (and SMP bringup) > > > > > with this, and it can even optimize things like on-disk memory > > > > > snapshots to simply not write out those pages to disk. > > > > > > > > > > A 4c-like approach seems like it'd be a lot of bang for the buck -- we > > > > > reuse the existing mechanism (MADV_WIPEONFORK), so there's no new > > > > > userspace API to deal with, and it'd be race free, and eliminate a lot > > > > > of kernel complexity. > > > > > > > > Clearly this has a chance to break applications, right? > > > > If there's an app that uses this as a non-system-calls way > > > > to find out whether there was a fork, it will break > > > > when wipe triggers without a fork ... > > > > For example, imagine: > > > > > > > > MADV_WIPEONFORK > > > > copy secret data to MADV_DONTFORK > > > > fork > > > > > > > > > > > > used to work, with this change it gets 0s instead of the secret data. > > > > > > > > > > > > I am also not sure it's wise to expose each guest process > > > > to the hypervisor like this. E.g. each process needs a > > > > guest physical address of its own then. This is a finite resource. > > > > > > > > > > > > The mmap interface proposed here is somewhat baroque, but it is > > > > certainly simple to implement ... > > > > > > Wipe of fork/vmgenid/whatever could end up being much more problematic > > > than it naively appears -- it could be wiped in the middle of a read. > > > Either the API needs to handle this cleanly, or we need something more > > > aggressive like signal-on-fork. > > > > > > --Andy > > > > > > Right, it's not on fork, it's actually when process is snapshotted. > > > > If we assume it's CRIU we care about, then I > > wonder what's wrong with something like > > MADV_CHANGEONPTRACE_SEIZE > > and basically say it's X bytes which change the value... > > I feel like we may be approaching this from the wrong end. Rather > than saying "what data structure can the kernel expose that might > plausibly be useful", how about we try identifying some specific > userspace needs and see what a good solution could look like. I can > identify two major cryptographic use cases: Well, I'm aware of a non-cryptographic use-case: https://bugzilla.redhat.com/show_bug.cgi?id=1118834 this seems to just ask for the guest to have a way to detect that a VM cloning triggered. -- MST