Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp1704764pxu; Fri, 27 Nov 2020 13:14:19 -0800 (PST) X-Google-Smtp-Source: ABdhPJzzBlg7sv1gE/5OGxqjYqnffCkN6UaDC/bbKw0yi+vODinEFnDQZiTZ7iF2AmUryRgoQh4u X-Received: by 2002:a05:6402:c95:: with SMTP id cm21mr9903383edb.372.1606511658974; Fri, 27 Nov 2020 13:14:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606511658; cv=none; d=google.com; s=arc-20160816; b=xRktgNyjzmRsrNQ9VRo525WFCnawVbcmJVJz535yMYnpvWfFEF29KNgt08mcmebHrb y/5MKQZ6nGkHK7oQ2NAlv2CiSY12YWjteYOJmg4nBrGl5LPOBBeDJSVc4isBAlzsQ6iO NwblEwEVeVhlkpCZllmfOWgLWTR8fFpWIQqGwKUwg4qeBS1tyiBSrQQFs5VCVoOfXDD5 ejnORolHp2VedB/bl99q1zoqxfZH33w4yvqrLsVP0FiJpN0n9f5xyCxkZe7LSRV8rfVY uWvy76pmFEW5ep+8FyCDzM4Rq2bw+ZkWRgoCRCM5TBN+2NW7W96qB03TbgUQSljA2iqE kuDQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=wq5aPWBOYfgE0ikLgKOb/75PgZgI1EkZa0hkLcr2E6E=; b=BNAQg+53O7vTJ9d0ug+Y65fJcyjbnb08a9HABo83nsUUe2VmjmlvRYruRvn0JZxkBO 9st8rCdzVwl74tWMX7syaB/oJ5QhaYqZ8vjIwm40zxaBHklw5bQVulYuksCT8Yz3w9FA 7iqeNXHYBUgvzi2JN6Xe3jYJEwQ/+VsNTS/5ZGLQLOs4uGV29t8z+3q3S4oePOzCQcHB RE5pT/jxMZWgjRbdAHsQlJBE7X407GrOoi3DR2FIqjPjUT0S3CM9HHqkeJiwfn/yK1rd B540MSVeTqsAVTyqDceJlmuHt54YiNKJiSDQ1Efyaj0/+4LB85LjcuKWLSt8vg3xWtfk J6Fg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=LIRHhHFI; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i8si3605806ejj.424.2020.11.27.13.13.39; Fri, 27 Nov 2020 13:14:18 -0800 (PST) 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=@google.com header.s=20161025 header.b=LIRHhHFI; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731252AbgK0U3i (ORCPT + 99 others); Fri, 27 Nov 2020 15:29:38 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32768 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731500AbgK0U2m (ORCPT ); Fri, 27 Nov 2020 15:28:42 -0500 Received: from mail-lf1-x144.google.com (mail-lf1-x144.google.com [IPv6:2a00:1450:4864:20::144]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 59EB5C0613D2 for ; Fri, 27 Nov 2020 12:20:48 -0800 (PST) Received: by mail-lf1-x144.google.com with SMTP id z21so8601869lfe.12 for ; Fri, 27 Nov 2020 12:20:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=wq5aPWBOYfgE0ikLgKOb/75PgZgI1EkZa0hkLcr2E6E=; b=LIRHhHFIkM/Wpdo44zJO/nUYNrS+gJ0aecPyjsSYd8yPt5l7XJsEgxH6VluvZ0l2c8 SxkO84qW52Zqb3ZiSgF1lDgqzBV+MlcdgFO3ZowglCYgd+BRmFg17FEnlLafGdblK5s/ B3QPELYXQKnl2eFyB+OjIbaxgEFtKKGHdr8XwYWm3WPMSSRAPPhdzcrwFHF+Z9+4GLDh qeBz/MGtUfU/PYmoBosJRa8XkQ4ACohZRg7L17a0lN10TaXaWR+qqvoYi1QWNBpX7P4C L+CeuduU0Y40aOHEfYkSzUJUpJHJtMDynlFnqLlaOH1tlUe6LxUwKpbUA3YkNI+Mk5wH CfbQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=wq5aPWBOYfgE0ikLgKOb/75PgZgI1EkZa0hkLcr2E6E=; b=FPL4WD2tv5LWltzEHnYYrC1JrrkYnhg+h9n4A7KmXNpy55UxGeACHQBalyWjlxfUAP m0eH34iB4Q8i/HmxcmW2fNsXxwtj6lN7PBEc0aCa8t0cn7phKL701uMF0hVW6HRjhdLA u27JxM2CocGODCuPwKm2Q1gC39SM7IZlOfE+Gf3aDxuGcHzuCMrgLwa8EuCfbGPjZRFt vfCm6/m42nhs06Nsy5Gw1umRiulNnCf0hB1j6AMJ9FqLC+/VKb9fNbZJusLiRLLowglk CFZalsQZQYkTGDiJADQ9VEz2uvYRyV8sM53DRHQi2nT/d4b7oVo+KWRBklu37aCgIjHu E2RQ== X-Gm-Message-State: AOAM5308AB0npgNHVLGttAlUbxELhUGCPnnPeeLRuLabne165qUitutl xNcO3WDS1j0AnT3WFsvxBLoY2Uie9oaFX3l1p5USkg== X-Received: by 2002:a19:8c13:: with SMTP id o19mr4194624lfd.573.1606508446532; Fri, 27 Nov 2020 12:20:46 -0800 (PST) MIME-Version: 1.0 References: <3E05451B-A9CD-4719-99D0-72750A304044@amazon.com> In-Reply-To: From: Jann Horn Date: Fri, 27 Nov 2020 21:20:19 +0100 Message-ID: Subject: Re: [PATCH v2] drivers/virt: vmgenid: add vm generation id driver To: "Catangiu, Adrian Costin" Cc: "Graf (AWS), Alexander" , Christian Borntraeger , "Jason A. Donenfeld" , Willy Tarreau , "MacCarthaigh, Colm" , Andy Lutomirski , "Theodore Y. Ts'o" , Eric Biggers , "open list:DOCUMENTATION" , kernel list , "Woodhouse, David" , "bonzini@gnu.org" , "Singh, Balbir" , "Weiss, Radu" , "oridgar@gmail.com" , "ghammer@redhat.com" , Jonathan Corbet , Greg Kroah-Hartman , "Michael S. Tsirkin" , Qemu Developers , KVM list , Michal Hocko , "Rafael J. Wysocki" , Pavel Machek , Linux API , "mpe@ellerman.id.au" , linux-s390 , "areber@redhat.com" , Pavel Emelyanov , Andrey Vagin , Mike Rapoport , Dmitry Safonov <0x7f454c46@gmail.com>, Pavel Tikhomirov , "gil@azul.com" , "asmehra@redhat.com" , "dgunigun@redhat.com" , "vijaysun@ca.ibm.com" Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Nov 27, 2020 at 8:04 PM Catangiu, Adrian Costin wrote: > On 27/11/2020 20:22, Jann Horn wrote: > > On Fri, Nov 20, 2020 at 11:29 PM Jann Horn wrote: > >> On Mon, Nov 16, 2020 at 4:35 PM Catangiu, Adrian Costin > >> wrote: > >>> This patch is a driver that exposes a monotonic incremental Virtual > >>> Machine Generation u32 counter via a char-dev FS interface that > >>> provides sync and async VmGen counter updates notifications. It also > >>> provides VmGen counter retrieval and confirmation mechanisms. > >>> > >>> The hw provided UUID is not exposed to userspace, it is internally > >>> used by the driver to keep accounting for the exposed VmGen counter. > >>> The counter starts from zero when the driver is initialized and > >>> monotonically increments every time the hw UUID changes (the VM > >>> generation changes). > >>> > >>> On each hw UUID change, the new hypervisor-provided UUID is also fed > >>> to the kernel RNG. > >> As for v1: > >> > >> Is there a reasonable usecase for the "confirmation" mechanism? It > >> doesn't seem very useful to me. > > I think it adds value in complex scenarios with multiple users of the > mechanism, potentially at varying layers of the stack, different > processes and/or runtime libraries. > > The driver offers a natural place to handle minimal orchestration > support and offer visibility in system-wide status. > > A high-level service that trusts all system components to properly use > the confirmation mechanism can actually block and wait patiently for the > system to adjust to the new world. Even if it doesn't trust all > components it can still do a best-effort, timeout block. What concrete action would that high-level service be able to take after waiting for such an event? My model of the vmgenid mechanism is that RNGs and cryptographic libraries that use it need to be fundamentally written such that it is guaranteed that a VM fork can not cause the same random number / counter / ... to be reused for two different cryptographic operations in a way visible to an attacker. This means that e.g. TLS libraries need to, between accepting unencrypted input and sending out encrypted data, check whether the vmgenid changed since the connection was set up, and if a vmgenid change occurred, kill the connection. Can you give a concrete example of a usecase where the vmgenid mechanism is used securely and the confirmation mechanism is necessary as part of that? > >> How do you envision integrating this with libraries that have to work > >> in restrictive seccomp sandboxes? If this was in the vDSO, that would > >> be much easier. > > Since this mechanism targets all of userspace stack, the usecase greatly > vary. I doubt we can have a single silver bullet interface. > > For example, the mmap interface targets user space RNGs, where as fast > and as race free as possible is key. But there also higher level > applications that don't manage their own memory or don't have access to > low-level primitives so they can't use the mmap or even vDSO interfaces. > That's what the rest of the logic is there for, the read+poll interface > and all of the orchestration logic. Are you saying that, because people might not want to write proper bindings for this interface while also being unwilling to take the performance hit of calling read() in every place where they would have to do so to be fully correct, you want to build a "best-effort" mechanism that is deliberately designed to allow some cryptographic state reuse in a limited time window? > Like you correctly point out, there are also scenarios like tight > seccomp jails where even the FS interfaces is inaccessible. For cases > like this and others, I believe we will have to work incrementally to > build up the interface diversity to cater to all the user scenarios > diversity. It would be much nicer if we could have one simple interface that lets everyone correctly do what they need to, though...