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 3B12BC43217 for ; Wed, 2 Mar 2022 15:20:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243438AbiCBPVS (ORCPT ); Wed, 2 Mar 2022 10:21:18 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48906 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243429AbiCBPVR (ORCPT ); Wed, 2 Mar 2022 10:21:17 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id F3069C6263 for ; Wed, 2 Mar 2022 07:20:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1646234433; 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=o+/uKNtMSqxxtp2IKJVl4PtqKh8tUPajkwApvE96v0s=; b=iZvlekyAFl5nhUjkv+onEJRQIPyP7cB+kIaFJrHbDQ7pATZiAYE/Tq0qBzlMzuHFHLOmpt zdYbNAkNwWffzIUXc6FizFwUuQ3JkC2BEfyNqKWaIKMbuIQkucj75fyBYJ3SbWkm/kJU2a 6FDxgfebhtt2Dd8xIt8C7EZO8WD/ewA= Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-164-R30_fwuQPHK9XdoXimFZJw-1; Wed, 02 Mar 2022 10:20:32 -0500 X-MC-Unique: R30_fwuQPHK9XdoXimFZJw-1 Received: by mail-wr1-f72.google.com with SMTP id ba15-20020a0560001c0f00b001f01822f821so756485wrb.7 for ; Wed, 02 Mar 2022 07:20:31 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=o+/uKNtMSqxxtp2IKJVl4PtqKh8tUPajkwApvE96v0s=; b=KMpoVYLUd6G3F96b0rrqF5JyXhtocxx1Fc8OYmcim/ebiwdMneS9abW1iffpbLSCNz KixQ6VKUcVn7rRnhzxYAu0boASn6lDMkG8EnfZhXKIzTGcTxct53ZvC5t8oTOOORKjJR P9y6VIrG1hQoP07pGbxKFUUNb9mEYs/a/hqA4lgrPNT/qdroW2x/vBhri5wjv9ercpUT 62nXp8EvyGOAeQUQvDA24rKRrf/RDbA3seIxS9EELwelRX8REBwI1UlSL+eeA3fO8eVC nAHdcXSip3zG5ADKOvnu6TMxsWSBsBZNo1Y6dlTXLO86f5G+fTEq93p1x0Zyb1gNjNmF oeAA== X-Gm-Message-State: AOAM531zFcgtEWn4oVBIQGM+LTRbqhjl6gfeFVC3xma6TVweps53pILF ihqpz9KPOk5ICf6XIYg80AZVehJ6eWmnGW4lKPpe/kDHkYUPeZksjUZ6eY+xIJhoqj2pQ9q4WTU 0np8bbsG4rDU4KRkwjxs= X-Received: by 2002:a05:6000:114d:b0:1ee:f251:52c6 with SMTP id d13-20020a056000114d00b001eef25152c6mr22351321wrx.618.1646234430701; Wed, 02 Mar 2022 07:20:30 -0800 (PST) X-Google-Smtp-Source: ABdhPJxaRd2QDCauXRg0Cy1iugecAP23hz+39Lwf58iM9a92otz79fxfMO534ZE5Hi2k0kqltL5FeA== X-Received: by 2002:a05:6000:114d:b0:1ee:f251:52c6 with SMTP id d13-20020a056000114d00b001eef25152c6mr22351286wrx.618.1646234430410; Wed, 02 Mar 2022 07:20:30 -0800 (PST) Received: from redhat.com ([2a10:8006:355c:0:48d6:b937:2fb9:b7de]) by smtp.gmail.com with ESMTPSA id m18-20020a5d56d2000000b001edc00dbeeasm16452690wrw.69.2022.03.02.07.20.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Mar 2022 07:20:29 -0800 (PST) Date: Wed, 2 Mar 2022 10:20:25 -0500 From: "Michael S. Tsirkin" To: "Jason A. Donenfeld" Cc: Laszlo Ersek , LKML , KVM list , QEMU Developers , linux-hyperv@vger.kernel.org, Linux Crypto Mailing List , Alexander Graf , "Michael Kelley (LINUX)" , Greg Kroah-Hartman , adrian@parity.io, Daniel =?iso-8859-1?Q?P=2E_Berrang=E9?= , Dominik Brodowski , Jann Horn , "Rafael J. Wysocki" , "Brown, Len" , Pavel Machek , Linux PM , Colm MacCarthaigh , Theodore Ts'o , Arnd Bergmann Subject: Re: propagating vmgenid outward and upward Message-ID: <20220302101602-mutt-send-email-mst@kernel.org> References: <223f858c-34c5-3ccd-b9e8-7585a976364d@redhat.com> <20220301121419-mutt-send-email-mst@kernel.org> <20220302031738-mutt-send-email-mst@kernel.org> <20220302074503-mutt-send-email-mst@kernel.org> <20220302092149-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-pm@vger.kernel.org On Wed, Mar 02, 2022 at 04:14:56PM +0100, Jason A. Donenfeld wrote: > Hi Michael, > > On Wed, Mar 2, 2022 at 3:46 PM Michael S. Tsirkin wrote: > > I just don't see how "value changed while it was read" is so different > > from "value changed one clock after it was read". Since we don't detect > > the latter I don't see why we should worry about the former. > > The "barrier" is at the point where the plaintext has been chosen AND > the nonce for a given keypair has been selected. So, if you have > plaintext in a buffer, and a key in a buffer, and the nonce for that > encryption in a buffer, and then after those are all selected, you > check to see if the vmgenid has changed since the birth of that key, > then you're all set. If it changes _after_ that point of check (your > "one clock after"), it doesn't matter: you'll just be > double-transmitting the same ciphertext, which is something that flaky > wifi sometimes does _anyway_ (and attackers can do intentionally), so > network protocols already are resilient to replay. This is the same > case you asked about earlier, and then answered yourself, when you > were wondering about reaching down into qdiscs. > > Jason So writing some code: 1: put plaintext in a buffer put a key in a buffer put the nonce for that encryption in a buffer if vm gen id != stored vm gen id stored vm gen id = vm gen id goto 1 I think this is race free, but I don't see why does it matter whether we read gen id atomically or not. -- MST