Received: by 2002:a05:7412:da14:b0:e2:908c:2ebd with SMTP id fe20csp2147285rdb; Mon, 9 Oct 2023 14:27:03 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFZxgmClSlbDqBJgfJGeAWfFgUt7Ixb8qSTDrwIcSfg4xIj6VvqIJ0WUfomUxxkGsiJW/sZ X-Received: by 2002:a05:6e02:12ac:b0:34f:b85b:37d8 with SMTP id f12-20020a056e0212ac00b0034fb85b37d8mr16180778ilr.26.1696886822696; Mon, 09 Oct 2023 14:27:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696886822; cv=none; d=google.com; s=arc-20160816; b=HQ7neFdqz4aBQWXIHAACCj3dBisdf599xsYDtmeHnnciucZLaeOnlTBY5/ym7DCnfg uFxPPuoeSsHF0b6kYGzoUJQW4cAj4k3JjTLBweJheAMHvbqbfMg07zo0v1Oqzy7VaWr2 gvtdJ0HT0+rDSUCjKFwv1PZRNJma4YXET/ofPAJkWxLVFs9t7aUEWozbcT3QCEhu/vqP sp/FUfs572GmV77ncXXzZiej0ONav7kXJQQy4c3LXoM3Zalj5EJgVucjnAwDhX7W2hC/ gzTbdN767PNPVMuk0pOV3gR3oS3/O9F+qUuIAcmGiSE+cA0dCgo4YmIIC4nDKTWUCx+E 1TJg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:dkim-signature; bh=HGGD5jvAnQPh9X54uhY2HVxAcITGPm3/bi/jB8262X0=; fh=6r7tsuSNtEA1kc6u9rolnGSwa9O/8zGR77V4wjPW5XA=; b=bOCQEshEfMwq60De2TOFpAeHNTnU6rpGngspLeMm4Wo4uEM019jusEd0Ns5ZM2K1OR L3EpL0Dd1QusHQhJfLo8VABEWAFwX+T/GPjQ05ISs61OCS3C6cY7kTSdzrmeiQnOhbZz 7/7/3+OouumtqvP3zKha6xLZsdms6oOgB/pPh9TjSKfyc+ytqgGlhtSXtZGH4vfkJEnc 810tJZcVtv7z27m9ReUiuZIK+PWI4CsBXeQ2vgQZ5YywU9HUnr2V1Kf95R7JHBllQ9GC us8cCNHqnxyA07RkaTTny09+53gselfH9Orn7UU63NRQp3HOJ7gkn20EPBGxNokyxpNF 7GcA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b="Xdscn/4x"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 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 morse.vger.email (morse.vger.email. [23.128.96.31]) by mx.google.com with ESMTPS id z66-20020a633345000000b00569cd6ead3asi90402pgz.643.2023.10.09.14.27.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Oct 2023 14:27:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) client-ip=23.128.96.31; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b="Xdscn/4x"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id 96F798119D02; Mon, 9 Oct 2023 14:27:00 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1378236AbjJIV0m (ORCPT + 99 others); Mon, 9 Oct 2023 17:26:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35136 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1378269AbjJIV0l (ORCPT ); Mon, 9 Oct 2023 17:26:41 -0400 Received: from mail-yb1-xb4a.google.com (mail-yb1-xb4a.google.com [IPv6:2607:f8b0:4864:20::b4a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 29E6D9E for ; Mon, 9 Oct 2023 14:26:39 -0700 (PDT) Received: by mail-yb1-xb4a.google.com with SMTP id 3f1490d57ef6-d9a3a98b34dso884570276.3 for ; Mon, 09 Oct 2023 14:26:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1696886798; x=1697491598; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=HGGD5jvAnQPh9X54uhY2HVxAcITGPm3/bi/jB8262X0=; b=Xdscn/4xHytY63mUdNFzyvBkwTqnx52EVI9XpQS1F26gO2DyP9VC/PXrFujcWxof52 RhBDeIEzmSaQiSPasdBwcoehVeqBnrHpp4mamHjmBRg2mbE4uUyodv+b6Gmp8xxKaABw 1V4ankST6ljZ+tQi0Y1CIStc7fbozJIl3AdVi1QoutyGWC7Iq4xu24r3bm8425t7Ma6S S7eapAmkRxYQHgW62/4BGag30cjGRPgFFgzXoC8ibW1H73ViU5iH8RhXeOolmZWmet4G GhX1R0CX/FphPDV4bXr9GuAr7K9duv/T8k2IB7cLN9ZZ8R1tcRD6NibKLJiJwgZiFftS FAkw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696886798; x=1697491598; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=HGGD5jvAnQPh9X54uhY2HVxAcITGPm3/bi/jB8262X0=; b=gjgJXQwapTVN+X4DKUrpB6yeuG0prBu0T8FcSTne1s3YgRnudXWIFzojnTcy2LeSjt jHw2o9CsMm51h4yqP2fLeMAqfkIm/s17gUoP6Q+H15ujNtT9CgzXEiqWIDC8f0HLpj8A QadXuhE4uASKUACS9JpKhKFKGIQQlXHCfmHNxJk119CNVFcuMlLShy1rAGcg47OQvfhp BjPohStypZu5Hi88VSOH5sWBs7qwFvGJfpItR5C36kq0rj58Eg3VWnT0RKv2/GDqX4LM wv0K9FmukwRU6yHqgVqYQ/7YG+TJ3d4iBG3++zuodEt+K9QT99Gl693K8cUFodkEhbnD WDYw== X-Gm-Message-State: AOJu0YyGCidxxAfGq2RSCJWFVSS4CYo5a/3iJ0bXb7I1zUJWcHvh9k9n 6+C5BoTwGftL4q/sXsk9VQgXFbsxvsU= X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a05:6902:138d:b0:d9a:4e29:6353 with SMTP id x13-20020a056902138d00b00d9a4e296353mr13218ybu.0.1696886798378; Mon, 09 Oct 2023 14:26:38 -0700 (PDT) Date: Mon, 9 Oct 2023 14:26:36 -0700 In-Reply-To: <20231009204037.GK800259@ZenIV> Mime-Version: 1.0 References: <20230928180651.1525674-1-pbonzini@redhat.com> <169595365500.1386813.6579237770749312873.b4-ty@google.com> <20231009022248.GD800259@ZenIV> <20231009200608.GJ800259@ZenIV> <20231009204037.GK800259@ZenIV> Message-ID: Subject: Re: [PATCH gmem FIXUP] kvm: guestmem: do not use a file system From: Sean Christopherson To: Al Viro Cc: linux-kernel@vger.kernel.org, kvm@vger.kernel.org, Paolo Bonzini Content-Type: text/plain; charset="us-ascii" X-Spam-Status: No, score=-4.8 required=5.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_PASS, USER_IN_DEF_DKIM_WL autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (morse.vger.email [0.0.0.0]); Mon, 09 Oct 2023 14:27:00 -0700 (PDT) On Mon, Oct 09, 2023, Al Viro wrote: > On Mon, Oct 09, 2023 at 01:20:06PM -0700, Sean Christopherson wrote: > > On Mon, Oct 09, 2023, Al Viro wrote: > > > On Mon, Oct 09, 2023 at 07:32:48AM -0700, Sean Christopherson wrote: > > > > > > > Yeah, we found that out the hard way. Is using the "secure" variant to get a > > > > per-file inode a sane approach, or is that abuse that's going to bite us too? > > > > > > > > /* > > > > * Use the so called "secure" variant, which creates a unique inode > > > > * instead of reusing a single inode. Each guest_memfd instance needs > > > > * its own inode to track the size, flags, etc. > > > > */ > > > > file = anon_inode_getfile_secure(anon_name, &kvm_gmem_fops, gmem, > > > > O_RDWR, NULL); > > > > > > Umm... Is there any chance that your call site will ever be in a module? > > > If not, you are probably OK with that variant. > > > > Yes, this code can be compiled as a module. I assume there issues with the inode > > outliving the module? > > The entire file, actually... If you are using that mechanism in a module, you > need to initialize kvm_gmem_fops.owner to THIS_MODULE; AFAICS, you don't have > that done. Ah, that's handled indirectly handled by a chain of refcounted objects. Every VM that KVM creates gets a reference to the module, and each guest_memfd instance gets a reference to its owning VM. Thanks much for the help!