Received: by 2002:a05:7412:da14:b0:e2:908c:2ebd with SMTP id fe20csp2206113rdb; Mon, 9 Oct 2023 17:09:33 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFVRWKNd6G6fJZFcuJ1lTQNJ5ERKCRUcAbuyMLv4RtN7OfL6WiQCE2zh21pKiT5GzisN8cF X-Received: by 2002:a05:6a21:81a5:b0:16e:b6eb:19f2 with SMTP id pd37-20020a056a2181a500b0016eb6eb19f2mr5423080pzb.61.1696896572905; Mon, 09 Oct 2023 17:09:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696896572; cv=none; d=google.com; s=arc-20160816; b=ANvJdoe7qB5OQVxkcmp4p6hRj3HUmfxcdOXc5irvCcOxIn5K9vE+Th86Xks0FxqSzW eD09VIpp45A3ycrgM8uMDLScy0pxLKy8ALBN29JgBPJKTuCgM9Cm9pMiFNcHCBPL+ccO lAz6QTeqoGbGlP6dj/w/FA2PxRGm22TMAhvsp1mqCgzO4h/i5tQNfbL6N3uh+idRMnE4 a7Vwr+DYlM/00EUZnE6++2VAQb0oIOPppJZ0gzAS9Xt/6GSETGt6Vaj++Mme+4fPzBpO Mpjq4O6KgJ21Xa3qe/SxzzdHU93tbPiuZoDGhFHllRTfRhfCA8lEfoqTPtZ82p2A5sbi XqjA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=n9xu3Z/aqGuYgnlZo2/hESvC9ySythWvvumkFQkDfT0=; fh=7A2vjXu/ewATeTgBdu7iBmgBP0mnBjez2UGBNdh/IPI=; b=Ic7hZQJG4876/gkjff3IgHgsodCiwPYTAictF1qAp3ChLsfv06BUNF2YfHshnyTFvU kbr/6PsseLwT90y0GDEF8tYpACbbtA/Sh72qMmPbDeA/yuFY2eoNmXuXfxvXAcKKKLhA h5Nm+CdU2FfTVWJCPtcN907tbi2BngiVNL6x2NvqfvqVWeJvz9yxUJtOdK0BUEOopKHE yhu4mTI15suP7C87It4bXjSa0mfs/b1GfSWY+/GE4xxW+0aufQN69Rcg3kEhGQUVt7dh bEmtWOpbkyJ1vuafnkl+ihRV7BKSZ0EqdhcgGKqp81V6UfltR58aet7kDKn29XpUgOLi 3bSw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.org.uk header.s=zeniv-20220401 header.b=XIqUa65u; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=zeniv.linux.org.uk Return-Path: Received: from fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id p13-20020a056a000a0d00b0068fb6fc3ff1si8761532pfh.209.2023.10.09.17.09.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Oct 2023 17:09:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.org.uk header.s=zeniv-20220401 header.b=XIqUa65u; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=zeniv.linux.org.uk Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id 2403B823CA1C; Mon, 9 Oct 2023 17:09:30 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1379127AbjJJAJO (ORCPT + 99 others); Mon, 9 Oct 2023 20:09:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60518 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1377918AbjJJAJN (ORCPT ); Mon, 9 Oct 2023 20:09:13 -0400 Received: from zeniv.linux.org.uk (zeniv.linux.org.uk [IPv6:2a03:a000:7:0:5054:ff:fe1c:15ff]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AF463A4; Mon, 9 Oct 2023 17:09:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=linux.org.uk; s=zeniv-20220401; h=Sender:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=n9xu3Z/aqGuYgnlZo2/hESvC9ySythWvvumkFQkDfT0=; b=XIqUa65uMPROPoc4TABSmUZlQX HgrnM9BAh0IwmOaqbe9PO+nenWlwimlzXtYXOGsoLx6PpeJFi8rIt2/4XH1AoGFo1SxgOYDk1VWeg HQ77KAcQR+QCnqr2aUsBZe0indo6PmGBo4srGu1m2kblgCFQ9ZjX0BPbsiUAWdc2cPisI4T1FLo1q 559gXGApBNxEXekxl5Cu5BUk0yeo2999kdjhEwsId8XxGoW8qIIZzbuj5n+guDBfUHZN5rXSZnpti RW00SDreI0ApchZ8/TuRyLsvdlzV6HNIq97UA7oJverC5ejAc8gmmdyJnVr1HZHDaen9UqirfZdg8 Ata5QWjA==; Received: from viro by zeniv.linux.org.uk with local (Exim 4.96 #2 (Red Hat Linux)) id 1qq0JC-00HLiS-27; Tue, 10 Oct 2023 00:09:10 +0000 Date: Tue, 10 Oct 2023 01:09:10 +0100 From: Al Viro To: Sean Christopherson Cc: linux-kernel@vger.kernel.org, kvm@vger.kernel.org, Paolo Bonzini Subject: Re: [PATCH gmem FIXUP] kvm: guestmem: do not use a file system Message-ID: <20231010000910.GM800259@ZenIV> References: <20230928180651.1525674-1-pbonzini@redhat.com> <169595365500.1386813.6579237770749312873.b4-ty@google.com> <20231009022248.GD800259@ZenIV> <20231009200608.GJ800259@ZenIV> <20231009204037.GK800259@ZenIV> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Sender: Al Viro X-Spam-Status: No, score=2.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_SBL_CSS, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.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 (fry.vger.email [0.0.0.0]); Mon, 09 Oct 2023 17:09:30 -0700 (PDT) X-Spam-Level: ** On Mon, Oct 09, 2023 at 02:26:36PM -0700, Sean Christopherson wrote: > 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. Umm... what's the usual call chain leading to final drop of refcount of that module?